| 1 | package Catmandu::Util::Path; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 121 | ▶ | use Catmandu::Sane; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 121 | our $VERSION = '1.2025'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 121 | ▶ | use Catmandu::Util qw(is_value is_string require_package); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 121 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 121 | ▶ | use Exporter qw(import); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 121 | our @EXPORT_OK = qw( | |||||||||||||||||||||||||||
| 12 | looks_like_path | ||||||||||||||||||||||||||||
| 13 | as_path | ||||||||||||||||||||||||||||
| 14 | ); | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 121 | our %EXPORT_TAGS = (all => \@EXPORT_OK,); | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 4 | ▶ | sub looks_like_path { # TODO only recognizes Catmandu::Path::simple | ||||||||||||||||||||||||||
|
Subroutine
looks_like_path: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||
| 19 | 4 | my ($path) = @_; | |||||||||||||||||||||||||||
| 20 | 4 | ▶ | is_string($path) && $path =~ /^\$[\.\/]/ ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
is_string($path) and $path =~ m[^\$[\./]]
MC/DC50%1/2
is_string($path) and $path =~ m[^\$[\./]]
is_string($path)
$path =~ m[^\$[\./]]
Truth table66%2/3
A and B
A= is_string($path)B= $path =~ m[^\$[\./]]
| |||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 614 | ▶ | sub as_path { | ||||||||||||||||||||||||||
|
Subroutine
as_path: called CC=4 SCAR=14.8
Pod
documented
| |||||||||||||||||||||||||||||
| 24 | 614 | my ($path, $path_type) = @_; | |||||||||||||||||||||||||||
| 25 | 614 | ▶ | if (is_value($path)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | 614 | ▶ | $path_type //= 'simple'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$path_type //= "simple"
MC/DC0%0/1
$path_type //= "simple"
$path_type
Truth table50%1/2
A
A= $path_type
| |||||||||||||||||||||||||||||
| 27 | 614 | state $class_cache = {}; | |||||||||||||||||||||||||||
| 28 | 614 | ▶ | my $class = $class_cache->{$path_type} | ||||||||||||||||||||||||||
|
Condition66%2/3
$class_cache->{$path_type} ||= require_package($path_type, "Catmandu::Path")
MC/DC0%0/2
$class_cache->{$path_type} ||= require_package($path_type, "Catmandu::Path")
$class_cache->{$path_type}
require_package($path_type, "Catmandu::Path")
Truth table66%2/3
A ||= B
A= $class_cache->{$path_type}B= require_package($path_type, "Catmandu::Path")
| |||||||||||||||||||||||||||||
| 29 | ||= require_package($path_type, 'Catmandu::Path'); | ||||||||||||||||||||||||||||
| 30 | 614 | $class->new(path => $path); | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | else { | ||||||||||||||||||||||||||||
| 33 | 0 | $path; | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 121 | 1; | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | __END__ | ||||||||||||||||||||||||||||