blib/lib/File/Update.pm

filter: Statementstmt 86.2% 25 / 29 Branchbran 50.0% 4 / 8 Conditioncond 44.4% 4 / 9 MC/DCmcdc 33.3% 2 / 6 Subroutinesub 85.7% 6 / 7 Podpod 100% 4 / 4 totaltotal 71.4% 45 / 63 CC 8 SCAR 14.9
CC
8
Cov
72%
write_on_change_no_utf8
12.0
write_on_change_raw
3.3
write_on_change
3.0
CRAP 4.4
↑ Summary Build »
1 package File::Update;
2 2 $File::Update::VERSION = '0.2.0';
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 = (
9 qw(modify_on_change write_on_change write_on_change_raw write_on_change_no_utf8)
10 );
11  
12 sub write_on_change
13 {
14 3 ▶ my ( $io, $text_ref ) = @_;
Subroutine write_on_change: called CC=3 SCAR=11.0
Pod documented
15  
16 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
17 {
18 2 $io->spew_utf8($$text_ref);
19 }
20  
21 3 return;
22 }
23  
24 sub modify_on_change
25 {
26 1 ▶ my ( $io, $sub_ref ) = @_;
Subroutine modify_on_change: called CC=2 SCAR=7.0
Pod documented
27  
28 1 my $text = $io->slurp_utf8();
29  
30 1 ▶ if ( $sub_ref->( \$text ) )
Branch: 1 branch
BranchTrueFalseTotal
if (&$sub_ref(\$text)) 1 0 1
31 {
32 1 $io->spew_utf8($text);
33 }
34  
35 1 return;
36 }
37  
38 sub write_on_change_no_utf8
39 {
40 0 ▶ my ( $io, $text_ref ) = @_;
Subroutine write_on_change_no_utf8: not called CC=3 SCAR=24.8
Pod documented
41  
42 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
43 {
44 0 $io->spew($$text_ref);
45 }
46  
47 0 return;
48 }
49  
50 sub write_on_change_raw
51 {
52 1 ▶ my ( $io, $text_ref ) = @_;
Subroutine write_on_change_raw: called CC=3 SCAR=12.0
Pod documented
53  
54 1 ▶ if ( ( !-e $io ) or ( $io->slurp_raw() ne $$text_ref ) )
Branch: 1 branch
BranchTrueFalseTotal
if (not -e $io or $io->slurp_raw ne $$text_ref) 1 0 1
Condition33%1/3
not -e $io or $io->slurp_raw ne $$text_ref
l!l&&r!l&&!r
100
MC/DC0%0/2
not -e $io or $io->slurp_raw ne $$text_ref
not -e $io $io->slurp_raw ne $$text_ref
Truth table33%1/3
not(A) or B
A= not -e $ioB= $io->slurp_raw ne $$text_ref
ABresult
1X1
011
000
55 {
56 1 $io->spew_raw($$text_ref);
57 }
58  
59 1 return;
60 }
61  
62 2 1;
63  
64 __END__
↑ Summary Build »