blib/lib/Pinto/Remote/Action/Install.pm

filter: Statementstmt 58.4% 31 / 53 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 63.6% 7 / 11 Podpod n/a totaltotal 46.3% 38 / 82 CC 9 SCAR 22.0
CC
9
Cov
45%
__ANON__
20.0
_build_mirror_uri
12.0
__ANON__
12.0
CRAP 9.0
« blib/lib/App/Pinto/Command/thanks.pm ↑ Summary blib/lib/App/Pinto/Command/roots.pm »
1 # ABSTRACT: Install packages from the repository
2  
3 package Pinto::Remote::Action::Install;
4  
5 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use MooseX::MarkAsMethods ( autoclean => 1 );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use MooseX::Types::Moose qw(Undef Bool HashRef ArrayRef Maybe Str);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶use File::Temp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use File::Which qw(which);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 ▶use Pinto::Result;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Pinto::Util qw(throw);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 #------------------------------------------------------------------------------
16  
17 1 our $VERSION = '0.14'; # VERSION
18  
19 #------------------------------------------------------------------------------
20  
21 1 extends qw( Pinto::Remote::Action );
22  
23 #------------------------------------------------------------------------------
24  
25 has targets => (
26 isa => ArrayRef [Str],
27 traits => ['Array'],
28 handles => { targets => 'elements' },
29 0 ▶ default => sub { $_[0]->args->{targets} || [] },
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0]->args->{"targets"} or [] 0 0 0
30 1 lazy => 1,
31 );
32  
33 1 has do_pull => (
34 is => 'ro',
35 isa => Bool,
36 default => 0,
37 );
38  
39 1 has mirror_uri => (
40 is => 'ro',
41 isa => Str,
42 builder => '_build_mirror_uri',
43 lazy => 1,
44 );
45  
46 #------------------------------------------------------------------------------
47  
48 0 ▶sub _build_mirror_uri {
Subroutine _build_mirror_uri: not called CC=3 SCAR=24.8
49 0 my ($self) = @_;
50  
51 0 my $stack = $self->args->{stack};
52 0 ▶ my $stack_dir = defined $stack ? "/stacks/$stack" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $stack ? : 0 0 0
53 0 my $mirror_uri = $self->root . $stack_dir;
54  
55 0 ▶ if ( defined $self->password ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->password) 0 0 0
56  
57 # Squirt username and password into URI
58 0 my $credentials = $self->username . ':' . $self->password;
59 0 $mirror_uri =~ s{^ (https?://) }{$1$credentials\@}mx;
60 }
61  
62 0 return $mirror_uri;
63 }
64  
65 #------------------------------------------------------------------------------
66  
67 0 ▶around BUILDARGS => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
68 0 my $orig = shift;
69 0 my $class = shift;
70  
71 0 my $args = $class->$orig(@_);
72  
73 # Intercept attributes from the action "args" hash
74 0 ▶ $args->{do_pull} = delete $args->{args}->{do_pull} || 0;
Condition0%0/2
delete $args->{'args'}{'do_pull'} || 0
l!l
00
MC/DC0%0/1
delete $args->{'args'}{'do_pull'} || 0
delete $args->{'args'}{'do_pull'}
Truth table0%0/2
A
A= delete $args->{'args'}{'do_pull'}
Aresult
11
00
75 0 ▶ $args->{cpanm_options} = delete $args->{args}->{cpanm_options} || {};
Condition0%0/2
delete $args->{'args'}{'cpanm_options'} || {}
l!l
00
MC/DC0%0/1
delete $args->{'args'}{'cpanm_options'} || {}
delete $args->{'args'}{'cpanm_options'}
Truth table0%0/2
A
A= delete $args->{'args'}{'cpanm_options'}
Aresult
11
00
76  
77 0 return $args;
78 1 };
79  
80 #------------------------------------------------------------------------------
81  
82 0 ▶override execute => sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
83 0 my ($self) = @_;
84  
85 0 my $result;
86 0 ▶ if ( $self->do_pull ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->do_pull) 0 0 0
87  
88 0 my $request = $self->_make_request( name => 'pull' );
89 0 $result = $self->_send_request( req => $request );
90  
91 0 ▶ throw 'Failed to pull packages' if not $result->was_successful;
Branch: 1 branch
BranchTrueFalseTotal
unless $result->was_successful 0 0 0
92 }
93  
94 # Pinto::Role::Installer will handle installation after execute()
95 0 ▶ return defined $result ? $result : Pinto::Result->new;
Branch: 1 branch
BranchTrueFalseTotal
defined $result ? : 0 0 0
96 1 };
97  
98 #------------------------------------------------------------------------------
99  
100 1 with qw( Pinto::Role::Installer );
101  
102 #------------------------------------------------------------------------------
103  
104 1 __PACKAGE__->meta->make_immutable;
105  
106 #-----------------------------------------------------------------------------
107 1 1;
108  
109 __END__
« blib/lib/App/Pinto/Command/thanks.pm ↑ Summary blib/lib/App/Pinto/Command/roots.pm »