« IsDev/Role/Matcher/Child/BaseName/MatchRegexp/File.pm
↑ Summary
IsDev/Role/Matcher/FullPath/Is/Any.pm »
| 1 | 20 | ▶ | use 5.008; # utf8 | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 20 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 20 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 20 | ▶ | use utf8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | package Path::IsDev::Role::Matcher::Child::Exists::Any::File; | ||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 20 | our $VERSION = '1.001003'; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | # ABSTRACT: Match if a path contains one of any of a list of files | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 20 | our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 20 | ▶ | use Role::Tiny qw( with ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 27 | 20 | with 'Path::IsDev::Role::Matcher::Child::Exists::Any'; | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 11 | ▶ | sub child_exists_file { | ||||||||||||||||||||||||||
|
Subroutine
child_exists_file: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 38 | 11 | my ( $self, $result_object, $child ) = @_; | |||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 11 | my $child_path = $result_object->path->child($child); | |||||||||||||||||||||||||||
| 41 | 11 | my $ctx = { 'child_name' => $child, child_path => "$child_path", tests => [] }; | |||||||||||||||||||||||||||
| 42 | 11 | my $tests = $ctx->{tests}; | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | # For now, yes, files, not things usable as files | ||||||||||||||||||||||||||||
| 45 | ## no critic (ValuesAndExpressions::ProhibitFiletest_f) | ||||||||||||||||||||||||||||
| 46 | 11 | ▶ | if ( -f $child_path ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | 9 | push @{$tests}, { 'child_path_isfile?' => 1 }; | |||||||||||||||||||||||||||
| 48 | 9 | $result_object->add_reason( $self, 1, "$child_path is a file", $ctx ); | |||||||||||||||||||||||||||
| 49 | 9 | return 1; | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | 2 | push @{$tests}, { 'child_path_isfile?' => 1 }; | |||||||||||||||||||||||||||
| 52 | 2 | $result_object->add_reason( $self, 0, "$child_path is not a file", $ctx ); | |||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 2 | return; | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 77 | ▶ | sub child_exists_any_file { | ||||||||||||||||||||||||||
|
Subroutine
child_exists_any_file: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 66 | 77 | my ( $self, $result_object, @children ) = @_; | |||||||||||||||||||||||||||
| 67 | 77 | for my $child (@children) { | |||||||||||||||||||||||||||
| 68 | 96 | ▶ | return 1 if $self->child_exists( $result_object, $child ) and $self->child_exists_file( $result_object, $child ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->child_exists($result_object, $child) and $self->child_exists_file($result_object, $child)
MC/DC100%2/2
$self->child_exists($result_object, $child) and $self->child_exists_file($result_object, $child)
$self->child_exists($result_object, $child)
$self->child_exists_file($result_object, $child)
Truth table100%3/3
A and B
A= $self->child_exists($result_object, $child)B= $self->child_exists_file($result_object, $child)
| |||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | 68 | return; | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 20 | 1; | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | __END__ | ||||||||||||||||||||||||||||