| 1 | 24 | ▶ | use 5.008; # utf8 | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 24 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 24 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 24 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | package Path::IsDev::Role::Matcher::Child::Exists::Any; | ||||||||||
| 7 | |||||||||||
| 8 | 24 | our $VERSION = '1.001003'; | |||||||||
| 9 | |||||||||||
| 10 | # ABSTRACT: Match if any of a list of children exists | ||||||||||
| 11 | |||||||||||
| 12 | 24 | our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY | |||||||||
| 13 | |||||||||||
| 14 | 24 | ▶ | use Role::Tiny; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | |||||||||||
| 16 | |||||||||||
| 17 | |||||||||||
| 18 | |||||||||||
| 19 | |||||||||||
| 20 | |||||||||||
| 21 | |||||||||||
| 22 | |||||||||||
| 23 | |||||||||||
| 24 | |||||||||||
| 25 | |||||||||||
| 26 | |||||||||||
| 27 | |||||||||||
| 28 | |||||||||||
| 29 | |||||||||||
| 30 | |||||||||||
| 31 | |||||||||||
| 32 | |||||||||||
| 33 | |||||||||||
| 34 | |||||||||||
| 35 | 111 | ▶ | sub child_exists { | ||||||||
|
Subroutine
child_exists: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 36 | 111 | my ( $self, $result_object, $child ) = @_; | |||||||||
| 37 | |||||||||||
| 38 | 111 | my $child_path = $result_object->path->child($child); | |||||||||
| 39 | |||||||||||
| 40 | 111 | my $ctx = { 'child_name' => $child, child_path => "$child_path", tests => [] }; | |||||||||
| 41 | 111 | my $tests = $ctx->{tests}; | |||||||||
| 42 | |||||||||||
| 43 | 111 | ▶ | if ( -e $child_path ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | 12 | push @{$tests}, { 'child_path_exists?' => 1 }; | |||||||||
| 45 | 12 | $result_object->add_reason( $self, 1, "$child exists", $ctx ); | |||||||||
| 46 | 12 | return 1; | |||||||||
| 47 | } | ||||||||||
| 48 | 99 | push @{$tests}, { 'child_path_exists?' => 0 }; | |||||||||
| 49 | 99 | $result_object->add_reason( $self, 0, "$child does not exist", $ctx ); | |||||||||
| 50 | 99 | return; | |||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | |||||||||||
| 54 | |||||||||||
| 55 | |||||||||||
| 56 | |||||||||||
| 57 | |||||||||||
| 58 | |||||||||||
| 59 | |||||||||||
| 60 | |||||||||||
| 61 | 0 | ▶ | sub child_exists_any { | ||||||||
|
Subroutine
child_exists_any: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 62 | 0 | my ( $self, $result_object, @children ) = @_; | |||||||||
| 63 | 0 | for my $child (@children) { | |||||||||
| 64 | 0 | ▶ | return 1 if $self->child_exists( $result_object, $child ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 65 | } | ||||||||||
| 66 | 0 | return; | |||||||||
| 67 | } | ||||||||||
| 68 | |||||||||||
| 69 | 24 | 1; | |||||||||
| 70 | |||||||||||
| 71 | __END__ | ||||||||||