blib/lib/Path/Class/File/Stat.pm

filter: Statementstmt 89.3% 42 / 47 Branchbran 62.5% 10 / 16 Conditioncond 71.4% 10 / 14 MC/DCmcdc 42.8% 3 / 7 Subroutinesub 100% 7 / 7 Podpod 100% 4 / 4 totaltotal 80.0% 76 / 95 CC 13 SCAR 20.5
CC
13
Cov
81%
changed
12.0
use_md5
3.8
BEGIN
1.0
CRAP 7.8
↑ Summary
1 package Path::Class::File::Stat;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use base qw( Path::Class::File );
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 our $VERSION = '0.05';
7  
8 1 ▶my $debug = $ENV{PERL_DEBUG} || 0;
Condition50%1/2
$ENV{'PERL_DEBUG'} || 0
l!l
01
MC/DC0%0/1
$ENV{'PERL_DEBUG'} || 0
$ENV{'PERL_DEBUG'}
Truth table50%1/2
A
A= $ENV{'PERL_DEBUG'}
Aresult
11
00
9  
10 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
11 1 my $self = shift->SUPER::new(@_);
12 1 $self->{_stat} = $self->stat;
13 1 return $self;
14 }
15  
16 1 ▶sub use_md5 {
Subroutine use_md5: called CC=3 SCAR=13.5
Pod documented
17 1 my $self = shift;
18 1 ▶ if ( exists $self->{_md5} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"_md5"}) 0 1 1
19 0 ▶ $debug and warn "_md5 exists: $self->{_md5}";
Branch: 1 branch
BranchTrueFalseTotal
$debug and warn qq[_md5 exists: $self->{"_md5"}] 0 0 0
20 0 return $self->{_md5};
21 }
22 1 require Digest::MD5;
23 1 $self->{_md5} = Digest::MD5::md5_hex( $self->slurp );
24 1 return $self->{_md5};
25 }
26  
27 5 ▶sub changed {
Subroutine changed: called CC=11 SCAR=24.8
Pod documented
28 5 my $self = shift;
29 5 my ( $old_sig, $new_sig, $sig_changed, $io_changed, $mtime_changed,
30 $size_changed );
31 5 ▶ if ( exists $self->{_md5} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"_md5"}) 2 3 5
32 2 $old_sig = $self->{_md5};
33 2 $new_sig = Digest::MD5::md5_hex( $self->slurp );
34 2 ▶ $debug and warn "old_sig=$old_sig new_sig=$new_sig";
Branch: 1 branch
BranchTrueFalseTotal
$debug and warn "old_sig=$old_sig new_sig=$new_sig" 0 2 2
35 2 $sig_changed = $old_sig ne $new_sig;
36 }
37 5 my $new_stat = $self->stat;
38 5 my $old_stat = $self->{_stat};
39  
40 5 ▶ $io_changed = ( $old_stat->dev ne $new_stat->dev
Condition33%1/3
$old_stat->dev ne $new_stat->dev && $old_stat->ino ne $new_stat->ino
!ll&&!rl&&r
500
MC/DC0%0/2
$old_stat->dev ne $new_stat->dev && $old_stat->ino ne $new_stat->ino
$old_stat->dev ne $new_stat->dev $old_stat->ino ne $new_stat->ino
Truth table33%1/3
A && B
A= $old_stat->dev ne $new_stat->devB= $old_stat->ino ne $new_stat->ino
ABresult
0X0
100
111
41 && $old_stat->ino ne $new_stat->ino );
42 5 $mtime_changed = $old_stat->mtime ne $new_stat->mtime;
43 5 $size_changed = $old_stat->size ne $new_stat->size;
44  
45 5 ▶ if ($debug) {
Branch: 1 branch
BranchTrueFalseTotal
if ($debug) 0 5 5
46 0 require Data::Dump;
47 0 Data::Dump::dump($new_stat);
48 0 Data::Dump::dump($old_stat);
49  
50 #Data::Dump::dump($self);
51 }
52  
53 5 ▶ if ( $io_changed || $mtime_changed || $size_changed || $sig_changed ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($io_changed or $mtime_changed or $size_changed or $sig_changed) 4 1 5
Condition88%8/9
$io_changed or $mtime_changed or $size_changed or $sig_changed
l!l&&r!l&&!r
311
$io_changed or $mtime_changed or $size_changed
l!l&&r!l&&!r
212
$io_changed or $mtime_changed
l!l&&r!l&&!r
023
MC/DC75%3/4
$io_changed or $mtime_changed or $size_changed or $sig_changed
$io_changed $mtime_changed $size_changed $sig_changed
Truth table80%4/5
A or B or C or D
A= $io_changedB= $mtime_changedC= $size_changedD= $sig_changed
ABCDresult
1XXX1
01XX1
001X1
00011
00000
54 4 ▶ $debug and warn "$self is not the file it once was\n";
Branch: 1 branch
BranchTrueFalseTotal
$debug and warn "$self is not the file it once was\n" 0 4 4
55 4 ▶ $self->{_md5} = $new_sig if $sig_changed;
Branch: 1 branch
BranchTrueFalseTotal
if $sig_changed 1 3 4
56 4 return $self->restat;
57 }
58 1 return 0;
59 }
60  
61 5 ▶sub restat {
Subroutine restat: called CC=1 SCAR=0.0
Pod documented
62 5 my $self = shift;
63 5 my $old = $self->{_stat};
64 5 $self->{_stat} = $self->stat;
65 5 return $old;
66 }
67  
68 1 1;
69  
70 __END__
↑ Summary