| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
6
|
|
|
6
|
|
91730
|
use 5.008; # utf8 |
|
|
6
|
|
|
|
|
20
|
|
|
2
|
6
|
|
|
6
|
|
28
|
use strict; |
|
|
6
|
|
|
|
|
9
|
|
|
|
6
|
|
|
|
|
134
|
|
|
3
|
6
|
|
|
6
|
|
24
|
use warnings; |
|
|
6
|
|
|
|
|
7
|
|
|
|
6
|
|
|
|
|
452
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Dist::Zilla::Util::PluginLoader; |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.001003'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: Inflate a Legal Dist::Zilla Plugin from basic parts |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY |
|
12
|
|
|
|
|
|
|
|
|
13
|
6
|
|
|
6
|
|
26
|
use Carp qw( croak ); |
|
|
6
|
|
|
|
|
6
|
|
|
|
6
|
|
|
|
|
411
|
|
|
14
|
6
|
|
|
6
|
|
917
|
use Moose qw( has ); |
|
|
6
|
|
|
|
|
622344
|
|
|
|
6
|
|
|
|
|
45
|
|
|
15
|
6
|
|
|
6
|
|
32026
|
use Dist::Zilla::Util; |
|
|
6
|
|
|
|
|
46722
|
|
|
|
6
|
|
|
|
|
382
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has sequence => ( is => ro =>, required => 1 ); |
|
18
|
|
|
|
|
|
|
has assembler => ( is => ro =>, lazy_build => 1 ); |
|
19
|
|
|
|
|
|
|
has section_class => ( is => ro =>, lazy_build => 1 ); |
|
20
|
|
|
|
|
|
|
|
|
21
|
6
|
|
|
6
|
|
43
|
no Moose; |
|
|
6
|
|
|
|
|
9
|
|
|
|
6
|
|
|
|
|
38
|
|
|
22
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _build_assembler { |
|
25
|
13
|
|
|
13
|
|
19
|
my ($self) = @_; |
|
26
|
13
|
|
|
|
|
557
|
return $self->sequence->assembler; |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub _build_section_class { |
|
30
|
13
|
|
|
13
|
|
16
|
my ($self) = @_; |
|
31
|
13
|
|
|
|
|
395
|
return $self->assembler->section_class; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub _split_ini_token { |
|
35
|
4
|
|
|
4
|
|
5
|
my ( undef, $token ) = @_; |
|
36
|
4
|
|
|
|
|
24
|
my ( $key, $value ) = $token =~ /\A\s*([^=]+?)\s*=\s*(.+?)\s*\z/msx; |
|
37
|
4
|
|
|
|
|
15
|
return ( $key, $value ); |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub _check_array { |
|
41
|
17
|
|
|
17
|
|
22
|
my ( undef, $array ) = @_; |
|
42
|
17
|
50
|
|
|
|
42
|
croak 'Attributes must be an arrayref' unless 'ARRAY' eq ref $array; |
|
43
|
17
|
|
|
|
|
17
|
for ( @{$array} ) { |
|
|
17
|
|
|
|
|
26
|
|
|
44
|
24
|
50
|
|
|
|
35
|
croak 'Attributes ArrayRef must contain no refs' if ref; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
17
|
|
|
|
|
55
|
return $array; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub _auto_attrs { |
|
50
|
24
|
|
|
24
|
|
40
|
my $nargs = ( my ( $self, $package, $name, $attrs ) = @_ ); |
|
51
|
|
|
|
|
|
|
|
|
52
|
24
|
50
|
|
|
|
56
|
croak 'Not enough arguments to load()' if $nargs < 2; |
|
53
|
|
|
|
|
|
|
|
|
54
|
24
|
50
|
|
|
|
36
|
croak 'Argument <package> may not be a ref' if ref $package; |
|
55
|
|
|
|
|
|
|
|
|
56
|
24
|
100
|
|
|
|
38
|
if ( 2 == $nargs ) { |
|
57
|
1
|
|
|
|
|
3
|
return ( $package, $package, [] ); |
|
58
|
|
|
|
|
|
|
} |
|
59
|
23
|
100
|
|
|
|
40
|
if ( 3 == $nargs ) { |
|
60
|
7
|
100
|
|
|
|
15
|
if ( 'ARRAY' eq ref $name ) { |
|
61
|
1
|
|
|
|
|
3
|
return ( $package, $package, $self->_check_array($name) ); |
|
62
|
|
|
|
|
|
|
} |
|
63
|
6
|
|
|
|
|
16
|
return ( $package, $name, [] ); |
|
64
|
|
|
|
|
|
|
} |
|
65
|
16
|
50
|
|
|
|
62
|
if ( 4 == $nargs ) { |
|
66
|
16
|
100
|
|
|
|
29
|
if ( not defined $name ) { |
|
67
|
1
|
|
|
|
|
3
|
return ( $package, $package, $self->_check_array($attrs) ); |
|
68
|
|
|
|
|
|
|
} |
|
69
|
15
|
50
|
|
|
|
26
|
if ( ref $name ) { |
|
70
|
0
|
|
|
|
|
0
|
croak "Illegal value $name for <name>"; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
15
|
|
|
|
|
36
|
return ( $package, $name, $self->_check_array($attrs) ); |
|
73
|
|
|
|
|
|
|
} |
|
74
|
0
|
|
|
|
|
0
|
croak 'Too many arguments to load()'; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub load { |
|
78
|
17
|
|
|
17
|
1
|
106
|
my ( $self, @args ) = @_; |
|
79
|
17
|
|
|
|
|
38
|
my ( $package, $name, $attrs ) = $self->_auto_attrs(@args); |
|
80
|
|
|
|
|
|
|
|
|
81
|
17
|
50
|
|
|
|
21
|
croak 'Not an even number of attribute values, should be a key => value sequence.' if ( scalar @{$attrs} % 2 ) != 0; |
|
|
17
|
|
|
|
|
41
|
|
|
82
|
|
|
|
|
|
|
|
|
83
|
17
|
|
|
|
|
550
|
my $child_section = $self->section_class->new( |
|
84
|
|
|
|
|
|
|
name => $name, |
|
85
|
|
|
|
|
|
|
package => Dist::Zilla::Util->expand_config_package_name($package), |
|
86
|
|
|
|
|
|
|
); |
|
87
|
17
|
|
|
|
|
8043
|
my @xattrs = @{$attrs}; |
|
|
17
|
|
|
|
|
36
|
|
|
88
|
17
|
|
|
|
|
48
|
while (@xattrs) { |
|
89
|
10
|
|
|
|
|
673
|
my ( $key, $value ) = splice @xattrs, 0, 2, (); |
|
90
|
10
|
|
|
|
|
24
|
$child_section->add_value( $key, $value ); |
|
91
|
|
|
|
|
|
|
} |
|
92
|
17
|
|
|
|
|
1003
|
$self->sequence->add_section($child_section); |
|
93
|
17
|
50
|
|
|
|
5075
|
$child_section->finalize unless $child_section->is_finalized; |
|
94
|
17
|
|
|
|
|
19070
|
return; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub load_ini { |
|
98
|
7
|
|
|
7
|
1
|
20
|
my ( $self, @args ) = @_; |
|
99
|
7
|
|
|
|
|
23
|
my ( $package, $name, $attrs ) = $self->_auto_attrs(@args); |
|
100
|
7
|
|
|
|
|
11
|
return $self->load( $package, $name, [ map { $self->_split_ini_token($_) } @{$attrs} ] ); |
|
|
4
|
|
|
|
|
13
|
|
|
|
7
|
|
|
|
|
22
|
|
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
__END__ |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=pod |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=encoding UTF-8 |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 NAME |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Dist::Zilla::Util::PluginLoader - Inflate a Legal Dist::Zilla Plugin from basic parts |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 VERSION |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
version 0.001003 |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
use Dist::Zilla::Util::PluginLoader; |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
my $loader = Dist::Zilla::Util::PluginLoader->new( sequence => $sequence ); |
|
125
|
|
|
|
|
|
|
$loader->load( $plugin, $name, [ key => value , key => value ]); |
|
126
|
|
|
|
|
|
|
$loader->load_ini( $plugin, $name, [ 'key = value', 'key = value' ] ); |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 METHODS |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head2 C<load> |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Load a Dist::Zilla plugin meeting specification. |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Signatures: |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
void load( $self, $plugin ) |
|
137
|
|
|
|
|
|
|
void load( $self, $plugin, \@args ); |
|
138
|
|
|
|
|
|
|
void load( $self, $plugin, $name ); |
|
139
|
|
|
|
|
|
|
void load( $self, $plugin, $name, \@args ); |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
$plugin is Str ( Dist::Zilla Plugin ) |
|
142
|
|
|
|
|
|
|
$name is Str ( Dist::Zilla Section Name ) |
|
143
|
|
|
|
|
|
|
@args is ArrayRef |
|
144
|
|
|
|
|
|
|
num items == even |
|
145
|
|
|
|
|
|
|
key => value pairs of scalars. |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Constructs an instance of C<$plugin>, using C<$name> where possible, |
|
148
|
|
|
|
|
|
|
and uses C<@args> to populate the C<MVP> properties for that C<$plugin>, |
|
149
|
|
|
|
|
|
|
and then injects it to the C<< ->sequence >> passed earlier. |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head2 C<load_ini> |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Load a Dist::Zilla plugin meeting specification with unparsed |
|
154
|
|
|
|
|
|
|
C<INI> C<key = value> strings. |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Signatures: |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
void load( $self, $plugin ) |
|
159
|
|
|
|
|
|
|
void load( $self, $plugin, \@args ); |
|
160
|
|
|
|
|
|
|
void load( $self, $plugin, $name ); |
|
161
|
|
|
|
|
|
|
void load( $self, $plugin, $name, \@args ); |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
$plugin is Str ( Dist::Zilla Plugin ) |
|
164
|
|
|
|
|
|
|
$name is Str ( Dist::Zilla Section Name ) |
|
165
|
|
|
|
|
|
|
@args is ArrayRef of Str |
|
166
|
|
|
|
|
|
|
each Str is 'key = value' |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Constructs an instance of C<$plugin>, using C<$name> where possible, |
|
169
|
|
|
|
|
|
|
and parses and uses C<@args> to populate the C<MVP> properties for that C<$plugin>, |
|
170
|
|
|
|
|
|
|
and then injects it to the C<< ->sequence >> passed earlier. |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head2 C<sequence> |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
A C<Config::MVP::Sequence> object. |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
The easiest way to get one of those is: |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
around plugin_from_config { |
|
181
|
|
|
|
|
|
|
my ($orig,$self,$name,$arg, $section ) = @_; |
|
182
|
|
|
|
|
|
|
^^^^^^^^ |
|
183
|
|
|
|
|
|
|
} |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head2 C<assembler> |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
A C<Config::MVP::Assembler> |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
Defaults to C<< sequence->assembler >> |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head2 C<section_class> |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
Defaults to C<< assembler->section_class >> |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=head1 AUTHOR |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
Kent Fredric <kentnl@cpan.org> |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Kent Fredric <kentfredric@gmail.com>. |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
204
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=cut |