This file is indexed.

/usr/share/perl5/Scrappy/Session.pm is in libscrappy-perl 0.94112090-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# ABSTRACT: Scrappy Scraper Session Handling
# Dist::Zilla: +PodWeaver

package Scrappy::Session;

BEGIN {
    $Scrappy::Session::VERSION = '0.94112090';
}

# load OO System
use Moose;

# load other libraries
use Carp;
use YAML::Syck;
$YAML::Syck::ImplicitTyping = 1;

has 'auto_save' => (is => 'rw', isa => 'Bool', default => 1);
has 'file' => (is => 'rw', isa => 'Str');


sub load {
    my $self = shift;
    my $file = shift;

    if ($file) {

        $self->file($file);

        croak("Session file $file does not exist or is not read/writable")
          unless -f $file;

        # load session file
        $self->{stash} = LoadFile($file);
    }

    return $self->{stash};
}


sub stash {
    my $self = shift;
    $self->{stash} = {} unless defined $self->{stash};

    if (@_) {
        my $stash = @_ > 1 ? {@_} : $_[0];
        if ($stash) {
            if (ref $stash eq 'HASH') {
                for (keys %{$stash}) {
                    if (lc $_ ne ':file') {
                        $self->{stash}->{$_} = $stash->{$_};
                    }
                    else {
                        $self->{file} = $stash->{$_};
                    }
                }
            }
            else {
                return $self->{stash}->{$stash};
            }
        }
    }

    $self->auto_write;
    return $self->{stash};
}


sub write {
    my $self = shift;
    my $file = shift || $self->file;

    $self->file($file);

    if ($file) {

        # write session file
        DumpFile($file, $self->{stash});

        # ... ummm
        croak("Session file $file does not exist or is not read/writable")
          unless -f $file;
    }

    return $self->{stash};
}

sub auto_write {
    my $self = shift;
    $self->write if $self->auto_save;

    return $self;
}

1;

__END__

=pod

=head1 NAME

Scrappy::Session - Scrappy Scraper Session Handling

=head1 VERSION

version 0.94112090

=head1 SYNOPSIS

    #!/usr/bin/perl
    use Scrappy::Session;

    my  $session = Scrappy::Session->new;
    
        -f 'scraper.sess' ?
        $session->load('scraper.sess');
        $session->write('scraper.sess');
        
        $session->stash('foo' => 'bar');
        $session->stash('abc' => [('a'..'z')]);

=head1 DESCRIPTION

Scrappy::Session provides YAML-Based session file handling for saving recorded
data across multiple execution using the L<Scrappy> framework.

=head2 ATTRIBUTES

The following is a list of object attributes available with every Scrappy::Session
instance.

=head3 auto_save

The auto_save attribute is a boolean that determines whether stash data is
automatically saved to the session file on update.

    my  $session = Scrappy::Session->new;
        
        $session->load('scraper.sess');
        $session->stash('foo' => 'bar');
        
        # turn auto-saving off
        $session->auto_save(0);
        $session->stash('foo' => 'bar');
        $session->write; # explicit write

=head3 file

The file attribute gets/sets the filename of the current session file.

    my  $session = Scrappy::Session->new;
        
        $session->load('scraper.sess');
        $session->write('scraper.sess.bak');
        $session->file('scraper.sess');

=head1 METHODS

=head2 load

The load method is used to read-in a session file, it returns its data in the
structure it was saved-in.

    my  $session = Scrappy::Session->new;
    my  $data = $session->load('scraper.sess');

=head2 stash

The stash method accesses the stash object which is used to store data to be
written to the session file.

    my  $session = Scrappy::Session->new;
        $session->load('scraper.sess');
        
        $session->stash('foo' => 'bar');
        $session->stash('abc' => [('a'..'z')]);
        $session->stash->{123} = [(1..9)];

=head2 write

The write method is used to write-out a session file, it saves the data stored
in the session stash and it returns the data written upon completion.

    my  $session = Scrappy::Session->new;
    
        $session->stash('foo' => 'bar');
        $session->stash('abc' => [('a'..'z')]);
        $session->stash->{123} = [(1..9)];
    
    my  $data = $session->write('scraper.sess');

=head1 AUTHOR

Al Newkirk <awncorp@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2010 by awncorp.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut