File Coverage

blib/lib/Path/IsDev/Role/Matcher/Child/Exists/Any/File.pm
Criterion Covered Total %
statement 31 31 100.0
branch 4 4 100.0
condition 3 3 100.0
subroutine 7 7 100.0
pod 2 2 100.0
total 47 47 100.0


line stmt bran cond sub pod time code
1 20     20   8373 use 5.008; # utf8
  20         47  
2 20     20   70 use strict;
  20         22  
  20         330  
3 20     20   61 use warnings;
  20         23  
  20         355  
4 20     20   502 use utf8;
  20         29  
  20         78  
5              
6             package Path::IsDev::Role::Matcher::Child::Exists::Any::File;
7              
8             our $VERSION = '1.001003';
9              
10             # ABSTRACT: Match if a path contains one of any of a list of files
11              
12             our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
13              
14              
15              
16              
17              
18              
19              
20              
21              
22              
23              
24              
25              
26 20     20   1467 use Role::Tiny qw( with );
  20         2911  
  20         90  
27             with 'Path::IsDev::Role::Matcher::Child::Exists::Any';
28              
29              
30              
31              
32              
33              
34              
35              
36              
37             sub child_exists_file {
38 11     11 1 22 my ( $self, $result_object, $child ) = @_;
39              
40 11         163 my $child_path = $result_object->path->child($child);
41 11         284 my $ctx = { 'child_name' => $child, child_path => "$child_path", tests => [] };
42 11         60 my $tests = $ctx->{tests};
43              
44             # For now, yes, files, not things usable as files
45             ## no critic (ValuesAndExpressions::ProhibitFiletest_f)
46 11 100       26 if ( -f $child_path ) {
47 9         150 push @{$tests}, { 'child_path_isfile?' => 1 };
  9         27  
48 9         28 $result_object->add_reason( $self, 1, "$child_path is a file", $ctx );
49 9         87 return 1;
50             }
51 2         32 push @{$tests}, { 'child_path_isfile?' => 1 };
  2         7  
52 2         7 $result_object->add_reason( $self, 0, "$child_path is not a file", $ctx );
53              
54 2         14 return;
55             }
56              
57              
58              
59              
60              
61              
62              
63              
64              
65             sub child_exists_any_file {
66 77     77 1 124 my ( $self, $result_object, @children ) = @_;
67 77         93 for my $child (@children) {
68 96 100 100     256 return 1 if $self->child_exists( $result_object, $child ) and $self->child_exists_file( $result_object, $child );
69             }
70 68         204 return;
71             }
72              
73             1;
74              
75             __END__