PluginKit/Plugin.pm

filter: Statementstmt 100% 32 / 32 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 2 / 2 totaltotal 100% 43 / 43 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« PluginKit/ConsumerRole.pm ↑ Summary
1 package MooX::PluginKit::Plugin;
2 4 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 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<use>d, exports several candy functions (see L</CANDY>)
15 into the caller.
16  
17 Some higher-level documentation about how to consume plugins can
18 be found at L<MooX::PluginKit/CREATING PLUGINS>.
19  
20 =cut
21  
22 4 ▶use MooX::PluginKit::Core;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 4 ▶use Carp qw();
Subroutine BEGIN: called CC=1 SCAR=0.0
24 4 ▶use Exporter qw();
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 4 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 4 our @EXPORT = qw(
29 plugin_applies_to
30 plugin_includes
31 );
32  
33 16 ▶sub import {
Subroutine import: called CC=1 SCAR=0.0
34 {
35 16 my $caller = (caller())[0];
36 16 init_plugin( $caller );
37 }
38  
39 16 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 11 ▶sub plugin_applies_to {
Subroutine plugin_applies_to: called CC=1 SCAR=0.0
Pod documented
65 11 my ($plugin) = caller();
66 11 local $Carp::Internal{ (__PACKAGE__) } = 1;
67 11 set_plugin_applies_to( $plugin, @_ );
68 11 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 6 ▶sub plugin_includes {
Subroutine plugin_includes: called CC=1 SCAR=0.0
Pod documented
80 6 my ($plugin) = caller();
81 6 local $Carp::Internal{ (__PACKAGE__) } = 1;
82 6 set_plugin_includes( $plugin, @_ );
83 6 return;
84 }
85  
86 4 1;
87 __END__
« PluginKit/ConsumerRole.pm ↑ Summary