Embra/Plugin/WrapZillaPlugin.pm

filter: Statementstmt 77.0% 74 / 96 Branchbran 38.1% 16 / 42 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 80.9% 17 / 21 Podpod n/a totaltotal 61.4% 107 / 174 CC 27 SCAR 24.7
CC
27
Cov
61%
__ANON__
42.0
extra_list_deps
33.4
__ANON__
6.0
CRAP 11.8
« Embra/Plugin/Zilla/WrapLog.pm ↑ Summary Embra/Role/ExtraListDeps.pm »
1 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package App::Embra::Plugin::WrapZillaPlugin;
5 5 $App::Embra::Plugin::WrapZillaPlugin::VERSION = '0.001'; # TRIAL
6 # ABSTRACT: adapts a Dist::Zilla plugin to work with App::Embra
7  
8 5 ▶use Class::Inspector qw<>;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 5 ▶use Module::Runtime qw<>;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 ▶use Method::Signatures;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 5 ▶use App::Embra::Plugin::Zilla::WrapLog;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 5 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15  
16  
17 5 ▶has 'plugin' => (
Subroutine __ANON__: called CC=4 SCAR=14.2
Branch: 2 branches
BranchTrueFalseTotal
unless scalar @_ > 0 0 5 5
if scalar @_ > 1 0 5 5
18 5 ▶ is => 'lazy',
Branch: 1 branch
BranchTrueFalseTotal
if not $plugin->does("Dist::Zilla::Role::Plugin") 1 4 5
19 isa => func( $plugin ) {
20 die q{can't wrap something that isn't a Dist::Zilla plugin!}
21 5 if not $plugin->does( 'Dist::Zilla::Role::Plugin' );
22 },
23 0 ▶);
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if scalar @_ > 0 0 0 0
24 5  
25 has 'plugin_args' => (
26 is => 'ro',
27 0 ▶ default => func { {} },
Subroutine __ANON__: not called CC=6 SCAR=37.4
Branch: 4 branches
BranchTrueFalseTotal
unless scalar @_ > 0 0 0 0
unless scalar @_ > 1 0 0 0
unless scalar @_ > 2 0 0 0
if scalar @_ > 3 0 0 0
28 0 ▶);
Condition0%0/3
$class eq 'Dist::Zilla' || &$orig($self, $class)
l!l&&r!l&&!r
000
MC/DC0%0/2
$class eq 'Dist::Zilla' || &$orig($self, $class)
$class eq 'Dist::Zilla' &$orig($self, $class)
Truth table0%0/3
A || B
A= $class eq 'Dist::Zilla'B= &$orig($self, $class)
ABresult
1X1
011
000
29 5  
30  
31 5 ▶around 'isa' => func ( $orig, $self, $class ) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine _build_plugin: called CC=3 SCAR=11.0
Branch: 1 branch
BranchTrueFalseTotal
if scalar @_ > 0 0 5 5
32 5 return $class eq 'Dist::Zilla' || $orig->($self, $class); # cheeky
33 };
34 5 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
unless ("Class::Inspector"->loaded($plugin_class)) 4 1 5
35 4 method _build_plugin {
36 ( my $plugin_class = $self->name ) =~ s/^-/Dist::Zilla::Plugin::/xms;
37  
38 if( not Class::Inspector->loaded( $plugin_class ) ) {
39 Module::Runtime::require_module $plugin_class;
40 }
41  
42 return $plugin_class->new(
43 zilla => $self,
44 plugin_name => $self->name,
45 5 logger => App::Embra::Plugin::Zilla::WrapLog->new(
46 proxy_prefix => '['.$self->name.'] ',
47 logger => $self->embra->logger,
48 ),
49 5 ▶ %{ $self->plugin_args },
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BUILDARGS: called CC=3 SCAR=11.0
50 5 );
51 5 }
52 5  
53 15 ▶method BUILDARGS( @args ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{$attr}) 10 5 15
54 10 my %args = @args;
55 my %attrs;
56 for my $attr ( qw< embra name plugin > ) {
57 if( exists $args{$attr} ) {
58 5 $attrs{$attr} = delete $args{$attr};
59 }
60 }
61 5 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine publish_site: called CC=4 SCAR=14.6
Branch: 1 branch
BranchTrueFalseTotal
if scalar @_ > 0 0 3 3
62 3 ▶ return { %attrs, plugin_args => \%args };
Subroutine __ANON__: called CC=3 SCAR=11.4
Subroutine __ANON__: called CC=3 SCAR=11.4
Branch: 4 branches
BranchTrueFalseTotal
unless scalar @_ > 0 0 1 1
if scalar @_ > 1 0 1 1
unless scalar @_ > 0 0 2 2
if scalar @_ > 1 0 2 2
63 }
64 3  
65 6 method publish_site {
66 6 my @wraps = (
67 6 ▶ [ '-AfterBuild' => func( $plugin ) { $plugin->after_build({ build_root => q<.> }) } ],
Branch: 1 branch
BranchTrueFalseTotal
if ($self->plugin->does($role)) 3 3 6
68 0 ▶ [ '-BeforeRelease' => func( $plugin ) { $plugin->before_release() } ],
Subroutine __ANON__: not called CC=2 SCAR=14.6
Branch: 1 branch
BranchTrueFalseTotal
if scalar @_ > 0 0 0 0
69 3 );
70 for my $wrap ( @wraps ) {
71 my( $role, $shim ) = @{ $wrap };
72 $role =~ s/^-/Dist::Zilla::Role::/xms;
73 if( $self->plugin->does( $role ) ) {
74 0 ▶ local *Dist::Zilla::VERSION = method { 4 }; # App::Embra::File->content, not ->encoded_content
Subroutine BEGIN: called CC=1 SCAR=5.5
Subroutine extra_list_deps: not called CC=6 SCAR=35.1
Branch: 3 branches
BranchTrueFalseTotal
if exists $args{"config"} and not +($Method::Signatures::mutc{"cache"}{"HashRef"} ||= "Method::Signatures"->_make_constraint("HashRef"))->check($config) 0 0 0
if keys %args 0 0 0
if scalar @_ > 2 0 0 0
Condition0%0/6
exists $args{"config"} and not +($Method::Signatures::mutc{"cache"}{"HashRef"} ||= "Method::Signatures"->_make_constraint("HashRef"))->check($config)
!ll&&!rl&&r
000
$Method::Signatures::mutc{"cache"}{"HashRef"} ||= "Method::Signatures"->_make_constraint("HashRef")
l!l&&r!l&&!r
000
MC/DC0%0/2
exists $args{"config"} and not +($Method::Signatures::mutc{"cache"}{"HashRef"} ||= "Method::Signatures"->_make_constraint("HashRef"))->check($config)
exists $args{"config"} not +($Method::Signatures::mutc{"cache"}{"HashRef"} ||= "Method::Signatures"->_make_constraint("HashRef"))->check($config)
MC/DC0%0/2
$Method::Signatures::mutc{"cache"}{"HashRef"} ||= "Method::Signatures"->_make_constraint("HashRef")
$Method::Signatures::mutc{"cache"}{"HashRef"} "Method::Signatures"->_make_constraint("HashRef")
Truth table0%0/3
A and not(B)
A= exists $args{"config"}B= not +($Method::Signatures::mutc{"cache"}{"HashRef"} ||= "Method::Signatures"->_make_constraint("HashRef"))->check($config)
ABresult
0X0
100
111
Truth table0%0/3
A ||= B
A= $Method::Signatures::mutc{"cache"}{"HashRef"}B= "Method::Signatures"->_make_constraint("HashRef")
ABresult
1X1
011
000
75 0 $shim->( $self->plugin );
76 0 }
77 }
78 }
79 5  
80 5 method extra_list_deps($class:, HashRef :$config) {
81 ( my $plugin_class = $config->{_name} ) =~ s/^-/Dist::Zilla::Plugin::/xms;
82 5 return $plugin_class;
83 }
84  
85 with 'App::Embra::Role::SitePublisher';
86 with 'App::Embra::Role::ExtraListDeps';
87  
88 5 has '+embra' => (
89 is => 'ro',
90 required => 1,
91 handles => [ qw< files > ],
92 );
93  
94 1;
95  
96 __END__
« Embra/Plugin/Zilla/WrapLog.pm ↑ Summary Embra/Role/ExtraListDeps.pm »