line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use Catmandu::Sane; |
3
|
120
|
|
|
120
|
|
778
|
|
|
120
|
|
|
|
|
217
|
|
|
120
|
|
|
|
|
659
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.2018'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Catmandu::Util qw(is_value is_string require_package); |
7
|
120
|
|
|
120
|
|
1096
|
use namespace::clean; |
|
120
|
|
|
|
|
264
|
|
|
120
|
|
|
|
|
6232
|
|
8
|
120
|
|
|
120
|
|
679
|
use Exporter qw(import); |
|
120
|
|
|
|
|
252
|
|
|
120
|
|
|
|
|
679
|
|
9
|
120
|
|
|
120
|
|
29804
|
|
|
120
|
|
|
|
|
230
|
|
|
120
|
|
|
|
|
30618
|
|
10
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
11
|
|
|
|
|
|
|
looks_like_path |
12
|
|
|
|
|
|
|
as_path |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our %EXPORT_TAGS = (all => \@EXPORT_OK,); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my ($path) = @_; |
18
|
|
|
|
|
|
|
is_string($path) && $path =~ /^\$[\.\/]/ ? 1 : 0; |
19
|
4
|
|
|
4
|
1
|
9
|
} |
20
|
4
|
100
|
66
|
|
|
29
|
|
21
|
|
|
|
|
|
|
my ($path, $path_type) = @_; |
22
|
|
|
|
|
|
|
if (is_value($path)) { |
23
|
|
|
|
|
|
|
$path_type //= 'simple'; |
24
|
589
|
|
|
589
|
1
|
1342
|
state $class_cache = {}; |
25
|
589
|
50
|
|
|
|
2169
|
my $class = $class_cache->{$path_type} |
26
|
589
|
|
50
|
|
|
2803
|
||= require_package($path_type, 'Catmandu::Path'); |
27
|
589
|
|
|
|
|
895
|
$class->new(path => $path); |
28
|
589
|
|
66
|
|
|
2259
|
} |
29
|
|
|
|
|
|
|
else { |
30
|
589
|
|
|
|
|
8211
|
$path; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} |
33
|
0
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=pod |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 NAME |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Catmandu::Util::Path - Path related utility functions |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 FUNCTIONS |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=over 4 |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=item looks_like_path($str) |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Returns 1 if the given string is a path, 0 otherwise. Only recognizes |
50
|
|
|
|
|
|
|
L<Catmandu::Path::simple> paths prefixed with a dollar sign at the moment. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
looks_like_path("$.foo.bar.$append") |
53
|
|
|
|
|
|
|
# => 1 |
54
|
|
|
|
|
|
|
looks_like_path("waffles") |
55
|
|
|
|
|
|
|
# => 0 |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=item as_path($str, $type) |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Helper function that returns a L<Catmandu::Path> instance for the given path |
60
|
|
|
|
|
|
|
string. The optional C<$type> argument gives preliminary support for |
61
|
|
|
|
|
|
|
alternative path implementations and defaults to 'simple'. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
as_path("$.foo.bar.$append") |
64
|
|
|
|
|
|
|
# is equivalent to |
65
|
|
|
|
|
|
|
Catmandu::Path::simple->new(path => "$.foo.bar.$append"); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=back |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=cut |