line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# vim: set ts=2 sts=2 sw=2 expandtab smarttab: |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# This file is part of Dist-Zilla-Role-PluginBundle-PluginRemover |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# This software is copyright (c) 2011 by Randy Stauner. |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under |
8
|
|
|
|
|
|
|
# the same terms as the Perl 5 programming language system itself. |
9
|
|
|
|
|
|
|
# |
10
|
2
|
|
|
2
|
|
416960
|
use strict; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
63
|
|
11
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
105
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
package Dist::Zilla::Role::PluginBundle::PluginRemover; |
14
|
|
|
|
|
|
|
# git description: v0.104-1-g5f9ab18 |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:RWSTAUNER'; |
17
|
|
|
|
|
|
|
# ABSTRACT: Add '-remove' functionality to a bundle |
18
|
|
|
|
|
|
|
$Dist::Zilla::Role::PluginBundle::PluginRemover::VERSION = '0.105'; |
19
|
2
|
|
|
2
|
|
222
|
use Moose::Role; |
|
2
|
|
|
|
|
387142
|
|
|
2
|
|
|
|
|
14
|
|
20
|
2
|
|
|
2
|
|
9899
|
use Dist::Zilla::Util (); |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
587
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
requires 'bundle_config'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
4
|
|
|
4
|
1
|
13
|
sub plugin_remover_attribute { '-remove' }; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Stub an empty sub so we can use 'around'. |
28
|
|
|
|
|
|
|
# A consuming class can overwrite the empty sub |
29
|
|
|
|
|
|
|
# and the 'around' will modify that sub at composition time. |
30
|
|
|
|
0
|
0
|
|
sub mvp_multivalue_args { } |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
around mvp_multivalue_args => sub { |
33
|
|
|
|
|
|
|
my $orig = shift; |
34
|
|
|
|
|
|
|
my $self = shift; |
35
|
|
|
|
|
|
|
$self->plugin_remover_attribute, $self->$orig(@_) |
36
|
|
|
|
|
|
|
}; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub remove_plugins { |
40
|
8
|
|
|
8
|
1
|
2896
|
my ($self, $remove, @plugins) = @_; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# plugin specifications look like: |
43
|
|
|
|
|
|
|
# [ plugin_name, plugin_class, arguments ] |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# stolen 99% from @Filter (thanks rjbs!) |
46
|
8
|
|
|
|
|
69
|
require List::Util; |
47
|
8
|
|
|
|
|
34
|
for my $i (reverse 0 .. $#plugins) { |
48
|
|
|
|
|
|
|
splice @plugins, $i, 1 if List::Util::any(sub { |
49
|
28
|
100
|
|
28
|
|
230
|
$plugins[$i][0] eq $_ |
50
|
|
|
|
|
|
|
or |
51
|
|
|
|
|
|
|
$plugins[$i][1] eq Dist::Zilla::Util->expand_config_package_name($_) |
52
|
26
|
100
|
|
|
|
821
|
}, @$remove); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
8
|
|
|
|
|
324
|
return @plugins; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
around bundle_config => sub { |
59
|
|
|
|
|
|
|
my ($orig, $class, $section) = @_; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# is it better to delete this or allow the bundle to see it? |
62
|
|
|
|
|
|
|
my $remove = $section->{payload}->{ $class->plugin_remover_attribute }; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my @plugins = $orig->($class, $section); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
return @plugins unless $remove; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
return $class->remove_plugins($remove, @plugins); |
69
|
|
|
|
|
|
|
}; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
__END__ |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=pod |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=encoding UTF-8 |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=for :stopwords Randy Stauner ACKNOWLEDGEMENTS cpan testmatrix url annocpan anno bugtracker |
80
|
|
|
|
|
|
|
rt cpants kwalitee diff irc mailto metadata placeholders metacpan |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 NAME |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Dist::Zilla::Role::PluginBundle::PluginRemover - Add '-remove' functionality to a bundle |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 VERSION |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
version 0.105 |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 SYNOPSIS |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# in Dist::Zilla::PluginBundle::MyBundle |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
with ( |
95
|
|
|
|
|
|
|
'Dist::Zilla::Role::PluginBundle', # or PluginBundle::Easy |
96
|
|
|
|
|
|
|
'Dist::Zilla::Role::PluginBundle::PluginRemover' |
97
|
|
|
|
|
|
|
); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# PluginRemover should probably be last |
100
|
|
|
|
|
|
|
# (unless you're doing something more complex) |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 DESCRIPTION |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This role enables your L<Dist::Zilla> Plugin Bundle |
105
|
|
|
|
|
|
|
to automatically remove any plugins specified |
106
|
|
|
|
|
|
|
by the C<-remove> attribute |
107
|
|
|
|
|
|
|
(like L<@Filter|Dist::Zilla::PluginBundle::Filter> does): |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
[@MyBundle] |
110
|
|
|
|
|
|
|
-remove = PluginIDontWant |
111
|
|
|
|
|
|
|
-remove = OtherDumbPlugin |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
If you want to use an attribute named C<-remove> for your own bundle |
114
|
|
|
|
|
|
|
you can override the C<plugin_remover_attribute> sub |
115
|
|
|
|
|
|
|
to define a different attribute name: |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# in your bundle package |
118
|
|
|
|
|
|
|
sub plugin_remover_attribute { 'scurvy_cur' } |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
This role adds a method modifier to C<bundle_config>, |
121
|
|
|
|
|
|
|
which is the method that the root C<PluginBundle> role requires, |
122
|
|
|
|
|
|
|
and that C<PluginBundle::Easy> wraps. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 METHODS |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head2 plugin_remover_attribute |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Returns the name of the attribute |
129
|
|
|
|
|
|
|
containing the array ref of plugins to remove. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Defaults to C<-remove>. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head2 remove_plugins |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
$class->remove_plugins(\@to_remove, @plugins); |
136
|
|
|
|
|
|
|
$class->remove_plugins(['Foo'], [Foo => 'DZP::Foo'], [Bar => 'DZP::Bar']); |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Takes an arrayref of plugin names to remove |
139
|
|
|
|
|
|
|
(like what will be in the config payload for C<-remove>), |
140
|
|
|
|
|
|
|
removes them from the list of plugins passed, |
141
|
|
|
|
|
|
|
and returns the remaining plugins. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
This is used by the C<bundle_config> modifier |
144
|
|
|
|
|
|
|
but is defined separately in case you would like |
145
|
|
|
|
|
|
|
to use the functionality without the voodoo that occurs |
146
|
|
|
|
|
|
|
when consuming this role. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
The plugin name to match against all plugins can be given as either the plugin |
149
|
|
|
|
|
|
|
moniker (like you might provide in your config file, expanded via |
150
|
|
|
|
|
|
|
L<Dist::Zilla::Util/expand_config>), or the unique plugin name used to |
151
|
|
|
|
|
|
|
differentiate multiple plugins of the same type. For example, in this |
152
|
|
|
|
|
|
|
configuration: |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
[Foo::Bar / plugin 1] |
155
|
|
|
|
|
|
|
[Foo::Bar / plugin 2] |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
passing C<'Foo::Bar'> to C<remove_plugins> will remove both these plugins from |
158
|
|
|
|
|
|
|
the configuration, but only the first is removed when passing C<'plugin 1'>. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=for Pod::Coverage mvp_multivalue_args |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 SUPPORT |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head2 Perldoc |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
perldoc Dist::Zilla::Role::PluginBundle::PluginRemover |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head2 Websites |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
The following websites have more information about this module, and may be of help to you. As always, |
173
|
|
|
|
|
|
|
in addition to those websites please use your favorite search engine to discover more resources. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=over 4 |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=item * |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
MetaCPAN |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
A modern, open-source CPAN search engine, useful to view POD in HTML format. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
L<http://metacpan.org/release/Dist-Zilla-Role-PluginBundle-PluginRemover> |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=back |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head2 Bugs / Feature Requests |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
Please report any bugs or feature requests by email to C<bug-dist-zilla-role-pluginbundle-pluginremover at rt.cpan.org>, or through |
190
|
|
|
|
|
|
|
the web interface at L<https://rt.cpan.org/Public/Bug/Report.html?Queue=Dist-Zilla-Role-PluginBundle-PluginRemover>. You will be automatically notified of any |
191
|
|
|
|
|
|
|
progress on the request by the system. |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head2 Source Code |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
L<https://github.com/rwstauner/Dist-Zilla-Role-PluginBundle-PluginRemover> |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
git clone https://github.com/rwstauner/Dist-Zilla-Role-PluginBundle-PluginRemover.git |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=head1 AUTHOR |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
Randy Stauner <rwstauner@cpan.org> |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=head1 CONTRIBUTOR |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=for stopwords Karen Etheridge |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
Karen Etheridge <ether@cpan.org> |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
This software is copyright (c) 2011 by Randy Stauner. |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
215
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=cut |