blib/lib/Dist/Zilla/Role/Plugin.pm

filter: Statementstmt 100% 31 / 31 Branchbran n/a Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 4 totaltotal 91.6% 44 / 48 CC 2 SCAR 1.7
CC
2
Cov
100%
register_component
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« blib/lib/Dist/Zilla/Plugin/TemplateModule.pm ↑ Summary blib/lib/Dist/Zilla/File/OnDisk.pm »
1 package Dist::Zilla::Role::Plugin 6.040;
2 # ABSTRACT: something that gets plugged in to Dist::Zilla
3  
4 53 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 53 with 'Dist::Zilla::Role::ConfigDumper';
6  
7 53 ▶use Dist::Zilla::Pragmas;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 53 ▶use Params::SomeUtil qw(_HASHLIKE);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 53 ▶use Moose::Util::TypeConstraints 'class_type';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 53 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 #pod =head1 DESCRIPTION
15 #pod
16 #pod The Plugin role should be applied to all plugin classes. It provides a few key
17 #pod methods and attributes that all plugins will need.
18 #pod
19 #pod =attr plugin_name
20 #pod
21 #pod The plugin name is generally determined when configuration is read.
22 #pod
23 #pod =cut
24  
25 53 has plugin_name => (
26 is => 'ro',
27 isa => 'Str',
28 required => 1,
29 );
30  
31 #pod =attr zilla
32 #pod
33 #pod This attribute contains the Dist::Zilla object into which the plugin was
34 #pod plugged.
35 #pod
36 #pod =cut
37  
38 53 has zilla => (
39 is => 'ro',
40 isa => class_type('Dist::Zilla'),
41 required => 1,
42 weak_ref => 1,
43 );
44  
45 #pod =method log
46 #pod
47 #pod The plugin's C<log> method delegates to the Dist::Zilla object's
48 #pod L<Dist::Zilla/log> method after including a bit of argument-munging.
49 #pod
50 #pod =cut
51  
52 has logger => (
53 is => 'ro',
54 lazy => 1,
55 handles => [ qw(log log_debug log_fatal) ],
56 771 ▶ default => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
57 771 $_[0]->zilla->chrome->logger->proxy({
58 proxy_prefix => '[' . $_[0]->plugin_name . '] ',
59 });
60 },
61 53 );
62  
63 # We define these effectively-pointless subs here to allow other roles to
64 # modify them with around. -- rjbs, 2010-03-21
65 481 ▶sub mvp_multivalue_args {};
Subroutine mvp_multivalue_args: called CC=1 SCAR=0.0
Pod undocumented
66 520 ▶sub mvp_aliases { return {} };
Subroutine mvp_aliases: called CC=1 SCAR=0.0
Pod undocumented
67  
68 768 ▶sub plugin_from_config {
Subroutine plugin_from_config: called CC=1 SCAR=0.0
Pod undocumented
69 768 my ($class, $name, $arg, $section) = @_;
70  
71 768 my $self = $class->new({
72 %$arg,
73 plugin_name => $name,
74 zilla => $section->sequence->assembler->zilla,
75 });
76 }
77  
78 768 ▶sub register_component {
Subroutine register_component: called CC=2 SCAR=6.9
Pod undocumented
79 768 my ($class, $name, $arg, $section) = @_;
80  
81 768 my $self = $class->plugin_from_config($name, $arg, $section);
82  
83 767 ▶ my $version = $self->VERSION || 0;
Condition100%2/2
$self->VERSION || 0
l!l
75215
MC/DC100%1/1
$self->VERSION || 0
$self->VERSION
Truth table100%2/2
A
A= $self->VERSION
Aresult
11
00
84  
85 767 $self->log_debug([ 'online, %s v%s', $self->meta->name, $version ]);
86  
87 767 push @{ $self->zilla->plugins }, $self;
88  
89 767 return;
90 }
91  
92 53 1;
93  
94 __END__
« blib/lib/Dist/Zilla/Plugin/TemplateModule.pm ↑ Summary blib/lib/Dist/Zilla/File/OnDisk.pm »