File Coverage

blib/lib/Path/IsDev/Role/Matcher/FullPath/Is/Any.pm
Criterion Covered Total %
statement 38 46 82.6
branch 3 6 50.0
condition n/a
subroutine 8 8 100.0
pod 1 1 100.0
total 50 61 81.9


line stmt bran cond sub pod time code
1 14     14   5818 use 5.008; # utf8
  14         29  
2 14     14   49 use strict;
  14         17  
  14         234  
3 14     14   40 use warnings;
  14         21  
  14         255  
4 14     14   507 use utf8;
  14         23  
  14         67  
5              
6             package Path::IsDev::Role::Matcher::FullPath::Is::Any;
7              
8             our $VERSION = '1.001003';
9              
10             # ABSTRACT: Match if the current directory is the same directory from a list of absolute paths.
11              
12             our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
13              
14             sub _path {
15 64     64   214 require Path::Tiny;
16 64         482 Path::Tiny->VERSION('0.004');
17 64         224 goto &Path::Tiny::path;
18             }
19              
20 14     14   1673 use Role::Tiny;
  14         3106  
  14         61  
21              
22              
23              
24              
25              
26              
27              
28              
29              
30              
31              
32              
33              
34              
35              
36              
37              
38              
39              
40              
41              
42              
43             sub _fullpath_is {
44 64     64   88 my ( $self, $result_object, $this, $comparator ) = @_;
45              
46 64         71 my $context = {};
47              
48 64         107 $context->{tests} = [];
49              
50 64         98 $context->{test_path} = "$comparator";
51              
52 64         96 my $path = _path($comparator);
53              
54 64 50       1011 if ( not $path->exists ) {
55 0         0 push @{ $context->{tests} }, { 'test_path_exists?' => 0 };
  0         0  
56 0         0 $result_object->add_reason( $self, 0, "comparative path $comparator does not exist", $context );
57 0         0 return;
58             }
59              
60 64         1083 push @{ $context->{tests} }, { 'test_path_exists?' => 1 };
  64         156  
61              
62 64         134 my $realpath = $path->realpath;
63              
64 64         6975 $context->{source_realpath} = "$this";
65 64         230 $context->{test_realpath} = "$realpath";
66              
67 64 50       212 if ( not $realpath eq $this ) {
68 64         243 push @{ $context->{tests} }, { 'test_realpath_eq_source_realpath?' => 0 };
  64         146  
69 64         119 $result_object->add_reason( $self, 0, "$this ne $realpath", $context );
70 64         315 return;
71             }
72 0         0 push @{ $context->{tests} }, { 'test_realpath_eq_source_realpath?' => 1 };
  0         0  
73 0         0 $result_object->add_reason( $self, 1, "$this eq $realpath", $context );
74 0         0 return 1;
75             }
76              
77              
78              
79              
80              
81              
82              
83              
84              
85              
86              
87              
88              
89             sub fullpath_is_any {
90 32     32 1 63 my ( $self, $result_object, @dirnames ) = @_;
91 32         641 my $current = $result_object->path->realpath;
92 32         3900 for my $dirname (@dirnames) {
93 64 50       144 return 1 if $self->_fullpath_is( $result_object, $current, $dirname );
94             }
95 32         177 return;
96             }
97              
98             1;
99              
100             __END__