| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package MooX::PluginKit::Plugin; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
|
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
|
|
5584
|
use MooX::PluginKit::Core; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
379
|
|
|
22
|
4
|
|
|
4
|
|
26
|
use Carp qw(); |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
57
|
|
|
23
|
4
|
|
|
4
|
|
17
|
use Exporter qw(); |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
123
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
4
|
|
|
4
|
|
24
|
use strictures 2; |
|
|
4
|
|
|
|
|
29
|
|
|
|
4
|
|
|
|
|
165
|
|
|
26
|
4
|
|
|
4
|
|
766
|
use namespace::clean; |
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
31
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our @EXPORT = qw( |
|
29
|
|
|
|
|
|
|
plugin_applies_to |
|
30
|
|
|
|
|
|
|
plugin_includes |
|
31
|
|
|
|
|
|
|
); |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub import { |
|
34
|
|
|
|
|
|
|
{ |
|
35
|
16
|
|
|
16
|
|
85342
|
my $caller = (caller())[0]; |
|
|
16
|
|
|
|
|
52
|
|
|
36
|
16
|
|
|
|
|
63
|
init_plugin( $caller ); |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
16
|
|
|
|
|
3819
|
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
|
381
|
my ($plugin) = caller(); |
|
66
|
11
|
|
|
|
|
33
|
local $Carp::Internal{ (__PACKAGE__) } = 1; |
|
67
|
11
|
|
|
|
|
45
|
set_plugin_applies_to( $plugin, @_ ); |
|
68
|
11
|
|
|
|
|
38
|
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
|
|
|
|
|
12
|
local $Carp::Internal{ (__PACKAGE__) } = 1; |
|
82
|
6
|
|
|
|
|
19
|
set_plugin_includes( $plugin, @_ ); |
|
83
|
6
|
|
|
|
|
14
|
return; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |
|
87
|
|
|
|
|
|
|
__END__ |