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