File Coverage

blib/lib/Path/IsDev/Role/Matcher/Child/BaseName/MatchRegexp/File.pm
Criterion Covered Total %
statement 30 30 100.0
branch 4 4 100.0
condition 3 3 100.0
subroutine 7 7 100.0
pod 1 1 100.0
total 45 45 100.0


line stmt bran cond sub pod time code
1 9     9   3775 use 5.008; # utf8
  9         20  
2 9     9   30 use strict;
  9         11  
  9         146  
3 9     9   25 use warnings;
  9         14  
  9         166  
4 9     9   538 use utf8;
  9         29  
  9         48  
5              
6             package Path::IsDev::Role::Matcher::Child::BaseName::MatchRegexp::File;
7              
8             our $VERSION = '1.001003';
9              
10             # ABSTRACT: Match if any children have basename's that match a regexp and are files
11              
12             our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
13              
14 9     9   919 use Role::Tiny qw( with );
  9         3214  
  9         40  
15             with 'Path::IsDev::Role::Matcher::Child::BaseName::MatchRegexp';
16              
17              
18              
19              
20              
21              
22              
23              
24              
25              
26              
27              
28              
29              
30              
31              
32              
33              
34              
35              
36              
37             sub _this_child_isfile {
38 5     5   8 my ( $self, $result_object, $child ) = @_;
39 5         12 my $ctx = {
40             'child' => "$child",
41             tests => [],
42             };
43 5         20 my $tests = $ctx->{tests};
44              
45             ## no critic (ValuesAndExpressions::ProhibitFiletest_f)
46 5 100       12 if ( -f $child ) {
47 3         56 push @{$tests}, { 'child_isfile?' => 1 };
  3         9  
48 3         9 $result_object->add_reason( $self, 1, "$child is a file", $ctx );
49 3         26 return 1;
50             }
51 2         34 push @{$tests}, { 'child_isfile?' => 0 };
  2         7  
52 2         4 $result_object->add_reason( $self, 0, "$child is not a file", $ctx );
53              
54 2         9 return;
55             }
56              
57              
58              
59              
60              
61              
62              
63              
64              
65              
66              
67              
68              
69              
70             sub child_basename_matchregexp_file {
71 9     9 1 12 my ( $self, $result_object, $regexp ) = @_;
72 9         185 for my $child ( $result_object->path->children ) {
73 24 100 100     1258 return 1
74             if $self->_this_child_matchregexp( $result_object, $child, $regexp )
75             and $self->_this_child_isfile( $result_object, $child );
76             }
77 6         137 return;
78              
79             }
80              
81             1;
82              
83             __END__