line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooX::PluginKit::Plugin; |
2
|
4
|
|
|
4
|
|
5351
|
use 5.008001; |
|
4
|
|
|
|
|
13
|
|
3
|
4
|
|
|
4
|
|
24
|
use strictures 2; |
|
4
|
|
|
|
|
28
|
|
|
4
|
|
|
|
|
139
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
MooX::PluginKit::Plugin - Setup a role as a PluginKit plugin. |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 SYNOPSIS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head2 DESCRIPTION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
This module, when C |
15
|
|
|
|
|
|
|
into the caller. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Some higher-level documentation about how to consume plugins can |
18
|
|
|
|
|
|
|
be found at L. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
4
|
|
|
4
|
|
812
|
use MooX::PluginKit::Core; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
426
|
|
23
|
4
|
|
|
4
|
|
26
|
use Carp qw(); |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
88
|
|
24
|
4
|
|
|
4
|
|
52
|
use Exporter qw(); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
77
|
|
25
|
|
|
|
|
|
|
|
26
|
4
|
|
|
4
|
|
21
|
use namespace::clean; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
23
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our @EXPORT = qw( |
29
|
|
|
|
|
|
|
plugin_applies_to |
30
|
|
|
|
|
|
|
plugin_includes |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub import { |
34
|
|
|
|
|
|
|
{ |
35
|
16
|
|
|
16
|
|
83112
|
my $caller = (caller())[0]; |
|
16
|
|
|
|
|
48
|
|
36
|
16
|
|
|
|
|
55
|
init_plugin( $caller ); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
16
|
|
|
|
|
3938
|
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
|
389
|
my ($plugin) = caller(); |
66
|
11
|
|
|
|
|
31
|
local $Carp::Internal{ (__PACKAGE__) } = 1; |
67
|
11
|
|
|
|
|
44
|
set_plugin_applies_to( $plugin, @_ ); |
68
|
11
|
|
|
|
|
22
|
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
|
136
|
my ($plugin) = caller(); |
81
|
6
|
|
|
|
|
15
|
local $Carp::Internal{ (__PACKAGE__) } = 1; |
82
|
6
|
|
|
|
|
21
|
set_plugin_includes( $plugin, @_ ); |
83
|
6
|
|
|
|
|
13
|
return; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |
87
|
|
|
|
|
|
|
__END__ |