Catmandu/Util/Path.pm

filter: Statementstmt 96.0% 24 / 25 Branchbran 75.0% 3 / 4 Conditioncond 62.5% 5 / 8 MC/DCmcdc 20.0% 1 / 5 Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 82.0% 41 / 50 CC 6 SCAR 10.2
CC
6
Cov
86%
as_path
4.4
looks_like_path
3.0
BEGIN
1.0
CRAP 2.8
« Catmandu/Cmd/config.pm ↑ Summary Catmandu/Fix/assoc.pm »
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
BranchTrueFalseTotal
is_string($path) && $path =~ m[^\$[\./]] ? : 3 1 4
Condition66%2/3
is_string($path) and $path =~ m[^\$[\./]]
!ll&&!rl&&r
013
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[^\$[\./]]
ABresult
0X0
100
111
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
BranchTrueFalseTotal
if (is_value($path)) { } 614 0 614
26 614 ▶ $path_type //= 'simple';
Condition50%1/2
$path_type //= "simple"
l!l
0614
MC/DC0%0/1
$path_type //= "simple"
$path_type
Truth table50%1/2
A
A= $path_type
Aresult
11
00
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")
l!l&&r!l&&!r
520940
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")
ABresult
1X1
011
000
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__
« Catmandu/Cmd/config.pm ↑ Summary Catmandu/Fix/assoc.pm »