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

filter: Statementstmt 100% 39 / 39 Branchbran 85.0% 17 / 20 Conditioncond 78.5% 11 / 14 MC/DCmcdc 62.5% 5 / 8 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 2 totaltotal 87.7% 79 / 90 CC 17 SCAR 21.6
CC
17
Cov
92%
configure
13.0
_normalize_tags
5.2
BEGIN
1.0
CRAP 8.7
« .github/dzil-binary/publish.pl ↑ Summary .github/dzil-binary/pp-args.pl »
1 package Dist::Zilla::PluginBundle::Author::GETTY::Docker;
2 # ABSTRACT: Docker image subsection for @Author::GETTY
3 3 our $VERSION = '0.328';
4 3 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 with 'Dist::Zilla::Role::PluginBundle::Easy';
6  
7 9 ▶sub mvp_multivalue_args { qw(tags build_arg label platform) }
Subroutine mvp_multivalue_args: called CC=1 SCAR=0.0
Pod undocumented
8  
9 13 ▶sub configure {
Subroutine configure: called CC=13 SCAR=25.7
Pod undocumented
10 13 my $self = shift;
11  
12 13 my $payload = $self->payload;
13 3 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
14 13 my $defaults = \%Dist::Zilla::PluginBundle::Author::GETTY::DOCKER_DEFAULTS;
15 3 ▶ use warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 13 ▶ my $image = $payload->{image} // $defaults->{image};
Condition100%3/3
$payload->{"image"} // $defaults->{"image"}
l!l&&r!l&&!r
292
MC/DC100%2/2
$payload->{"image"} // $defaults->{"image"}
$payload->{"image"} $defaults->{"image"}
Truth table100%3/3
A // B
A= $payload->{"image"}B= $defaults->{"image"}
ABresult
1X1
011
000
18 13 ▶ unless (defined $image && length $image) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $image and length $image) 2 11 13
Condition66%2/3
defined $image and length $image
!ll&&!rl&&r
2011
MC/DC50%1/2
defined $image and length $image
defined $image length $image
Truth table66%2/3
A and B
A= defined $imageB= length $image
ABresult
0X0
100
111
19 2 require Carp;
20 2 Carp::croak(
21 "[" . $self->name . "] needs either `image = ...` in this subsection "
22 . "or `docker_image = ...` in [\@Author::GETTY]"
23 );
24 }
25  
26 my $tags = $self->_normalize_tags($payload->{tags})
27 // $self->_normalize_tags($defaults->{tags})
28 11 ▶ // ['latest', '%V', '%v'];
Condition100%5/5
($self->_normalize_tags($payload->{"tags"}) // $self->_normalize_tags($defaults->{"tags"})) // ["latest", "%V", "%v"]
l!l
56
$self->_normalize_tags($payload->{"tags"}) // $self->_normalize_tags($defaults->{"tags"})
l!l&&r!l&&!r
326
MC/DC100%2/2
($self->_normalize_tags($payload->{"tags"}) // $self->_normalize_tags($defaults->{"tags"})) // ["latest", "%V", "%v"]
$self->_normalize_tags($payload->{"tags"}) $self->_normalize_tags($defaults->{"tags"})
Truth table100%3/3
A // B
A= $self->_normalize_tags($payload->{"tags"})B= $self->_normalize_tags($defaults->{"tags"})
ABresult
1X1
011
000
29  
30 my $local = exists $payload->{local} ? $payload->{local}
31 : exists $defaults->{local} ? $defaults->{local}
32 11 ▶ : 0;
Branch: 2 branches
BranchTrueFalseTotal
exists $payload->{'local'} ? : 1 10 11
exists $defaults->{'local'} ? : 9 1 10
33  
34 11 ▶ my %plugin_args = (
Branch: 1 branch
BranchTrueFalseTotal
$local ? : 1 10 11
35 image => $image,
36 tag => $tags,
37 release_push => $local ? 0 : 1,
38 );
39  
40 11 ▶ $plugin_args{_target} = $payload->{target} if defined $payload->{target};
Branch: 1 branch
BranchTrueFalseTotal
if defined $payload->{"target"} 7 4 11
41 11 ▶ $plugin_args{_network_mode} = $payload->{network_mode} if defined $payload->{network_mode};
Branch: 1 branch
BranchTrueFalseTotal
if defined $payload->{"network_mode"} 0 11 11
42  
43 11 for my $k (qw(
44 dockerfile build_arg label platform build_verbose
45 pull no_cache rm force_rm fail_if_tag_exists skip_latest_on_trial
46 )) {
47 121 ▶ $plugin_args{$k} = $payload->{$k} if exists $payload->{$k};
Branch: 1 branch
BranchTrueFalseTotal
if exists $payload->{$k} 0 121 121
48 }
49  
50 11 $self->add_plugins([ 'Docker::API' => \%plugin_args ]);
51 }
52  
53 19 ▶sub _normalize_tags {
Subroutine _normalize_tags: called CC=5 SCAR=16.4
54 19 my ($self, $tags) = @_;
55 19 ▶ return undef unless defined $tags;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $tags 14 5 19
56 5 ▶ my @list = ref $tags eq 'ARRAY' ? @$tags : ($tags);
Branch: 1 branch
BranchTrueFalseTotal
ref $tags eq 'ARRAY' ? : 3 2 5
57 5 ▶ my @split = map { split /\s+/ } grep { defined && length } @list;
Condition33%1/3
defined $_ && length $_
!ll&&!rl&&r
005
MC/DC0%0/2
defined $_ && length $_
defined $_ length $_
Truth table33%1/3
A && B
A= defined $_B= length $_
ABresult
0X0
100
111
58 5 ▶ return @split ? \@split : undef;
Branch: 1 branch
BranchTrueFalseTotal
@split ? : 5 0 5
59 }
60  
61 3 __PACKAGE__->meta->make_immutable;
62 3 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
63 3 1;
64  
65 __END__
« .github/dzil-binary/publish.pl ↑ Summary .github/dzil-binary/pp-args.pl »