Footprintless/App/Command/service.pm

filter: Statementstmt 86.9% 40 / 46 Branchbran 42.8% 6 / 14 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 8 / 8 Podpod 100% 3 / 3 totaltotal 70.3% 57 / 81 CC 12 SCAR 19.9
CC
12
Cov
70%
validate_args
11.5
execute
8.1
BEGIN
1.0
CRAP 7.3
« Footprintless/App/ActionCommand.pm ↑ Summary Footprintless/Extract.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 Footprintless::App::Command::service;
5 5 $Footprintless::App::Command::service::VERSION = '1.29';
6 5 ▶use Footprintless::App -command;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use Footprintless::Util qw(exit_due_to);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use Log::Any;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 5 my $logger = Log::Any->get_logger();
11  
12 # ABSTRACT: Performs an action on one or more services.
13 # PODNAME: Footprintless::App::Command::service
14  
15 3 ▶sub execute {
Subroutine execute: called CC=5 SCAR=20.9
Pod documented
16 3 my ( $self, $opts, $args ) = @_;
17 3 my ( $coordinate, $action ) = @$args;
18  
19 3 foreach my $target ( @{ $self->{targets} } ) {
20 4 $logger->debugf( 'executing %s for %s', $action, $target->{coordinate} );
21 4 eval { $target->execute($action); };
22 4 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 4 4
23 0 ▶ if ( ref($@) && $@->isa('Footprintless::InvalidEntityException') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $@ and $@->isa("Footprintless::InvalidEntityException")) 0 0 0
Condition0%0/3
ref $@ and $@->isa("Footprintless::InvalidEntityException")
!ll&&!rl&&r
000
MC/DC0%0/2
ref $@ and $@->isa("Footprintless::InvalidEntityException")
ref $@ $@->isa("Footprintless::InvalidEntityException")
Truth table0%0/3
A and B
A= ref $@B= $@->isa("Footprintless::InvalidEntityException")
ABresult
0X0
100
111
24 0 $self->usage_error($@);
25 }
26 0 exit_due_to( $@, 1 );
27 }
28 }
29 }
30  
31 3 ▶sub usage_desc {
Subroutine usage_desc: called CC=1 SCAR=0.0
Pod documented
32 3 return "fpl service SERVICE_COORD ACTION";
33 }
34  
35 3 ▶sub validate_args {
Subroutine validate_args: called CC=8 SCAR=24.4
Pod documented
36 3 my ( $self, $opt, $args ) = @_;
37 3 my ( $coordinate, $action, @sub_coordinates ) = @$args;
38  
39 3 ▶ $self->usage_error("coordinate is required") unless ($coordinate);
Branch: 1 branch
BranchTrueFalseTotal
unless $coordinate 0 3 3
40 3 ▶ $self->usage_error("action is required") unless ($action);
Branch: 1 branch
BranchTrueFalseTotal
unless $action 0 3 3
41  
42 3 my $footprintless = $self->app()->footprintless();
43  
44 my @target_coordinates =
45 @sub_coordinates
46 3 ▶ ? map {"$coordinate.$_"} @sub_coordinates
Branch: 1 branch
BranchTrueFalseTotal
@sub_coordinates ? : 1 2 3
47 : ($coordinate);
48  
49 3 my @targets = ();
50 3 foreach my $target_coordinate (@target_coordinates) {
51 4 eval { push( @targets, $footprintless->service($target_coordinate) ); };
52 4 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 4 4
53 0 ▶ if ( ref($@) && $@->isa('Footprintless::InvalidEntityException') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $@ and $@->isa('Footprintless::InvalidEntityException')) { } 0 0 0
Condition0%0/3
ref $@ and $@->isa("Footprintless::InvalidEntityException")
!ll&&!rl&&r
000
MC/DC0%0/2
ref $@ and $@->isa("Footprintless::InvalidEntityException")
ref $@ $@->isa("Footprintless::InvalidEntityException")
Truth table0%0/3
A and B
A= ref $@B= $@->isa("Footprintless::InvalidEntityException")
ABresult
0X0
100
111
54 0 $self->usage_error($@);
55 }
56 else {
57 0 $self->usage_error("invalid coordinate [$target_coordinate]: $@");
58 }
59 }
60 }
61 3 $self->{targets} = \@targets;
62 }
63  
64 5 1;
65  
66 __END__
« Footprintless/App/ActionCommand.pm ↑ Summary Footprintless/Extract.pm »