line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
4
|
|
|
4
|
|
74905
|
use 5.008; # utf8 |
|
4
|
|
|
|
|
10
|
|
2
|
4
|
|
|
4
|
|
18
|
use strict; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
105
|
|
3
|
4
|
|
|
4
|
|
17
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
305
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Dist::Zilla::Role::PluginLoader; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.001003'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: A Plugin that can load others. |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY |
12
|
|
|
|
|
|
|
|
13
|
4
|
|
|
4
|
|
381
|
use Moose::Role qw( has around with requires ); |
|
4
|
|
|
|
|
379315
|
|
|
4
|
|
|
|
|
31
|
|
14
|
4
|
|
|
4
|
|
20119
|
use Dist::Zilla::Util::PluginLoader; |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
1079
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
requires 'load_plugins'; |
17
|
|
|
|
|
|
|
requires 'plugin_from_config'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
around plugin_from_config => sub { |
20
|
|
|
|
|
|
|
my ( $orig, $plugin_class, $name, $arg, $own_section ) = @_; |
21
|
|
|
|
|
|
|
my $own_object = $plugin_class->$orig( $name, $arg, $own_section ); |
22
|
|
|
|
|
|
|
my $loader = Dist::Zilla::Util::PluginLoader->new( sequence => $own_section->sequence ); |
23
|
|
|
|
|
|
|
$own_object->load_plugins($loader); |
24
|
|
|
|
|
|
|
return $own_object; |
25
|
|
|
|
|
|
|
}; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
around dump_config => sub { |
28
|
|
|
|
|
|
|
my ( $orig, $self, @args ) = @_; |
29
|
|
|
|
|
|
|
my $config = $self->$orig(@args); |
30
|
|
|
|
|
|
|
my $localconf = $config->{ +__PACKAGE__ } = {}; |
31
|
|
|
|
|
|
|
$localconf->{ q[$] . __PACKAGE__ . '::VERSION' } = $VERSION; |
32
|
|
|
|
|
|
|
$localconf->{ q[$] . q[Dist::Zilla::Util::PluginLoader::VERSION] } = $Dist::Zilla::Util::PluginLoader::VERSION; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
return $config; |
35
|
|
|
|
|
|
|
}; |
36
|
|
|
|
|
|
|
|
37
|
4
|
|
|
4
|
|
50
|
no Moose::Role; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
37
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
__END__ |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=pod |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=encoding UTF-8 |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 NAME |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Dist::Zilla::Role::PluginLoader - A Plugin that can load others. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 VERSION |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
version 0.001003 |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 WARNINGS |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 STOP |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
You probably don't want to use this module. You either want a C<@PluginBundle>, or L<< |
60
|
|
|
|
|
|
|
C<PluginLoader::Configurable> |
61
|
|
|
|
|
|
|
|Dist::Zilla::Role::PluginLoader::Configurable |
62
|
|
|
|
|
|
|
>> |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 WHEN YOU WANT THIS MODULE |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=over 4 |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=item * You don't want a plugin bundle |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=item * You want something harder to understand for people who use your plugin. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item * You B<I<EXPRESSLY>> wish to hide the loaded modules from things like L<< |
73
|
|
|
|
|
|
|
C<Dist::Zilla::App::Command::bakeini> |
74
|
|
|
|
|
|
|
|Dist::Zilla::App::Command::bakeini |
75
|
|
|
|
|
|
|
>> |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=item * You are loading a single, or handful of modules, all of which are I<BLATANTLY> obvious I<DIRECTLY> in C<dist.ini>, |
78
|
|
|
|
|
|
|
except with some special loading semantics. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=back |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 ADVICE |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=over 4 |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item * Do make consuming plugins have to declare the loaded plugin somehow |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item * Do make consuming plugins able to directly configure the loaded plugin somehow |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item * If at all possible, load at most, one plugin. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item * If at all possible, and you are loading only one plugin, use L<< |
93
|
|
|
|
|
|
|
C<PluginLoader::Configurable> |
94
|
|
|
|
|
|
|
|Dist::Zilla::Role::PluginLoader::Configurable |
95
|
|
|
|
|
|
|
>> |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=item * If you have read this far, and you still are considering using this Role, please contact me, C<kentnl> on |
98
|
|
|
|
|
|
|
C<#distzilla@irc.perl.org>, and let me convince you not to. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=back |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 SYNOPSIS |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
use Moose; |
105
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::Plugin', 'Dist::Zilla::Role::PluginLoader'; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub load_plugins { |
108
|
|
|
|
|
|
|
my ( $self, $loader ) = @_; |
109
|
|
|
|
|
|
|
# Load raw config |
110
|
|
|
|
|
|
|
$loader->load ( 'GatherDir', 'GatherDir-for-FooPlugin', [ include_dotfiles => 1, key => value, ... ]); |
111
|
|
|
|
|
|
|
# Load using ini style input |
112
|
|
|
|
|
|
|
$loader->load_ini( 'GatherDir', 'GatherDir2-for-FooPlugin', [ 'include_dotfiles = 1', 'key = value', ... ]); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 REQUIRES METHODS |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 C<load_plugins> |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Signature: |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
void < load_plugins( $self, $loader ); |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
$loader isa Dist::Zilla::Util::PluginLoader; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
See L<< C<Dist::Zilla::Util::PluginLoader>|Dist::Zilla::Util::PluginLoader >> for details. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head2 C<plugin_from_config> |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Signature: |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
$object < plugin_from_config( $class, $plugin_name, $args, $section ) |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
$object does Dist::Zilla::Role::Plugin |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
$class does Dist::Zilla::Role::Plugin |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
$plugin_name is Str |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
$args is HashRef |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
$section isa Config::MVP::Section |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Recommended Provider: |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::Plugin'; |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
L<< C<Dist::Zilla::Role::Plugin>|Dist::Zilla::Role::Plugin >> |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 AUTHOR |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Kent Fredric <kentnl@cpan.org> |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Kent Fredric <kentfredric@gmail.com>. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
158
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=cut |