line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
11526
|
use 5.006; |
|
2
|
|
|
|
|
4
|
|
2
|
2
|
|
|
2
|
|
7
|
use strict; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
31
|
|
3
|
2
|
|
|
2
|
|
5
|
use warnings; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
95
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Dist::Zilla::Role::BundleDeps; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.002003'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: Automatically add all plugins in a bundle as dependencies |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
2
|
|
|
2
|
|
408
|
use Moose::Role qw( around ); |
|
2
|
|
|
|
|
304731
|
|
|
2
|
|
|
|
|
10
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub _bundle_alias { |
27
|
1
|
|
|
1
|
|
1
|
my ($self) = @_; |
28
|
1
|
|
|
|
|
4
|
my $ns = $self->meta->name; |
29
|
1
|
50
|
|
|
|
41
|
if ( $ns =~ /\ADist::Zilla::PluginBundle::(.*\z)/msx ) { |
30
|
0
|
|
|
|
|
0
|
return q[@] . $1; |
31
|
|
|
|
|
|
|
} |
32
|
1
|
|
|
|
|
3
|
return $ns; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _extract_plugin_prereqs { |
36
|
1
|
|
|
1
|
|
3
|
my ( undef, @config ) = @_; |
37
|
1
|
|
|
|
|
881
|
require CPAN::Meta::Requirements; |
38
|
1
|
|
|
|
|
5100
|
my $reqs = CPAN::Meta::Requirements->new(); |
39
|
1
|
|
|
|
|
11
|
for my $item (@config) { |
40
|
2
|
|
|
|
|
116
|
my ( undef, $module, $conf ) = @{$item}; |
|
2
|
|
|
|
|
5
|
|
41
|
2
|
|
|
|
|
2
|
my $version = 0; |
42
|
2
|
100
|
|
|
|
7
|
$version = $conf->{':version'} if exists $conf->{':version'}; |
43
|
2
|
|
|
|
|
4
|
$reqs->add_string_requirement( $module, $version ); |
44
|
|
|
|
|
|
|
} |
45
|
1
|
|
|
|
|
37
|
return $reqs; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _create_prereq_plugin { |
49
|
1
|
|
|
1
|
|
1
|
my ( $self, $reqs, $config ) = @_; |
50
|
1
|
|
|
|
|
2
|
my $plugin_conf = { %{$config}, %{ $reqs->as_string_hash } }; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
3
|
|
51
|
1
|
|
|
|
|
23
|
my $prereq = []; |
52
|
1
|
|
|
|
|
1
|
push @{$prereq}, $self->_bundle_alias . '/::Role::BundleDeps'; |
|
1
|
|
|
|
|
3
|
|
53
|
1
|
|
|
|
|
3
|
push @{$prereq}, 'Dist::Zilla::Plugin::Prereqs'; |
|
1
|
|
|
|
|
1
|
|
54
|
1
|
|
|
|
|
1
|
push @{$prereq}, $plugin_conf; |
|
1
|
|
|
|
|
2
|
|
55
|
1
|
|
|
|
|
14
|
return $prereq; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub bundledeps_defaults { |
80
|
|
|
|
|
|
|
return { |
81
|
1
|
|
|
1
|
1
|
6
|
-phase => 'develop', |
82
|
|
|
|
|
|
|
-relationship => 'requires', |
83
|
|
|
|
|
|
|
}; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
around bundle_config => sub { |
87
|
|
|
|
|
|
|
my ( $orig, $self, $section, ) = @_; |
88
|
|
|
|
|
|
|
my $myconf = $self->bundledeps_defaults; |
89
|
|
|
|
|
|
|
for my $param (qw( phase relationship )) { |
90
|
|
|
|
|
|
|
my $field = 'bundledeps_' . $param; |
91
|
|
|
|
|
|
|
next unless exists $section->{payload}->{$field}; |
92
|
|
|
|
|
|
|
$myconf->{ q[-] . $param } = delete $section->{payload}->{$field}; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
my (@config) = $self->$orig($section); |
95
|
|
|
|
|
|
|
my $reqs = $self->_extract_plugin_prereqs(@config); |
96
|
|
|
|
|
|
|
return ( @config, $self->_create_prereq_plugin( $reqs => $myconf ) ); |
97
|
|
|
|
|
|
|
}; |
98
|
|
|
|
|
|
|
|
99
|
2
|
|
|
2
|
|
5823
|
no Moose::Role; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
8
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
__END__ |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=pod |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=encoding UTF-8 |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 NAME |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Dist::Zilla::Role::BundleDeps - Automatically add all plugins in a bundle as dependencies |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 VERSION |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
version 0.002003 |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 SYNOPSIS |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
package blahblahblah; |
120
|
|
|
|
|
|
|
use Moose; |
121
|
|
|
|
|
|
|
... |
122
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::PluginBundle'; |
123
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::BundleDeps'; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Dependencies appear now for all plugins returned. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 DESCRIPTION |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
This role attempts to solve the problem of communicating dependencies to META.* from bundles |
130
|
|
|
|
|
|
|
in a different way. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
My first attempt was L<< C<[Prereqs::Plugins]>|Dist::Zilla::Plugins::Prereqs::Plugins >>, which added |
133
|
|
|
|
|
|
|
all values that are seen in the C<dist.ini> to dependencies. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
However, that was inherently limited, as the C<:version> specifier |
136
|
|
|
|
|
|
|
is lost before the plugins appear on C<< $zilla->plugins >> |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
This Role however, can see any declarations of C<:version> your bundle advertises, |
139
|
|
|
|
|
|
|
by standing between your C<bundle_config> method and C<Dist::Zilla> |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 METHODS |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head2 C<bundledeps_defaults> |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
This method provides the C<HashRef> of defaults to use for the generated C<Prereqs> section. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Because this role is intended to advertise Plugin Bundle dependencies, and because those |
148
|
|
|
|
|
|
|
dependencies will be "develop" dependencies everywhere other than the bundle itself, |
149
|
|
|
|
|
|
|
our defaults are: |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
{ |
152
|
|
|
|
|
|
|
-phase => develop, |
153
|
|
|
|
|
|
|
-relationship => requires, |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
These can be overridden when consuming a bundle in C<dist.ini> |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
[@Author::MyBundle] |
159
|
|
|
|
|
|
|
bundledeps_phase = runtime |
160
|
|
|
|
|
|
|
bundledeps_relationship = requires |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=begin MetaPOD::JSON v1.1.0 |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
{ |
165
|
|
|
|
|
|
|
"namespace":"Dist::Zilla::Role::BundleDeps", |
166
|
|
|
|
|
|
|
"interface":"role" |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=end MetaPOD::JSON |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 LIMITATIONS |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
If you bundle plugins with your bundle, and use those plugins in the bundle, |
175
|
|
|
|
|
|
|
you'll risk a self-reference problem, which may be solved in a future release of Dist::Zilla. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
Until then, you'll need to possibly use L<< C<[RemovePrereqs]>|Dist::Zilla::Plugin::RemovePrereqs >> |
178
|
|
|
|
|
|
|
to trim self-references. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head1 SEE ALSO |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
L<< C<[BundleInspector]>|Dist::Zilla::Plugin::BundleInspector >> |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head1 AUTHOR |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
Kent Fredric <kentnl@cpan.org> |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
This software is copyright (c) 2016 by Kent Fredric <kentfredric@gmail.com>. |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
193
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=cut |