line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Parse::Path::DZIL; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.92'; # VERSION |
4
|
|
|
|
|
|
|
# ABSTRACT: "dist.ini-style".paths.for.DZIL[0] |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
############################################################################# |
7
|
|
|
|
|
|
|
# Modules |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
11278
|
use Moo; |
|
2
|
|
|
|
|
25306
|
|
|
2
|
|
|
|
|
17
|
|
10
|
2
|
|
|
2
|
|
4700
|
use sanity; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
20
|
|
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
924309
|
use String::Escape; |
|
2
|
|
|
|
|
28291
|
|
|
2
|
|
|
|
|
210
|
|
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
|
30
|
use namespace::clean; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
26
|
|
15
|
2
|
|
|
2
|
|
653
|
no warnings 'uninitialized'; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
1700
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
############################################################################# |
18
|
|
|
|
|
|
|
# Required Methods |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
with 'Parse::Path::Role::Path'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub _build_blueprint { { |
23
|
|
|
|
|
|
|
hash_step_regexp => qr/ |
24
|
|
|
|
|
|
|
# Standard character (or a zero-length with a delimiter) |
25
|
|
|
|
|
|
|
(?<key>\w+|(?=\.))| |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Quoted key |
28
|
|
|
|
|
|
|
(?<quote>['"])(?<key> (?: |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# The (?!) is a fancy way of saying ([^\"\\]*) with a variable quote character |
31
|
|
|
|
|
|
|
(?>(?: (?! \\|\g{quote}). )*) | # Most stuff (no backtracking) |
32
|
|
|
|
|
|
|
\\ \g{quote} | # Escaped quotes |
33
|
|
|
|
|
|
|
\\ (?! \g{quote}) # Any other escaped character |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
)* )\g{quote}| |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Zero-length step (with a single blank key) |
38
|
|
|
|
|
|
|
(?<key>^$) |
39
|
|
|
|
|
|
|
/x, |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
array_step_regexp => qr/\[(?<key>\d{1,5})\]/, |
42
|
|
|
|
|
|
|
delimiter_regexp => qr/(?:\.|(?=\[))/, |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
unescape_translation => [ |
45
|
|
|
|
|
|
|
[qr/\"/ => \&String::Escape::unbackslash], |
46
|
4
|
|
|
4
|
|
9
|
[qr/\'/ => sub { my $str = $_[0]; $str =~ s|\\([\'\\])|$1|g; $str; }], |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
14
|
|
47
|
|
|
|
|
|
|
], |
48
|
|
|
|
|
|
|
pos_translation => [ |
49
|
|
|
|
|
|
|
[qr/.?/, 'X+1'], |
50
|
|
|
|
|
|
|
], |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
delimiter_placement => { |
53
|
|
|
|
|
|
|
HH => '.', |
54
|
|
|
|
|
|
|
AH => '.', |
55
|
|
|
|
|
|
|
}, |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
array_key_sprintf => '[%u]', |
58
|
|
|
|
|
|
|
hash_key_stringification => [ |
59
|
|
|
|
|
|
|
[qr/[\x00-\x1f\']/, |
60
|
|
|
|
|
|
|
'"%s"' => \&String::Escape::backslash], |
61
|
6
|
|
|
6
|
|
9
|
[qr/\W|^$/, "'%s'" => sub { my $str = $_[0]; $str =~ s|([\'\\])|\\$1|g; $str; }], |
|
6
|
|
|
19
|
|
8
|
|
|
6
|
|
|
|
|
16
|
|
|
19
|
|
|
|
|
3201
|
|
62
|
|
|
|
|
|
|
[qr/.?/, '%s'], |
63
|
|
|
|
|
|
|
], |
64
|
|
|
|
|
|
|
} } |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
42; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=pod |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=encoding utf-8 |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 NAME |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Parse::Path::DZIL - "dist.ini-style".paths.for.DZIL[0] |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 SYNOPSIS |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
use v5.10; |
81
|
|
|
|
|
|
|
use Parse::Path; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
my $path = Parse::Path->new( |
84
|
|
|
|
|
|
|
path => 'gophers[0].food.count', |
85
|
|
|
|
|
|
|
style => 'DZIL', |
86
|
|
|
|
|
|
|
); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
say $path->as_string; |
89
|
|
|
|
|
|
|
$path->push($path, '[2]'); |
90
|
|
|
|
|
|
|
say $path->as_string; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 DESCRIPTION |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
This path style is used for advanced L<Dist::Zilla> INI parsing. It's the reason why this distribution (and related modules) were |
95
|
|
|
|
|
|
|
created. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Support is available for both hash and array steps, including quoted hash steps. Some examples: |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
gophers[0].food.type |
100
|
|
|
|
|
|
|
"Drink more milk".[3][0][0]."and enjoy it!" |
101
|
|
|
|
|
|
|
'foo bar baz'[0]."\"Escaping works, too\"" |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
DZIL paths do not have relativity. They are all relative. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 AVAILABILITY |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
The project homepage is L<https://github.com/SineSwiper/Parse-Path/wiki>. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
The latest version of this module is available from the Comprehensive Perl |
110
|
|
|
|
|
|
|
Archive Network (CPAN). Visit L<http://www.perl.com/CPAN/> to find a CPAN |
111
|
|
|
|
|
|
|
site near you, or see L<https://metacpan.org/module/Parse::Path/>. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 AUTHOR |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Brendan Byrd <bbyrd@cpan.org> |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
This software is Copyright (c) 2013 by Brendan Byrd. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
This is free software, licensed under: |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |