| 1 | package Parse::Path; | ||||||||||||||||||
| 2 | |||||||||||||||||||
| 3 | 7 | our $VERSION = '0.92'; # VERSION | |||||||||||||||||
| 4 | # ABSTRACT: Parser for paths | ||||||||||||||||||
| 5 | |||||||||||||||||||
| 6 | ############################################################################# | ||||||||||||||||||
| 7 | # Modules | ||||||||||||||||||
| 8 | |||||||||||||||||||
| 9 | 7 | ▶ | use sanity; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 10 | |||||||||||||||||||
| 11 | 7 | ▶ | use Scalar::Util qw( blessed ); | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 12 | 7 | ▶ | use Module::Runtime qw( use_module ); | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 13 | |||||||||||||||||||
| 14 | 7 | ▶ | use namespace::clean; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 15 | 7 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 16 | |||||||||||||||||||
| 17 | ############################################################################# | ||||||||||||||||||
| 18 | # Dispatcher | ||||||||||||||||||
| 19 | |||||||||||||||||||
| 20 | 80 | ▶ | sub new { | ||||||||||||||||
|
Subroutine
new: called CC=8 SCAR=31.5
Pod
undocumented
| |||||||||||||||||||
| 21 | 80 | my $class = shift; | |||||||||||||||||
| 22 | 80 | my %opts; | |||||||||||||||||
| 23 | |||||||||||||||||||
| 24 | 80 | ▶ | if (@_ == 1) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 25 | # XXX: Many of these forms are purposely undocumented and experimental | ||||||||||||||||||
| 26 | 0 | my $arg = pop; | |||||||||||||||||
| 27 | 0 | ▶ | if (blessed $arg) { | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 28 | 0 | ▶ | if ($arg->does('Parse::Path::Role::Path')) { return $arg->clone; } | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 29 | 0 | else { $opts{path} = "$arg"; } | |||||||||||||||||
| 30 | } | ||||||||||||||||||
| 31 | 0 | elsif (ref $arg eq 'ARRAY') { %opts = @$arg; } | |||||||||||||||||
| 32 | 0 | elsif (ref $arg eq 'HASH') { %opts = %$arg; } | |||||||||||||||||
| 33 | 0 | else { $opts{path} = $arg; } | |||||||||||||||||
| 34 | } | ||||||||||||||||||
| 35 | # NOTE: if @_ == 0, it gets passed to DZIL and fails with its own path attr error | ||||||||||||||||||
| 36 | 80 | else { %opts = @_; } | |||||||||||||||||
| 37 | |||||||||||||||||||
| 38 | 80 | ▶ | my $style = delete $opts{style} // 'DZIL'; | ||||||||||||||||
|
Condition100%2/2
delete $opts{"style"} // "DZIL"
MC/DC100%1/1
delete $opts{"style"} // "DZIL"
delete $opts{"style"}
Truth table100%2/2
A
A= delete $opts{"style"}
| |||||||||||||||||||
| 39 | 80 | ▶ | $style = "Parse::Path::$style" unless ($style =~ s/^\=//); # NOTE: kill two birds with one stone | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 40 | |||||||||||||||||||
| 41 | # Load+create the path | ||||||||||||||||||
| 42 | 80 | return use_module($style)->new(%opts); | |||||||||||||||||
| 43 | } | ||||||||||||||||||
| 44 | |||||||||||||||||||
| 45 | 7 | 42; | |||||||||||||||||
| 46 | |||||||||||||||||||
| 47 | __END__ | ||||||||||||||||||