blib/lib/Pinto/Remote/SelfContained.pm

filter: Statementstmt 67.2% 39 / 58 Branchbran 20.0% 2 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 63.1% 12 / 19 Podpod 25.0% 1 / 4 totaltotal 56.2% 54 / 96 CC 8 SCAR 14.7
CC
8
Cov
58%
make_action
12.0
load_class_for_action
12.0
__ANON__
6.0
CRAP 4.3
« blib/lib/Pinto/Remote/SelfContained/Action/Install.pm ↑ Summary blib/lib/Pinto/Remote/SelfContained/Result.pm »
1 package Pinto::Remote::SelfContained;
2 # ABSTRACT: interact with a remote Pinto repository
3  
4  
5 2 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Module::Runtime qw(module_notional_filename use_package_optimistically);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Pinto::Remote::SelfContained::Action;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Pinto::Remote::SelfContained::Chrome;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Pinto::Remote::SelfContained::Types qw(Uri);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use Pinto::Remote::SelfContained::Util qw(current_username password_exec);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶use Types::Standard qw(Bool InstanceOf Int Maybe Str);
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 2 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 2 our $VERSION = '1.999'; # TRIAL VERSION
19  
20 2 with qw(
21 Pinto::Remote::SelfContained::HasHttptiny
22 );
23  
24 has root => (
25 is => 'ro',
26 isa => Uri,
27 0 ▶ default => sub { $ENV{PINTO_REPOSITORY_ROOT} },
Subroutine __ANON__: not called CC=1 SCAR=6.9
28 2 coerce => 1,
29 );
30  
31 has username => (
32 is => 'ro',
33 isa => Str,
34 1 ▶ default => sub { current_username() },
Subroutine __ANON__: called CC=1 SCAR=0.0
35 2 );
36  
37 has password => (
38 is => 'ro',
39 isa => Maybe[Str],
40 2 ▶ default => sub {
Subroutine __ANON__: called CC=3 SCAR=12.0
41 2 ▶ return $ENV{PINTO_PASSWORD} if $ENV{PINTO_PASSWORD};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"PINTO_PASSWORD"} 0 2 2
42 2 ▶ return password_exec($ENV{PINTO_PASSEXEC}) if $ENV{PINTO_PASSEXEC};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"PINTO_PASSEXEC"} 0 2 2
43 },
44 2 );
45  
46 has chrome => (
47 is => 'lazy',
48 isa => InstanceOf['Pinto::Remote::SelfContained::Chrome'],
49 0 ▶ builder => sub { Pinto::Remote::SelfContained::Chrome->new },
Subroutine __ANON__: not called CC=1 SCAR=6.9
50 2 );
51  
52  
53 0 ▶sub run {
Subroutine run: not called CC=1 SCAR=6.9
Pod documented
54 0 my ($self, $action_name, @args) = @_;
55  
56 0 my $action = $self->make_action($action_name, @args);
57  
58 0 $action->execute;
59 }
60  
61 0 ▶sub make_action {
Subroutine make_action: not called CC=3 SCAR=24.8
Pod undocumented
62 0 my ($self, $action_name, @args) = @_;
63  
64 0 ▶ my $action_args = (@args == 1 && ref $args[0] eq 'HASH') ? $args[0] : { @args };
Branch: 1 branch
BranchTrueFalseTotal
@args == 1 && ref $args[0] eq 'HASH' ? : 0 0 0
Condition0%0/3
@args == 1 and ref $args[0] eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
@args == 1 and ref $args[0] eq "HASH"
@args == 1 ref $args[0] eq "HASH"
Truth table0%0/3
A and B
A= @args == 1B= ref $args[0] eq "HASH"
ABresult
0X0
100
111
65  
66 0 my $action_class = $self->load_class_for_action(name => $action_name);
67  
68 0 ▶ local $SIG{__WARN__} = sub { $self->chrome->warning($_) for @_ };
Subroutine __ANON__: not called CC=2 SCAR=17.9
69  
70 0 my $action = $action_class->new(
71 name => $action_name,
72 args => $action_args,
73 root => $self->root,
74 username => $self->username,
75 password => $self->password,
76 chrome => $self->chrome,
77 httptiny => $self->httptiny,
78 );
79 }
80  
81 0 ▶sub run_streaming {
Subroutine run_streaming: not called CC=1 SCAR=6.9
Pod undocumented
82 0 my ($self, $streaming_callback, $action_name, @args) = @_;
83  
84 0 my $action = $self->make_action($action_name, @args);
85  
86 0 $action->execute($streaming_callback);;
87 }
88  
89 0 ▶sub load_class_for_action {
Subroutine load_class_for_action: not called CC=3 SCAR=24.8
Pod undocumented
90 0 my ($self, %args) = @_;
91  
92 my $action_name = $args{name}
93 0 ▶ or croak('Must specify an action name');
Branch: 1 branch
BranchTrueFalseTotal
my $action_name = $args{"name"} or croak("Must specify an action name") 0 0 0
94  
95 0 my $class = __PACKAGE__ . "::Action::\u$action_name";
96 0 use_package_optimistically($class);
97 0 ▶ return $INC{ module_notional_filename($class) } ? $class : __PACKAGE__.'::Action';
Branch: 1 branch
BranchTrueFalseTotal
$INC{&module_notional_filename($class)} ? : 0 0 0
98 }
99  
100 2 1;
101  
102 __END__
« blib/lib/Pinto/Remote/SelfContained/Action/Install.pm ↑ Summary blib/lib/Pinto/Remote/SelfContained/Result.pm »