| 1 | package File::ShouldUpdate; | ||||||||||||||||||||||||||||
| 2 | 2 | $File::ShouldUpdate::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 | 2 | ▶ | use Time::HiRes qw/ stat /; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use parent 'Exporter'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use vars qw/ @EXPORT_OK /; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 2 | @EXPORT_OK = qw/ should_update should_update_multi /; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | sub should_update_multi | ||||||||||||||||||||||||||||
| 12 | { | ||||||||||||||||||||||||||||
| 13 | 4 | ▶ | my ( $new_files, $syntax_sugar, $deps ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
should_update_multi: called CC=8 SCAR=21.1
Pod
documented
| |||||||||||||||||||||||||||||
| 14 | 4 | ▶ | if ( $syntax_sugar ne ":" ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 15 | { | ||||||||||||||||||||||||||||
| 16 | 0 | die qq#wrong syntax_sugar - not ":"!#; | |||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||
| 18 | 4 | my $min_dep; | |||||||||||||||||||||||||||
| 19 | 4 | foreach my $filename2 (@$new_files) | |||||||||||||||||||||||||||
| 20 | { | ||||||||||||||||||||||||||||
| 21 | 6 | my @stat2 = stat($filename2); | |||||||||||||||||||||||||||
| 22 | 6 | ▶ | if ( !@stat2 ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | { | ||||||||||||||||||||||||||||
| 24 | 2 | return 1; | |||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | 4 | my $new = $stat2[9]; | |||||||||||||||||||||||||||
| 27 | 4 | ▶ | if ( ( !defined $min_dep ) or ( $min_dep > $new ) ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $min_dep or $min_dep > $new
MC/DC50%1/2
not defined $min_dep or $min_dep > $new
not defined $min_dep
$min_dep > $new
Truth table66%2/3
not(A) or B
A= not defined $min_depB= $min_dep > $new
| |||||||||||||||||||||||||||||
| 28 | { | ||||||||||||||||||||||||||||
| 29 | 3 | $min_dep = $new; | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | 2 | foreach my $d (@$deps) | |||||||||||||||||||||||||||
| 33 | { | ||||||||||||||||||||||||||||
| 34 | 4 | my @stat1 = stat($d); | |||||||||||||||||||||||||||
| 35 | 4 | ▶ | return 1 if ( $stat1[9] > $min_dep ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | 2 | return 0; | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | sub should_update | ||||||||||||||||||||||||||||
| 41 | { | ||||||||||||||||||||||||||||
| 42 | 2 | ▶ | my ( $filename2, $syntax_sugar, @deps ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
should_update: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||
| 43 | 2 | ▶ | if ( $syntax_sugar ne ":" ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | { | ||||||||||||||||||||||||||||
| 45 | 0 | die qq#wrong syntax_sugar - not ":"!#; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | 2 | return should_update_multi( [$filename2], $syntax_sugar, \@deps ); | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 2 | 1; | |||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | __END__ | ||||||||||||||||||||||||||||