| 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
Condition100%3/3
not -e $io or $io->slurp_utf8 ne $$text_ref
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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
not -e $io or $io->slurp ne $$text_ref
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
| |||||||||||||||||||||||||||||
| 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
Condition33%1/3
not -e $io or $io->slurp_raw ne $$text_ref
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
| |||||||||||||||||||||||||||||
| 55 | { | ||||||||||||||||||||||||||||
| 56 | 1 | $io->spew_raw($$text_ref); | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 1 | return; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 2 | 1; | |||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | __END__ | ||||||||||||||||||||||||||||