Footprintless/CommandOptionsFactory.pm

filter: Statementstmt 100% 30 / 30 Branchbran 80.0% 8 / 10 Conditioncond 81.8% 9 / 11 MC/DCmcdc 50.0% 3 / 6 Subroutinesub 100% 8 / 8 Podpod 100% 2 / 2 totaltotal 89.5% 60 / 67 CC 10 SCAR 15.5
CC
10
Cov
92%
command_options
8.1
_init
3.0
BEGIN
1.0
CRAP 4.7
« Footprintless/Util.pm ↑ Summary Footprintless/Localhost.pm »
1 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package Footprintless::CommandOptionsFactory;
5 11 $Footprintless::CommandOptionsFactory::VERSION = '1.29';
6 # ABSTRACT: A factory for creating command options
7 # PODNAME: Footprintless::CommandOptionsFactory
8  
9 11 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 11 ▶use Footprintless::Localhost;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 11 ▶use Footprintless::Command;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 24 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
14 24 return bless( {}, shift )->_init(@_);
15 }
16  
17 35 ▶sub command_options {
Subroutine command_options: called CC=8 SCAR=20.9
Pod documented
18 35 my ( $self, %options ) = @_;
19  
20 35 ▶ $options{ssh} = $self->{default_ssh} unless ( $options{ssh} );
Branch: 1 branch
BranchTrueFalseTotal
unless $options{"ssh"} 32 3 35
21 35 ▶ delete( $options{sudo_username} ) unless ( $options{sudo_username} );
Branch: 1 branch
BranchTrueFalseTotal
unless $options{"sudo_username"} 32 3 35
22 35 ▶ delete( $options{sudo_command} ) unless ( $options{sudo_command} );
Branch: 1 branch
BranchTrueFalseTotal
unless $options{"sudo_command"} 35 0 35
23 35 ▶ delete( $options{username} ) unless ( $options{username} );
Branch: 1 branch
BranchTrueFalseTotal
unless $options{"username"} 35 0 35
24 35 ▶ if ( $self->{localhost}
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"localhost"} and $options{"hostname"} and $self->{"localhost"}->is_alias($options{"hostname"})) 14 21 35
Condition83%5/6
$self->{"localhost"} and $options{"hostname"} and $self->{"localhost"}->is_alias($options{"hostname"})
!ll&&!rl&&r
16514
$self->{"localhost"} and $options{"hostname"}
!ll&&!rl&&r
01619
MC/DC66%2/3
$self->{"localhost"} and $options{"hostname"} and $self->{"localhost"}->is_alias($options{"hostname"})
$self->{"localhost"} $options{"hostname"} $self->{"localhost"}->is_alias($options{"hostname"})
Truth table75%3/4
A and B and C
A= $self->{"localhost"}B= $options{"hostname"}C= $self->{"localhost"}->is_alias($options{"hostname"})
ABCresult
0XX0
10X0
1100
1111
25 && $options{hostname}
26 && $self->{localhost}->is_alias( $options{hostname} ) )
27 {
28 14 delete( $options{hostname} );
29 }
30  
31 35 return Footprintless::Command::command_options(%options);
32 }
33  
34 24 ▶sub _init {
Subroutine _init: called CC=3 SCAR=11.0
35 24 my ( $self, %options ) = @_;
36  
37 $self->{localhost} = $options{localhost}
38 24 ▶ || Footprintless::Localhost->new()->load_all();
Condition66%2/3
$options{'localhost'} || 'Footprintless::Localhost'->new->load_all
l!l&&r!l&&!r
2220
MC/DC0%0/2
$options{'localhost'} || 'Footprintless::Localhost'->new->load_all
$options{'localhost'} 'Footprintless::Localhost'->new->load_all
Truth table66%2/3
A || B
A= $options{'localhost'}B= 'Footprintless::Localhost'->new->load_all
ABresult
1X1
011
000
39 24 ▶ $self->{default_ssh} = $options{default_ssh} || 'ssh -q';
Condition100%2/2
$options{'default_ssh'} || 'ssh -q'
l!l
222
MC/DC100%1/1
$options{'default_ssh'} || 'ssh -q'
$options{'default_ssh'}
Truth table100%2/2
A
A= $options{'default_ssh'}
Aresult
11
00
40  
41 24 return $self;
42 }
43  
44 11 1;
45  
46 __END__
« Footprintless/Util.pm ↑ Summary Footprintless/Localhost.pm »