File.pm

filter: Statementstmt 96.3% 53 / 55 Branchbran 60.0% 6 / 10 Conditioncond 44.4% 4 / 9 MC/DCmcdc 16.6% 1 / 6 Subroutinesub 100% 11 / 11 Podpod 100% 5 / 5 totaltotal 83.3% 80 / 96 CC 9 SCAR 9.3
CC
9
Cov
85%
new
4.6
update
3.2
load
3.0
CRAP 2.5
« File/Driver/FreezeThaw.pm ↑ Summary File/Driver.pm »
1 package MojoX::Session::Store::File;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use base 'MojoX::Session::Store';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 our $VERSION = '0.01';
11  
12 2 __PACKAGE__->attr(dir => File::Spec->tmpdir);
13 2 __PACKAGE__->attr(prefix => 'mojoxsess');
14 2 __PACKAGE__->attr(driver => 'MojoX::Session::Store::File::Driver::Storable');
15 2 __PACKAGE__->attr('_driver_instance');
16  
17 2 my $_driver_instance;
18  
19 1 ▶sub new {
Subroutine new: called CC=4 SCAR=15.2
Pod documented
20 1 my $class = shift;
21  
22 1 my $self = $class->SUPER::new(@_);
23  
24 1 my $driver_classname = $self->driver;
25 1 ▶ unless($driver_classname =~ /^MojoX::Session::Store::File::Driver::/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($driver_classname =~ /^MojoX::Session::Store::File::Driver::/) 0 1 1
26 0 $driver_classname = "MojoX::Session::Store::File::Driver::$driver_classname";
27 }
28  
29 1 my $driver_available = eval "require $driver_classname; 1";
30 1 ▶ unless($driver_available) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($driver_available) 0 1 1
31 0 croak "Driver '$driver_classname' is not installed";
32 }
33  
34 1 ▶ $_driver_instance ||= $driver_classname->new;
Condition33%1/3
$_driver_instance ||= $driver_classname->new
l!l&&r!l&&!r
010
MC/DC0%0/2
$_driver_instance ||= $driver_classname->new
$_driver_instance $driver_classname->new
Truth table33%1/3
A ||= B
A= $_driver_instanceB= $driver_classname->new
ABresult
1X1
011
000
35 1 $self->_driver_instance($_driver_instance);
36  
37 1 $self;
38 }
39  
40 1 ▶sub create {
Subroutine create: called CC=2 SCAR=7.0
Pod documented
41 1 my $self = shift;
42  
43 1 my($sid, $expires, $data) = @_;
44  
45 1 my $file = $self->_get_file_name($sid);
46 1 ▶ return if -e $file;
Branch: 1 branch
BranchTrueFalseTotal
if -e $file 0 1 1
47  
48 1 return $self->_driver_instance->freeze($file, [$expires, $data]);
49 }
50  
51 1 ▶sub update {
Subroutine update: called CC=3 SCAR=11.8
Pod documented
52 1 my $self = shift;
53  
54 1 my($sid, $expires, $data) = @_;
55  
56 1 my $file = $self->_get_file_name($sid);
57 1 ▶ return if not -e $file or not -w _;
Branch: 1 branch
BranchTrueFalseTotal
unless -e $file and -w _ 0 1 1
Condition33%1/3
-e $file and -w _
!ll&&!rl&&r
001
MC/DC0%0/2
-e $file and -w _
-e $file -w _
Truth table33%1/3
A and B
A= -e $fileB= -w _
ABresult
0X0
100
111
58  
59 1 $self->_driver_instance->freeze($file, [$expires, $data]);
60 }
61  
62 3 ▶sub load {
Subroutine load: called CC=3 SCAR=11.0
Pod documented
63 3 my $self = shift;
64  
65 3 my $sid = shift;
66  
67 3 my $file = $self->_get_file_name($sid);
68 3 ▶ return if not -e $file or not -r _;
Branch: 1 branch
BranchTrueFalseTotal
unless -e $file and -r _ 1 2 3
Condition66%2/3
-e $file and -r _
!ll&&!rl&&r
102
MC/DC50%1/2
-e $file and -r _
-e $file -r _
Truth table66%2/3
A and B
A= -e $fileB= -r _
ABresult
0X0
100
111
69  
70 2 @{$self->_driver_instance->thaw($file)};
71 }
72  
73 1 ▶sub delete {
Subroutine delete: called CC=1 SCAR=0.0
Pod documented
74 1 my $self = shift;
75  
76 1 my $sid = shift;
77  
78 1 unlink $self->_get_file_name($sid);
79 }
80  
81 6 ▶sub _get_file_name {
Subroutine _get_file_name: called CC=1 SCAR=0.0
82 6 my $self = shift;
83  
84 6 my $sid = shift;
85  
86 6 File::Spec->catfile($self->dir, sprintf('%s_%s', $self->prefix, $sid));
87 }
88  
89 2 1;
90  
91 __END__
« File/Driver/FreezeThaw.pm ↑ Summary File/Driver.pm »