File Coverage

blib/lib/Apache/Session/Browseable/File.pm
Criterion Covered Total %
statement 24 56 42.8
branch 0 10 0.0
condition 0 3 0.0
subroutine 8 11 72.7
pod 0 2 0.0
total 32 82 39.0


line stmt bran cond sub pod time code
1             package Apache::Session::Browseable::File;
2              
3 1     1   1280 use strict;
  1         2  
  1         41  
4              
5 1     1   522 use Apache::Session;
  1         1349  
  1         27  
6 1     1   488 use Apache::Session::Lock::File;
  1         2142  
  1         30  
7 1     1   388 use Apache::Session::Browseable::Store::File;
  1         2  
  1         28  
8 1     1   504 use Apache::Session::Generate::MD5;
  1         231  
  1         28  
9 1     1   414 use Apache::Session::Serialize::Storable;
  1         3366  
  1         25  
10 1     1   399 use Apache::Session::Browseable::_common;
  1         3  
  1         31  
11 1     1   6 use Storable qw(thaw);
  1         1  
  1         437  
12              
13             our $VERSION = '1.0';
14             our @ISA = qw(Apache::Session Apache::Session::Browseable::_common);
15              
16             sub populate {
17 0     0 0   my $self = shift;
18              
19 0           $self->{object_store} = new Apache::Session::Browseable::Store::File $self;
20 0           $self->{lock_manager} = new Apache::Session::Lock::File $self;
21 0           $self->{generate} = \&Apache::Session::Generate::MD5::generate;
22 0           $self->{validate} = \&Apache::Session::Generate::MD5::validate;
23 0           $self->{serialize} = \&Apache::Session::Serialize::Storable::serialize;
24 0           $self->{unserialize} = \&Apache::Session::Serialize::Storable::unserialize;
25              
26 0           return $self;
27             }
28              
29             sub DESTROY {
30 0     0     my $self = shift;
31              
32 0           $self->save;
33 0           $self->{object_store}->close;
34 0           $self->release_all_locks;
35             }
36              
37             sub get_key_from_all_sessions {
38 0     0 0   my $class = shift;
39 0           my $args = shift;
40 0           my $data = shift;
41 0   0       $args->{Directory} ||= $Apache::Session::Store::File::Directory;
42              
43 0 0         unless ( opendir DIR, $args->{Directory} ) {
44 0           die "Cannot open directory $args->{Directory}\n";
45             }
46 0 0         my @t =
47 0           grep { -f "$args->{Directory}/$_" and /^[A-Za-z0-9@\-]+$/ } readdir(DIR);
48 0           closedir DIR;
49 0           my %res;
50 0           for my $f (@t) {
51 0           open F, "$args->{Directory}/$f";
52 0           my $row = join '', ;
53 0 0         if ( ref($data) eq 'CODE' ) {
    0          
54 0           $res{$f} = &$data( thaw($row), $f );
55             }
56             elsif ($data) {
57 0 0         $data = [$data] unless ( ref($data) );
58 0           my $tmp = thaw($row);
59 0           $res{$f}->{$_} = $tmp->{$_} foreach (@$data);
60             }
61             else {
62 0           $res{$f} = thaw($row);
63             }
64             }
65 0           return \%res;
66             }
67              
68             1;
69             __END__