blib/lib/Text/MicroMason/Cache/File.pm

filter: Statementstmt 93.1% 27 / 29 Branchbran 75.0% 6 / 8 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 84.0% 42 / 50 CC 6 SCAR 14.1
CC
6
Cov
85%
get
6.6
BEGIN
1.0
BEGIN
1.0
CRAP 4.1
« blib/lib/Text/MicroMason/HTMLMason.pm ↑ Summary blib/lib/Text/MicroMason/Debug.pm »
1 package Text::MicroMason::Cache::File;
2 4 @ISA = 'Text::MicroMason::Cache::Simple';
3  
4 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 # Array field names
7 4 ▶use constant LAST_CHECK => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use constant AGE => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use constant VALUE => 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 ######################################################################
12  
13 26 ▶sub get {
Subroutine get: called CC=6 SCAR=18.9
Pod documented
14 26 my ( $self, $file ) = @_;
15 26 ▶ my $entry = $self->SUPER::get( $file )
Branch: 1 branch
BranchTrueFalseTotal
my $entry = $self->SUPER::get($file) or return 17 9 26
16 or return;
17 17 ▶ unless (ref($entry) eq 'ARRAY' and @$entry == 3 ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $entry eq "ARRAY" and @$entry == 3) 0 17 17
Condition33%1/3
ref $entry eq "ARRAY" and @$entry == 3
!ll&&!rl&&r
0017
MC/DC0%0/2
ref $entry eq "ARRAY" and @$entry == 3
ref $entry eq "ARRAY" @$entry == 3
Truth table33%1/3
A and B
A= ref $entry eq "ARRAY"B= @$entry == 3
ABresult
0X0
100
111
18 0 Carp::croak("MicroMason: cache '$self' data corrupted; " .
19 "value for '$file' should not be '$entry'");
20 }
21
22 17 my $time = time();
23 17 ▶ if ( $entry->[LAST_CHECK] < $time ) { # don't check more than once per second
Branch: 1 branch
BranchTrueFalseTotal
if ($entry->[0] < $time) 2 15 17
24 2 my $current_age = -M $file;
25 2 ▶ if ( $entry->[AGE] > $current_age ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($entry->[1] > $current_age) { } 2 0 2
26 2 @$entry = ( 0, 0, undef ); # file has changed; cache invalid
27 2 return;
28 } else {
29 0 $entry->[LAST_CHECK] = $time;
30 }
31 }
32 15 return $entry->[VALUE];
33 }
34  
35 11 ▶sub set {
Subroutine set: called CC=1 SCAR=0.0
Pod documented
36 11 my ($self, $file, $sub) = @_;
37 11 $self->SUPER::set( $file => [ time(), -M $file, $sub ] );
38 11 return $sub;
39 }
40  
41 ######################################################################
42  
43 4 1;
44  
45 __END__
« blib/lib/Text/MicroMason/HTMLMason.pm ↑ Summary blib/lib/Text/MicroMason/Debug.pm »