line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooX::PluginKit::Plugin; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$MooX::PluginKit::Plugin::VERSION = '0.04'; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
MooX::PluginKit::Plugin - Setup a role as a PluginKit plugin. |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head2 DESCRIPTION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
This module, when C |
14
|
|
|
|
|
|
|
into the caller. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Some higher-level documentation about how to consume plugins can |
17
|
|
|
|
|
|
|
be found at L. |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
|
21
|
4
|
|
|
4
|
|
4879
|
use MooX::PluginKit::Core; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
322
|
|
22
|
4
|
|
|
4
|
|
21
|
use Carp qw(); |
|
4
|
|
|
|
|
15
|
|
|
4
|
|
|
|
|
62
|
|
23
|
4
|
|
|
4
|
|
46
|
use Exporter qw(); |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
83
|
|
24
|
|
|
|
|
|
|
|
25
|
4
|
|
|
4
|
|
19
|
use strictures 2; |
|
4
|
|
|
|
|
28
|
|
|
4
|
|
|
|
|
157
|
|
26
|
4
|
|
|
4
|
|
736
|
use namespace::clean; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
21
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our @EXPORT = qw( |
29
|
|
|
|
|
|
|
plugin_applies_to |
30
|
|
|
|
|
|
|
plugin_includes |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub import { |
34
|
|
|
|
|
|
|
{ |
35
|
16
|
|
|
16
|
|
68617
|
my $caller = (caller())[0]; |
|
16
|
|
|
|
|
42
|
|
36
|
16
|
|
|
|
|
48
|
init_plugin( $caller ); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
16
|
|
|
|
|
3388
|
goto &Exporter::import; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 CANDY |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 plugin_applies_to |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# Only apply to classes which isa() the supplied class, or |
47
|
|
|
|
|
|
|
# DOES() the supplied role. |
48
|
|
|
|
|
|
|
plugin_applies_to 'Some::Class'; |
49
|
|
|
|
|
|
|
plugin_applies_to 'Some::Role'; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# Only apply to classes which match the regex. |
52
|
|
|
|
|
|
|
plugin_applies_to qr/^MyApp::Foo::/; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# Only apply to classes which implement these methods. |
55
|
|
|
|
|
|
|
plugin_applies_to ['foo', 'bar']; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# Only apply to classes which pass this custom check. |
58
|
|
|
|
|
|
|
plugin_applies_to sub{ $_[0]->does('Some::Role') } |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Declares which types of classes this plugin may be applied to. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub plugin_applies_to { |
65
|
11
|
|
|
11
|
1
|
346
|
my ($plugin) = caller(); |
66
|
11
|
|
|
|
|
27
|
local $Carp::Internal{ (__PACKAGE__) } = 1; |
67
|
11
|
|
|
|
|
36
|
set_plugin_applies_to( $plugin, @_ ); |
68
|
11
|
|
|
|
|
21
|
return; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 plugin_includes |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
plugin_includes 'Some::Plugin', '::Relative::Plugin'; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Registers a plugin for inclusion with this plugin. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub plugin_includes { |
80
|
6
|
|
|
6
|
1
|
122
|
my ($plugin) = caller(); |
81
|
6
|
|
|
|
|
16
|
local $Carp::Internal{ (__PACKAGE__) } = 1; |
82
|
6
|
|
|
|
|
18
|
set_plugin_includes( $plugin, @_ ); |
83
|
6
|
|
|
|
|
9
|
return; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |
87
|
|
|
|
|
|
|
__END__ |