blib/lib/Dist/Zilla/PluginBundle/Author/GETTY/Binary.pm

filter: Statementstmt 100% 49 / 49 Branchbran 90.0% 18 / 20 Conditioncond 71.4% 10 / 14 MC/DCmcdc 55.5% 5 / 9 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 2 totaltotal 88.2% 90 / 102 CC 19 SCAR 23.0
CC
19
Cov
93%
configure
15.0
_normalize
5.4
BEGIN
1.0
CRAP 9.9
« .github/dzil-binary/plan.pl ↑ Summary .github/dzil-binary/publish.pl »
1 package Dist::Zilla::PluginBundle::Author::GETTY::Binary;
2 # ABSTRACT: Standalone binary subsection for @Author::GETTY
3 2 our $VERSION = '0.328';
4 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 with 'Dist::Zilla::Role::PluginBundle::Easy';
6  
7 2 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 6 ▶sub mvp_multivalue_args { qw(modules require platforms) } # platforms: so the dist-wide error can name it
Subroutine mvp_multivalue_args: called CC=1 SCAR=0.0
Pod undocumented
10  
11 2 my %DIST_WIDE = ( platforms => 'binary_platforms', prepare => 'binary_prepare' );
12  
13 39 ▶sub configure {
Subroutine configure: called CC=15 SCAR=27.1
Pod undocumented
14 39 my $self = shift;
15  
16 39 my $payload = $self->payload;
17 2 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
18 39 my $defaults = \%Dist::Zilla::PluginBundle::Author::GETTY::BINARY_DEFAULTS;
19 2 ▶ use warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 # Binaries need the GitHub release they are attached to.
22 Carp::croak("[" . $self->name . "] a binary release needs the GitHub release, but the "
23 . "release plugin is not active (no_github, no_github_release or no GitHub remote)")
24 39 ▶ if exists $defaults->{has_release} && !$defaults->{has_release};
Branch: 1 branch
BranchTrueFalseTotal
if exists $defaults->{"has_release"} and not $defaults->{"has_release"} 2 37 39
Condition66%2/3
exists $defaults->{"has_release"} and not $defaults->{"has_release"}
!ll&&!rl&&r
0372
MC/DC50%1/2
exists $defaults->{"has_release"} and not $defaults->{"has_release"}
exists $defaults->{"has_release"} not $defaults->{"has_release"}
Truth table66%2/3
A and not(B)
A= exists $defaults->{"has_release"}B= not $defaults->{"has_release"}
ABresult
0X0
100
111
25  
26 37 for my $k (sort keys %DIST_WIDE) {
27 Carp::croak("[" . $self->name . "] $k is dist-wide: set $DIST_WIDE{$k} in [\@Author::GETTY], not per binary")
28 73 ▶ if exists $payload->{$k};
Branch: 1 branch
BranchTrueFalseTotal
if exists $payload->{$k} 2 71 73
29 }
30  
31 35 my $name = $payload->{binary_name};
32 35 ▶ unless (defined $name) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $name) 2 33 35
33 2 ($name = $self->name) =~ s{\A.*/\s*}{};
34 }
35  
36 35 my %plugin_args = ( binary_name => $name );
37 35 ▶ $plugin_args{script} = $payload->{script} // "bin/$name";
Condition100%2/2
$payload->{"script"} // "bin/$name"
l!l
134
MC/DC100%1/1
$payload->{"script"} // "bin/$name"
$payload->{"script"}
Truth table100%2/2
A
A= $payload->{"script"}
Aresult
11
00
38  
39 35 for my $k (qw( modules require )) {
40 70 ▶ my $list = $self->_normalize($payload->{$k}) // $self->_normalize($defaults->{$k});
Condition100%3/3
$self->_normalize($payload->{$k}) // $self->_normalize($defaults->{$k})
l!l&&r!l&&!r
11059
MC/DC100%2/2
$self->_normalize($payload->{$k}) // $self->_normalize($defaults->{$k})
$self->_normalize($payload->{$k}) $self->_normalize($defaults->{$k})
Truth table100%3/3
A // B
A= $self->_normalize($payload->{$k})B= $self->_normalize($defaults->{$k})
ABresult
1X1
011
000
41 70 ▶ $plugin_args{$k} = $list if $list;
Branch: 1 branch
BranchTrueFalseTotal
if $list 11 59 70
42 }
43 35 for my $k (qw( pp_args verify smoke )) {
44 105 ▶ my $v = $payload->{$k} // $defaults->{$k};
Condition66%2/3
$payload->{$k} // $defaults->{$k}
l!l&&r!l&&!r
01887
MC/DC50%1/2
$payload->{$k} // $defaults->{$k}
$payload->{$k} $defaults->{$k}
Truth table66%2/3
A // B
A= $payload->{$k}B= $defaults->{$k}
ABresult
1X1
011
000
45 105 ▶ $plugin_args{$k} = $v if defined $v;
Branch: 1 branch
BranchTrueFalseTotal
if defined $v 18 87 105
46 }
47 # Dist-wide, from the parent's binary_platforms / binary_prepare only.
48 35 my $platforms = $self->_normalize($defaults->{platforms});
49 35 ▶ $plugin_args{platforms} = $platforms if $platforms;
Branch: 1 branch
BranchTrueFalseTotal
if $platforms 5 30 35
50 35 ▶ $plugin_args{prepare} = $defaults->{prepare} if defined $defaults->{prepare};
Branch: 1 branch
BranchTrueFalseTotal
if defined $defaults->{"prepare"} 3 32 35
51  
52 35 $self->add_plugins([ 'Author::GETTY::Binary' => $name => \%plugin_args ]);
53 }
54  
55 174 ▶sub _normalize {
Subroutine _normalize: called CC=5 SCAR=16.8
56 174 my ($self, $list) = @_;
57 174 ▶ return undef unless defined $list;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $list 158 16 174
58 16 ▶ my @list = ref $list eq 'ARRAY' ? @$list : ($list);
Branch: 1 branch
BranchTrueFalseTotal
ref $list eq 'ARRAY' ? : 16 0 16
59 16 ▶ my @split = map { split /\s+/ } grep { defined && length } @list;
Condition33%1/3
defined $_ && length $_
!ll&&!rl&&r
0022
MC/DC0%0/2
defined $_ && length $_
defined $_ length $_
Truth table33%1/3
A && B
A= defined $_B= length $_
ABresult
0X0
100
111
60 16 ▶ return @split ? \@split : undef;
Branch: 1 branch
BranchTrueFalseTotal
@split ? : 16 0 16
61 }
62  
63 2 __PACKAGE__->meta->make_immutable;
64 2 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
65 2 1;
66  
67 __END__
« .github/dzil-binary/plan.pl ↑ Summary .github/dzil-binary/publish.pl »