line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
4
|
|
|
4
|
|
1856
|
use 5.006; |
|
4
|
|
|
|
|
10
|
|
2
|
4
|
|
|
4
|
|
17
|
use strict; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
75
|
|
3
|
4
|
|
|
4
|
|
13
|
use warnings; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
226
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Dist::Zilla::Util::RoleDB::Entry; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.004001'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: Extracted meta-data about a role |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY |
12
|
|
|
|
|
|
|
|
13
|
4
|
|
|
4
|
|
554
|
use Moo qw( has ); |
|
4
|
|
|
|
|
10722
|
|
|
4
|
|
|
|
|
17
|
|
14
|
4
|
|
|
4
|
|
1908
|
use Carp qw( croak ); |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
2233
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
## no critic (NamingConventions) |
17
|
|
|
|
|
|
|
my $is_Str = sub { 'SCALAR' eq ref \$_[0] or 'SCALAR' eq ref \( my $val = $_[0] ) }; |
18
|
|
|
|
|
|
|
my $is_ArrayRef = sub { |
19
|
|
|
|
|
|
|
return 'ARRAY' eq ref $_[0] unless $_[1]; |
20
|
|
|
|
|
|
|
return unless 'ARRAY' eq ref $_[0]; |
21
|
|
|
|
|
|
|
for ( @{ $_[0] } ) { |
22
|
|
|
|
|
|
|
return unless $_[1]->($_); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
1; |
25
|
|
|
|
|
|
|
}; |
26
|
|
|
|
|
|
|
my $is_Bool = sub { not defined $_[0] or q() eq $_[0] or '0' eq $_[0] or '1' eq $_[0] }; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
has name => ( |
43
|
|
|
|
|
|
|
isa => sub { $is_Str->( $_[0] ) or croak 'name must be a Str' }, |
44
|
|
|
|
|
|
|
is => ro =>, |
45
|
|
|
|
|
|
|
required => 1, |
46
|
|
|
|
|
|
|
documentation => q[The unprefixed version of the role name, ie: -Foo => DZR::Foo], |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
has full_name => ( |
58
|
|
|
|
|
|
|
isa => sub { $is_Str->( $_[0] ) or croak 'full_name must be a Str' }, |
59
|
|
|
|
|
|
|
is => ro =>, |
60
|
|
|
|
|
|
|
lazy => 1, |
61
|
|
|
|
|
|
|
builder => '_build_full_name', |
62
|
|
|
|
|
|
|
documentation => q[The fully qualified version of the role name], |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub _build_full_name { |
66
|
54
|
|
|
54
|
|
136468
|
my ($self) = @_; |
67
|
54
|
|
|
|
|
118
|
my $role_name = $self->name; |
68
|
54
|
50
|
|
|
|
212
|
return $role_name unless $role_name =~ /\A-/msx; |
69
|
54
|
|
|
|
|
174
|
$role_name =~ s{\A-}{Dist::Zilla::Role::}msx; |
70
|
54
|
|
|
|
|
994
|
return $role_name; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
has required_modules => ( |
108
|
|
|
|
|
|
|
isa => sub { $is_ArrayRef->( $_[0], $is_Str ) or croak 'required_modules must be an ArrayRef of Str' }, |
109
|
|
|
|
|
|
|
is => ro =>, |
110
|
|
|
|
|
|
|
lazy => 1, |
111
|
|
|
|
|
|
|
builder => '_build_required_modules', |
112
|
|
|
|
|
|
|
## no critic (ProhibitImplicitNewlines) |
113
|
|
|
|
|
|
|
documentation => <<'EOF', ); |
114
|
|
|
|
|
|
|
A list of things that must be manually require()d for the module to exist. |
115
|
|
|
|
|
|
|
Note: This should not be needed for anything, as its really only intended |
116
|
|
|
|
|
|
|
as a way to make hidden packages require()able. |
117
|
|
|
|
|
|
|
Usually, this will be exactly one item, and it will be the same as the modules name. |
118
|
|
|
|
|
|
|
EOF |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub _build_required_modules { |
121
|
0
|
|
|
0
|
|
0
|
my ($self) = @_; |
122
|
0
|
|
|
|
|
0
|
return [ $self->full_name ]; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
131
|
30
|
|
|
30
|
1
|
55
|
sub is_phase { return } |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
has description => ( |
142
|
|
|
|
|
|
|
isa => sub { $is_Str->( $_[0] ) or croak 'description must be a Str' }, |
143
|
|
|
|
|
|
|
is => ro =>, |
144
|
|
|
|
|
|
|
required => 1, |
145
|
|
|
|
|
|
|
documentation => q[A text description of the role. A copy of ABSTRACT would be fine], |
146
|
|
|
|
|
|
|
); |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
has deprecated => ( |
155
|
|
|
|
|
|
|
isa => sub { $is_Bool->( $_[0] ) or croak 'deprecated must be Boolean' }, |
156
|
|
|
|
|
|
|
is => ro =>, |
157
|
|
|
|
|
|
|
lazy => 1, |
158
|
|
|
|
|
|
|
builder => '_build_deprecated', |
159
|
|
|
|
|
|
|
documentation => q[Set this to 1 if this role is deprecated], |
160
|
|
|
|
|
|
|
); |
161
|
|
|
|
|
|
|
|
162
|
0
|
|
|
0
|
|
|
sub _build_deprecated { return } |
163
|
|
|
|
|
|
|
|
164
|
4
|
|
|
4
|
|
21
|
no Moo; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
16
|
|
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
sub require_module { |
176
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
177
|
0
|
|
|
|
|
|
require Module::Runtime; |
178
|
0
|
|
|
|
|
|
for my $module ( @{ $self->required_modules } ) { |
|
0
|
|
|
|
|
|
|
179
|
0
|
|
|
|
|
|
Module::Runtime::require_module($module); |
180
|
|
|
|
|
|
|
} |
181
|
0
|
|
|
|
|
|
return $self->full_name; |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
1; |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
__END__ |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=pod |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=encoding UTF-8 |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head1 NAME |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
Dist::Zilla::Util::RoleDB::Entry - Extracted meta-data about a role |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head1 VERSION |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
version 0.004001 |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=head1 SYNOPSIS |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
use Dist::Zilla::Util::RoleDB::Entry; |
203
|
|
|
|
|
|
|
my $entry = Dist::Zilla::Util::RoleDB::Entry->new( |
204
|
|
|
|
|
|
|
name => "-FileGatherer", |
205
|
|
|
|
|
|
|
description => "A thing that adds files to your dist" |
206
|
|
|
|
|
|
|
); |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=head1 METHODS |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=head2 is_phase |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
Returns false |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=head2 C<require_module> |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
Load the module itself. |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
Usually, this just amounts to requiring C<full_name>, but it might not be |
219
|
|
|
|
|
|
|
in the case somebody has manually modified C<required_modules> |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=head2 C<name> |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
Contains the short name for the role, in a form acceptable by C<Dist::Zilla>'s C<plugins_with> method. |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
e.g: |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
-FileGatherer |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
Because |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
zilla->plugins_with(-FileGatherer) |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=head2 C<full_name> |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
Contains the fully qualified version of the role. |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
For instance, when C<name> is C<-FileGatherer>, C<full_name> will be C<Dist::Zilla::Role::FileGatherer> |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=head2 C<required_modules> |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
This contains an C<ArrayRef> of Modules that are required if one ever intends to use the module in C<full_name>. |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
Note, that this is not intended to be really used. It only exists as a helper in the event one wishes to document |
246
|
|
|
|
|
|
|
a roles existence in a file other than one matching its name. |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
For example: |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
Foo.pm: |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
package Foo; |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
use Moose::Role; |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
package Bar; |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
use Moose::Role; |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
In such a scenario, one cannot get Bar without C<require Foo> |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
So here, |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
->new( name => 'Foo' ); # required_modules is automatically [Foo] |
265
|
|
|
|
|
|
|
->new( name => 'Bar', required_modules => ['Foo'] ); |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
Also, if a role has peculiar load order requirements ( like seen in Class::MOP ) that means |
268
|
|
|
|
|
|
|
certain other libraries must be C<require>'d before C<require>ing the module itself, this would be a convenient place to put such information. |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
This mechanism is mostly to support C<< $entry->require_module >> |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=head2 C<description> |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
Contains a textual description of the Role. |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
Usually, a copy of the Roles "ABSTRACT" will do the trick. |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
=head2 C<deprecated> |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
If a role is deprecated, setting this may be useful. |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=head1 AUTHOR |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
Kent Fredric <kentnl@cpan.org> |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Kent Fredric <kentfredric@gmail.com>. |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
291
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
=cut |