| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Data::Object::Name; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
24841
|
use 5.014; |
|
|
1
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
21
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
23
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use routines; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
6
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '2.01'; # VERSION |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# BUILD |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $sep = qr/'|__|::|\\|\//; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# METHODS |
|
16
|
|
|
|
|
|
|
|
|
17
|
2
|
|
|
2
|
1
|
9
|
method file() { |
|
|
2
|
|
|
|
|
4
|
|
|
18
|
2
|
50
|
|
|
|
6
|
return $$self if $self->lookslike_a_file; |
|
19
|
|
|
|
|
|
|
|
|
20
|
2
|
|
|
|
|
9
|
my $string = $self->package; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
return join '__', map { |
|
23
|
2
|
|
|
|
|
10
|
join '_', map {lc} map {split /_/} grep {length} |
|
|
4
|
|
|
|
|
17
|
|
|
|
6
|
|
|
|
|
28
|
|
|
|
6
|
|
|
|
|
12
|
|
|
|
12
|
|
|
|
|
19
|
|
|
24
|
|
|
|
|
|
|
split /([A-Z]{1}[^A-Z]*)/ |
|
25
|
|
|
|
|
|
|
} split /$sep/, $string; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
1
|
|
|
1
|
1
|
7
|
method format($method, $format) { |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
2
|
|
|
29
|
1
|
|
|
|
|
5
|
my $string = $self->$method; |
|
30
|
|
|
|
|
|
|
|
|
31
|
1
|
|
50
|
|
|
16
|
return sprintf($format || '%s', $string); |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
1
|
|
|
1
|
1
|
6
|
method label() { |
|
|
1
|
|
|
|
|
2
|
|
|
35
|
1
|
50
|
|
|
|
5
|
return $$self if $self->lookslike_a_label; |
|
36
|
|
|
|
|
|
|
|
|
37
|
1
|
|
|
|
|
6
|
return join '_', split /$sep/, $self->package; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
3
|
|
|
3
|
1
|
8
|
method lookslike_a_file() { |
|
|
3
|
|
|
|
|
7
|
|
|
41
|
3
|
|
|
|
|
6
|
my $string = $$self; |
|
42
|
|
|
|
|
|
|
|
|
43
|
3
|
|
|
|
|
23
|
return $string =~ /^[a-z](?:\w*[a-z])?$/; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
2
|
|
|
2
|
1
|
7
|
method lookslike_a_label() { |
|
|
2
|
|
|
|
|
3
|
|
|
47
|
2
|
|
|
|
|
5
|
my $string = $$self; |
|
48
|
|
|
|
|
|
|
|
|
49
|
2
|
|
|
|
|
20
|
return $string =~ /^[A-Z](?:\w*[a-zA-Z0-9])?$/; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
7
|
|
|
7
|
1
|
16
|
method lookslike_a_package() { |
|
|
7
|
|
|
|
|
9
|
|
|
53
|
7
|
|
|
|
|
16
|
my $string = $$self; |
|
54
|
|
|
|
|
|
|
|
|
55
|
7
|
|
|
|
|
71
|
return $string =~ /^[A-Z](?:(?:\w|::)*[a-zA-Z0-9])?$/; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
2
|
|
|
2
|
1
|
8
|
method lookslike_a_path() { |
|
|
2
|
|
|
|
|
4
|
|
|
59
|
2
|
|
|
|
|
4
|
my $string = $$self; |
|
60
|
|
|
|
|
|
|
|
|
61
|
2
|
|
|
|
|
33
|
return $string =~ /^[A-Z](?:(?:\w|\\|\/|[\:\.]{1}[a-zA-Z0-9])*[a-zA-Z0-9])?$/; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
13
|
100
|
|
13
|
1
|
382345
|
method new($class: $name = '') { |
|
|
13
|
|
|
|
|
59
|
|
|
|
13
|
|
|
|
|
20
|
|
|
65
|
|
|
|
|
|
|
|
|
66
|
13
|
|
|
|
|
228
|
return bless \$name, $class; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
6
|
|
|
6
|
1
|
20
|
method package() { |
|
|
6
|
|
|
|
|
12
|
|
|
70
|
6
|
100
|
|
|
|
15
|
return $$self if $self->lookslike_a_package; |
|
71
|
|
|
|
|
|
|
|
|
72
|
4
|
|
|
|
|
22
|
my $string = $$self; |
|
73
|
|
|
|
|
|
|
|
|
74
|
4
|
50
|
|
|
|
30
|
if ($string !~ $sep) { |
|
75
|
0
|
|
|
|
|
0
|
return join '', map {ucfirst} split /[^a-zA-Z0-9]/, $string; |
|
|
0
|
|
|
|
|
0
|
|
|
76
|
|
|
|
|
|
|
} else { |
|
77
|
|
|
|
|
|
|
return join '::', map { |
|
78
|
4
|
|
|
|
|
34
|
join '', map {ucfirst} split /[^a-zA-Z0-9]/ |
|
|
8
|
|
|
|
|
22
|
|
|
|
8
|
|
|
|
|
61
|
|
|
79
|
|
|
|
|
|
|
} split /$sep/, $string; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
1
|
|
|
1
|
1
|
6
|
method path() { |
|
|
1
|
|
|
|
|
3
|
|
|
84
|
1
|
50
|
|
|
|
4
|
return $$self if $self->lookslike_a_path; |
|
85
|
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
return join '/', split /$sep/, $self->package; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=encoding utf8 |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 NAME |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Data::Object::Name |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 ABSTRACT |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Name Class for Perl 5 |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
use Data::Object::Name; |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
my $name = Data::Object::Name->new('FooBar/Baz'); |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=cut |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
This package provides methods for converting "name" strings. |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=cut |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 METHODS |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
This package implements the following methods: |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=cut |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head2 file |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
file() : Str |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
The file method returns a file representation of the name. |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=over 4 |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item file example #1 |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
# given: synopsis |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
my $file = $name->file; # foo_bar__baz |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=back |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=cut |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head2 format |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
format(Str $method, Str $format) : Str |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
The format method calls the specified method passing the result to the core |
|
148
|
|
|
|
|
|
|
L function with itself as an argument. |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=over 4 |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=item format example #1 |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
# given: synopsis |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
my $file = $name->format('file', '%s.t'); # foo_bar__baz.t |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=back |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=cut |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head2 label |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
label() : Str |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
The label method returns a label (or constant) representation of the name. |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=over 4 |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=item label example #1 |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
# given: synopsis |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
my $label = $name->label; # FooBar_Baz |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=back |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=cut |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head2 lookslike_a_file |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
lookslike_a_file() : Bool |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
The lookslike_a_file method returns truthy if its state resembles a filename. |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=over 4 |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=item lookslike_a_file example #1 |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
# given: synopsis |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
my $is_file = $name->lookslike_a_file; # falsey |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=back |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=cut |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head2 lookslike_a_label |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
lookslike_a_label() : Bool |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
The lookslike_a_label method returns truthy if its state resembles a label (or |
|
203
|
|
|
|
|
|
|
constant). |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=over 4 |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=item lookslike_a_label example #1 |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
# given: synopsis |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
my $is_label = $name->lookslike_a_label; # falsey |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=back |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=cut |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=head2 lookslike_a_package |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
lookslike_a_package() : Bool |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
The lookslike_a_package method returns truthy if its state resembles a package |
|
222
|
|
|
|
|
|
|
name. |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=over 4 |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=item lookslike_a_package example #1 |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
# given: synopsis |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
my $is_package = $name->lookslike_a_package; # falsey |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=back |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=cut |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=head2 lookslike_a_path |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
lookslike_a_path() : Bool |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
The lookslike_a_path method returns truthy if its state resembles a file path. |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=over 4 |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=item lookslike_a_path example #1 |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
# given: synopsis |
|
247
|
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
my $is_path = $name->lookslike_a_path; # truthy |
|
249
|
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=back |
|
251
|
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=cut |
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=head2 new |
|
255
|
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
new(Str $arg) : Object |
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
The new method instantiates the class and returns an object. |
|
259
|
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=over 4 |
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=item new example #1 |
|
263
|
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
use Data::Object::Name; |
|
265
|
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
my $name = Data::Object::Name->new; |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=back |
|
269
|
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
=over 4 |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=item new example #2 |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
use Data::Object::Name; |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
my $name = Data::Object::Name->new('FooBar'); |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
=back |
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
=cut |
|
281
|
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=head2 package |
|
283
|
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
package() : Str |
|
285
|
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
The package method returns a package name representation of the name given. |
|
287
|
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
=over 4 |
|
289
|
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
=item package example #1 |
|
291
|
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
# given: synopsis |
|
293
|
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
my $package = $name->package; # FooBar::Baz |
|
295
|
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
=back |
|
297
|
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
=cut |
|
299
|
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
=head2 path |
|
301
|
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
path() : Str |
|
303
|
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
The path method returns a path representation of the name. |
|
305
|
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
=over 4 |
|
307
|
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
=item path example #1 |
|
309
|
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
# given: synopsis |
|
311
|
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
my $path = $name->path; # FooBar/Baz |
|
313
|
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
=back |
|
315
|
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
=cut |
|
317
|
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
=head1 AUTHOR |
|
319
|
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
Al Newkirk, C |
|
321
|
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
=head1 LICENSE |
|
323
|
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
Copyright (C) 2011-2019, Al Newkirk, et al. |
|
325
|
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under the terms |
|
327
|
|
|
|
|
|
|
of the The Apache License, Version 2.0, as elucidated in the L<"license |
|
328
|
|
|
|
|
|
|
file"|https://github.com/iamalnewkirk/data-object-name/blob/master/LICENSE>. |
|
329
|
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
=head1 PROJECT |
|
331
|
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
L |
|
333
|
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
L |
|
335
|
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
L |
|
337
|
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
L |
|
339
|
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
L |
|
341
|
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
L |
|
343
|
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
=cut |