blib/lib/File/Update.pm

filter: Statementstmt 84.0% 21 / 25 Branchbran 50.0% 3 / 6 Conditioncond 50.0% 3 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 83.3% 5 / 6 Podpod 100% 3 / 3 totaltotal 74.0% 37 / 50 CC 6 SCAR 15.5
CC
6
Cov
73%
write_on_change_no_utf8
12.0
write_on_change
3.0
modify_on_change
2.0
CRAP 4.7
↑ Summary Build »
1 package File::Update;
2 2 $File::Update::VERSION = '0.0.3';
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  
6 2 ▶use parent 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 our @EXPORT_OK = (qw(modify_on_change write_on_change write_on_change_no_utf8));
9  
10 sub write_on_change
11 {
12 3 ▶ my ( $io, $text_ref ) = @_;
Subroutine write_on_change: called CC=3 SCAR=11.0
Pod documented
13  
14 3 ▶ if ( ( !-e $io ) or ( $io->slurp_utf8() ne $$text_ref ) )
Branch: 1 branch
BranchTrueFalseTotal
if (not -e $io or $io->slurp_utf8 ne $$text_ref) 2 1 3
Condition100%3/3
not -e $io or $io->slurp_utf8 ne $$text_ref
l!l&&r!l&&!r
111
MC/DC100%2/2
not -e $io or $io->slurp_utf8 ne $$text_ref
not -e $io $io->slurp_utf8 ne $$text_ref
Truth table100%3/3
not(A) or B
A= not -e $ioB= $io->slurp_utf8 ne $$text_ref
ABresult
1X1
011
000
15 {
16 2 $io->spew_utf8($$text_ref);
17 }
18  
19 3 return;
20 }
21  
22 sub modify_on_change
23 {
24 1 ▶ my ( $io, $sub_ref ) = @_;
Subroutine modify_on_change: called CC=2 SCAR=7.0
Pod documented
25  
26 1 my $text = $io->slurp_utf8();
27  
28 1 ▶ if ( $sub_ref->( \$text ) )
Branch: 1 branch
BranchTrueFalseTotal
if (&$sub_ref(\$text)) 1 0 1
29 {
30 1 $io->spew_utf8($text);
31 }
32  
33 1 return;
34 }
35  
36 sub write_on_change_no_utf8
37 {
38 0 ▶ my ( $io, $text_ref ) = @_;
Subroutine write_on_change_no_utf8: not called CC=3 SCAR=24.8
Pod documented
39  
40 0 ▶ if ( ( !-e $io ) or ( $io->slurp() ne $$text_ref ) )
Branch: 1 branch
BranchTrueFalseTotal
if (not -e $io or $io->slurp ne $$text_ref) 0 0 0
Condition0%0/3
not -e $io or $io->slurp ne $$text_ref
l!l&&r!l&&!r
000
MC/DC0%0/2
not -e $io or $io->slurp ne $$text_ref
not -e $io $io->slurp ne $$text_ref
Truth table0%0/3
not(A) or B
A= not -e $ioB= $io->slurp ne $$text_ref
ABresult
1X1
011
000
41 {
42 0 $io->spew($$text_ref);
43 }
44  
45 0 return;
46 }
47  
48 2 1;
49  
50 __END__
↑ Summary Build »