Callback/Command.pm

filter: Statementstmt 89.9% 152 / 169 Branchbran 81.9% 77 / 94 Conditioncond 65.1% 28 / 43 MC/DCmcdc 40.7% 11 / 27 Subroutinesub 100% 27 / 27 Podpod 90.0% 9 / 10 totaltotal 82.1% 304 / 370 CC 65 SCAR 23.5
CC
65
Cov
84%
clone
20.8
__ANON__
15.9
cp_command
14.1
CRAP 10.5
« Callback/CommandFailedException.pm ↑ Summary Callback/CommandRunner.pm »
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package IPC::Open3::Callback::Command;
5 1 $IPC::Open3::Callback::Command::VERSION = '1.18';
6 # ABSTRACT: A utility class that provides subroutines for building shell command strings.
7  
8 1 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 our @EXPORT_OK =
10 qw(batch_command command command_options cp_command mkdir_command pipe_command rm_command sed_command write_command);
11  
12 1 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 sub batch_command {
15 13 ▶ my ( @commands, $batch_options, $command_options );
Subroutine batch_command: called CC=5 SCAR=16.1
Pod documented
16 13 (@commands) = @_;
17 13 ▶ $command_options = pop(@commands)
Branch: 1 branch
BranchTrueFalseTotal
if ref $commands[$#commands] eq "IPC::Open3::Callback::Command::CommandOptions" 7 6 13
18 if ( ref( $commands[$#commands] ) eq 'IPC::Open3::Callback::Command::CommandOptions' );
19 13 ▶ $batch_options = pop(@commands) if ( ref( $commands[$#commands] ) eq 'HASH' );
Branch: 1 branch
BranchTrueFalseTotal
if ref $commands[$#commands] eq "HASH" 3 10 13
20  
21 13 ▶ push( @commands, $command_options ) if ($command_options);
Branch: 1 branch
BranchTrueFalseTotal
if $command_options 7 6 13
22  
23 wrap(
24 $batch_options || {},
25 @commands,
26 sub {
27 13 ▶ return @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
28 }
29 13 ▶ );
Condition100%2/2
$batch_options || {}
l!l
310
MC/DC100%1/1
$batch_options || {}
$batch_options
Truth table100%2/2
A
A= $batch_options
Aresult
11
00
30 }
31  
32 sub command_options {
33 40 ▶ return IPC::Open3::Callback::Command::CommandOptions->new(@_);
Subroutine command_options: called CC=1 SCAR=0.0
Pod documented
34 }
35  
36 sub command {
37 wrap(
38 {},
39 @_,
40 sub {
41 31 ▶ return shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
42 }
43 31 ▶ );
Subroutine command: called CC=1 SCAR=0.0
Pod documented
44 }
45  
46 sub cp_command {
47 13 ▶ my ( $source_path, $source_command_options, $destination_path, $destination_command_options,
Subroutine cp_command: called CC=14 SCAR=26.5
Pod documented
48 %cp_options );
49 13 $source_path = _escape_path(shift);
50 13 ▶ $source_command_options = shift
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[0] eq "IPC::Open3::Callback::Command::CommandOptions" 8 5 13
51 if ( ref( $_[0] ) eq 'IPC::Open3::Callback::Command::CommandOptions' );
52 13 $destination_path = _escape_path(shift);
53 13 ▶ $destination_command_options = shift
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[0] eq "IPC::Open3::Callback::Command::CommandOptions" 7 6 13
54 if ( ref( $_[0] ) eq 'IPC::Open3::Callback::Command::CommandOptions' );
55 13 %cp_options = @_;
56  
57 13 ▶ $source_command_options = command_options() if ( !$source_command_options );
Branch: 1 branch
BranchTrueFalseTotal
unless $source_command_options 5 8 13
58 13 ▶ $destination_command_options = command_options() if ( !$destination_command_options );
Branch: 1 branch
BranchTrueFalseTotal
unless $destination_command_options 6 7 13
59  
60 13 my $source_command;
61 my $destination_command;
62 13 ▶ if ( $cp_options{file} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cp_options{'file'}) { } 6 7 13
63  
64 # is a file, so use cat | dd
65 6 ▶ if ( $cp_options{compress} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cp_options{'compress'}) { } 1 5 6
66 1 $source_command = command( "gzip -c $source_path", $source_command_options );
67 1 $destination_command =
68 pipe_command( "gunzip", "dd of=$destination_path", $destination_command_options );
69 }
70 else {
71 5 $source_command = command( "cat $source_path", $source_command_options );
72 5 $destination_command =
73 command( "dd of=$destination_path", $destination_command_options );
74 }
75 }
76 else {
77 # is a directory, so use tar or unzip
78 7 ▶ if ( $cp_options{archive} && $cp_options{archive} eq 'zip' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cp_options{'archive'} and $cp_options{'archive'} eq 'zip') { } 2 5 7
Condition66%2/3
$cp_options{"archive"} and $cp_options{"archive"} eq "zip"
!ll&&!rl&&r
502
MC/DC50%1/2
$cp_options{"archive"} and $cp_options{"archive"} eq "zip"
$cp_options{"archive"} $cp_options{"archive"} eq "zip"
Truth table66%2/3
A and B
A= $cp_options{"archive"}B= $cp_options{"archive"} eq "zip"
ABresult
0X0
100
111
79 my $temp_zip = File::Spec->catfile( $destination_path,
80 2 ▶ $cp_options{unzip_temp_file} || "temp_cp_command.zip" );
Condition50%1/2
$cp_options{'unzip_temp_file'} || 'temp_cp_command.zip'
l!l
02
MC/DC0%0/1
$cp_options{'unzip_temp_file'} || 'temp_cp_command.zip'
$cp_options{'unzip_temp_file'}
Truth table50%1/2
A
A= $cp_options{'unzip_temp_file'}
Aresult
11
00
81 2 $source_command =
82 command(
83 batch_command( "cd $source_path", "zip -qr - .", { subshell => "bash -c " } ),
84 $source_command_options );
85 2 $destination_command = batch_command(
86 "dd of=$temp_zip", "unzip -qod $destination_path $temp_zip",
87 rm_command($temp_zip), $destination_command_options
88 );
89 }
90 else {
91 # default, use tar
92 5 my @parts = ("tar c -C $source_path .");
93 5 my @destination_parts = ();
94 5 ▶ if ( $cp_options{status} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cp_options{"status"}) 1 4 5
95 1 ▶ push(
Condition33%1/3
$source_command_options && $source_command_options->get_sudo_username
!ll&&!rl&&r
001
MC/DC0%0/2
$source_command_options && $source_command_options->get_sudo_username
$source_command_options $source_command_options->get_sudo_username
Truth table33%1/3
A && B
A= $source_command_optionsB= $source_command_options->get_sudo_username
ABresult
0X0
100
111
96 @parts,
97 join(
98 '',
99 'pv -f -s `',
100 _sudo_command(
101 $source_command_options
102 && $source_command_options->get_sudo_username(),
103 pipe_command( "du -sb $source_path", 'cut -f1' )
104 ),
105 '`'
106 )
107 );
108 }
109 5 ▶ if ( $cp_options{compress} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cp_options{"compress"}) 2 3 5
110 2 push( @parts, 'gzip' );
111 2 push( @destination_parts, 'gunzip' );
112 }
113 push(
114 5 ▶ @destination_parts,
Condition66%2/3
$destination_command_options && $destination_command_options->get_sudo_username
!ll&&!rl&&r
023
MC/DC50%1/2
$destination_command_options && $destination_command_options->get_sudo_username
$destination_command_options $destination_command_options->get_sudo_username
Truth table66%2/3
A && B
A= $destination_command_optionsB= $destination_command_options->get_sudo_username
ABresult
0X0
100
111
115 _sudo_command(
116 $destination_command_options
117 && $destination_command_options->get_sudo_username(),
118 "tar x -C $destination_path"
119 )
120 );
121  
122 5 $source_command = command( pipe_command(@parts), $source_command_options );
123 5 $destination_command = command( pipe_command(@destination_parts),
124 $destination_command_options->clone( sudo_username => undef ) );
125 }
126 }
127  
128 13 return pipe_command( $source_command, $destination_command );
129 }
130  
131 sub mkdir_command {
132 wrap(
133 {},
134 @_,
135 sub {
136 1 ▶ return 'mkdir -p "' . join( '" "', @_ ) . '"';
Subroutine __ANON__: called CC=1 SCAR=0.0
137 }
138 1 ▶ );
Subroutine mkdir_command: called CC=1 SCAR=0.0
Pod documented
139 }
140  
141 sub pipe_command {
142 wrap(
143 { command_separator => '|' },
144 @_,
145 sub {
146 32 ▶ return @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
147 }
148 32 ▶ );
Subroutine pipe_command: called CC=1 SCAR=0.0
Pod documented
149 }
150  
151 sub _quote_command {
152 32 ▶ my ($command) = @_;
Subroutine _quote_command: called CC=1 SCAR=0.0
153 32 $command =~ s/\\/\\\\/g;
154 32 $command =~ s/`/\\`/g; # for `command`
155 32 $command =~ s/"/\\"/g;
156 32 return "\"$command\"";
157 }
158  
159 sub _escape_path {
160 26 ▶ my ($path) = @_;
Subroutine _escape_path: called CC=1 SCAR=0.0
161 26 $path =~ s/(['"`\s])/\\$1/g;
162 26 return $path;
163 }
164  
165 sub rm_command {
166 wrap(
167 {},
168 @_,
169 sub {
170 4 ▶ return 'rm -rf "' . join( '" "', @_ ) . '"';
Subroutine __ANON__: called CC=1 SCAR=0.0
171 }
172 4 ▶ );
Subroutine rm_command: called CC=1 SCAR=0.0
Pod documented
173 }
174  
175 sub sed_command {
176 wrap(
177 {},
178 @_,
179 sub {
180 2 ▶ my @args = @_;
Subroutine __ANON__: called CC=9 SCAR=27.6
181 2 my $options = {};
182  
183 2 ▶ if ( ref( $args[$#args] ) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $args[$#args] eq "HASH") 1 1 2
184 1 $options = pop(@args);
185 }
186  
187 2 my $command = 'sed';
188 2 ▶ $command .= ' -i' if ( $options->{in_place} );
Branch: 1 branch
BranchTrueFalseTotal
if $options->{"in_place"} 0 2 2
189 2 ▶ if ( defined( $options->{temp_script_file} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $options->{'temp_script_file'}) { } 0 2 2
190 0 my $temp_script_file_name = $options->{temp_script_file}->filename();
191 0 ▶ print( { $options->{temp_script_file} } join( ' ', '', map {"$_;"} @args ) )
Branch: 1 branch
BranchTrueFalseTotal
if scalar @args 0 0 0
192 if ( scalar(@args) );
193 print(
194 0 { $options->{temp_script_file} } join( ' ',
195 '',
196 0 map {"s/$_/$options->{replace_map}{$_}/g;"}
197 0 keys( %{ $options->{replace_map} } ) )
198 0 ▶ ) if ( defined( $options->{replace_map} ) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $options->{"replace_map"} 0 0 0
199 0 $options->{temp_script_file}->flush();
200 0 $command .= " -f $temp_script_file_name";
201 }
202 else {
203 2 ▶ $command .= join( ' ', '', map {"-e '$_'"} @args ) if ( scalar(@args) );
Branch: 1 branch
BranchTrueFalseTotal
if scalar @args 1 1 2
204 $command .= join( ' ',
205 '',
206 1 map {"-e 's/$_/$options->{replace_map}{$_}/g'"}
207 1 keys( %{ $options->{replace_map} } ) )
208 2 ▶ if ( defined( $options->{replace_map} ) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $options->{"replace_map"} 1 1 2
209 }
210 2 ▶ $command .= join( ' ', '', @{ $options->{files} } ) if ( $options->{files} );
Branch: 1 branch
BranchTrueFalseTotal
if $options->{"files"} 0 2 2
211  
212 2 return $command;
213 }
214 2 ▶ );
Subroutine sed_command: called CC=1 SCAR=0.0
Pod documented
215 }
216  
217 sub _sudo_command {
218 132 ▶ my ( $sudo_username, $command ) = @_;
Subroutine _sudo_command: called CC=3 SCAR=11.0
219 132 ▶ if ( defined($sudo_username) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $sudo_username) 24 108 132
220 24 ▶ $command = "sudo " . ( $sudo_username ? "-u $sudo_username " : '' ) . $command;
Branch: 1 branch
BranchTrueFalseTotal
$sudo_username ? : 22 2 24
221 }
222 132 return $command;
223 }
224  
225 sub write_command {
226 5 ▶ my ( $filename, @lines, $write_options, $command_options );
Subroutine write_command: called CC=10 SCAR=23.4
Pod documented
227 5 $filename = shift;
228 5 @lines = @_;
229 5 ▶ $command_options = pop(@lines)
Branch: 1 branch
BranchTrueFalseTotal
if ref $lines[$#lines] eq "IPC::Open3::Callback::Command::CommandOptions" 4 1 5
230 if ( ref( $lines[$#lines] ) eq 'IPC::Open3::Callback::Command::CommandOptions' );
231 5 ▶ $write_options = pop(@lines) if ( ref( $lines[$#lines] ) eq 'HASH' );
Branch: 1 branch
BranchTrueFalseTotal
if ref $lines[$#lines] eq "HASH" 3 2 5
232  
233 5 my $remote_command = "dd of=$filename";
234 5 ▶ if ( defined($write_options) && defined( $write_options->{mode} ) ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $write_options and defined $write_options->{'mode'}) { } 3 2 5
elsif (defined $command_options) { } 1 1 2
Condition66%2/3
defined $write_options and defined $write_options->{"mode"}
!ll&&!rl&&r
203
MC/DC50%1/2
defined $write_options and defined $write_options->{"mode"}
defined $write_options defined $write_options->{"mode"}
Truth table66%2/3
A and B
A= defined $write_optionsB= defined $write_options->{"mode"}
ABresult
0X0
100
111
235 3 ▶ if ( defined($command_options) ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $command_options) { } 3 0 3
elsif (defined $command_options) { } 0 0 0
236 3 $remote_command =
237 batch_command( $remote_command, "chmod $write_options->{mode} $filename",
238 $command_options );
239 }
240 elsif ( defined($command_options) ) {
241 0 $remote_command =
242 batch_command( $remote_command, "chmod $write_options->{mode} $filename" );
243 }
244 }
245 elsif ( defined($command_options) ) {
246 1 $remote_command = command( $remote_command, $command_options );
247 }
248  
249 my $line_separator =
250 ( defined($write_options) && defined( $write_options->{line_separator} ) )
251 ? $write_options->{line_separator}
252 5 ▶ : '\n';
Branch: 1 branch
BranchTrueFalseTotal
defined $write_options && defined $write_options->{'line_separator'} ? : 2 3 5
Condition100%3/3
defined $write_options and defined $write_options->{"line_separator"}
!ll&&!rl&&r
212
MC/DC100%2/2
defined $write_options and defined $write_options->{"line_separator"}
defined $write_options defined $write_options->{"line_separator"}
Truth table100%3/3
A and B
A= defined $write_optionsB= defined $write_options->{"line_separator"}
ABresult
0X0
100
111
253 5 return pipe_command( 'printf "' . join( $line_separator, @lines ) . '"', $remote_command );
254 }
255  
256 # Handles wrapping commands with possible ssh and command prefix
257 sub wrap {
258 83 ▶ my $wrap_options = shift;
Subroutine wrap: called CC=14 SCAR=26.4
Pod undocumented
259 83 my $builder = pop;
260 83 my @args = @_;
261 83 my ( $ssh, $username, $hostname, $sudo_username, $pretty );
262  
263 83 ▶ if ( ref( $args[$#args] ) eq 'IPC::Open3::Callback::Command::CommandOptions' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $args[$#args] eq "IPC::Open3::Callback::Command::CommandOptions") 40 43 83
264 40 my $options = pop(@args);
265 40 ▶ $ssh = $options->get_ssh() || 'ssh';
Condition100%2/2
$options->get_ssh || 'ssh'
l!l
139
MC/DC100%1/1
$options->get_ssh || 'ssh'
$options->get_ssh
Truth table100%2/2
A
A= $options->get_ssh
Aresult
11
00
266 40 $username = $options->get_username();
267 40 $hostname = $options->get_hostname();
268 40 $sudo_username = $options->get_sudo_username();
269 40 $pretty = $options->get_pretty();
270 }
271  
272 83 my $destination_command = '';
273 83 ▶ my $command_separator = $wrap_options->{command_separator} || ';';
Condition100%2/2
$wrap_options->{'command_separator'} || ';'
l!l
3251
MC/DC100%1/1
$wrap_options->{'command_separator'} || ';'
$wrap_options->{'command_separator'}
Truth table100%2/2
A
A= $wrap_options->{'command_separator'}
Aresult
11
00
274 83 my $commands = 0;
275 83 foreach my $command ( &$builder(@args) ) {
276 126 ▶ if ( defined($command) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $command) 126 0 126
277 126 ▶ if ( $commands++ > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($commands++ > 0) 43 83 126
278 43 $destination_command .= $command_separator;
279 43 ▶ if ($pretty) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pretty) 0 43 43
280 0 $destination_command .= "\n";
281 }
282 }
283  
284 126 $command =~ s/^(.*?[^\\]);$/$1/; # from find -exec
285  
286 126 $command = _sudo_command( $sudo_username, $command );
287  
288 126 $destination_command .= $command;
289 }
290 }
291  
292 83 ▶ if ( $wrap_options->{subshell} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($wrap_options->{"subshell"}) 3 80 83
293 3 $destination_command = $wrap_options->{subshell} . _quote_command($destination_command);
294 }
295  
296 83 ▶ if ( !defined($username) && !defined($hostname) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $username or defined $hostname) 54 29 83
Condition100%3/3
defined $username or defined $hostname
l!l&&r!l&&!r
52454
MC/DC100%2/2
defined $username or defined $hostname
defined $username defined $hostname
Truth table100%3/3
A or B
A= defined $usernameB= defined $hostname
ABresult
1X1
011
000
297  
298 # silly to ssh to localhost as current user, so dont
299 54 return $destination_command;
300 }
301  
302 29 ▶ my $userAt =
Branch: 2 branches
BranchTrueFalseTotal
$username ? : 5 24 29
$ssh =~ /plink(?:\.exe)?$/ ? : 1 4 5
303 $username
304 ? ( ( $ssh =~ /plink(?:\.exe)?$/ ) ? "-l $username " : "$username\@" )
305 : '';
306  
307 29 $destination_command = _quote_command($destination_command);
308 29 ▶ return "$ssh $userAt" . ( $hostname || 'localhost' ) . " $destination_command";
Condition50%1/2
$hostname || 'localhost'
l!l
290
MC/DC0%0/1
$hostname || 'localhost'
$hostname
Truth table50%1/2
A
A= $hostname
Aresult
11
00
309 }
310  
311 package IPC::Open3::Callback::Command::CommandOptions;
312 1 $IPC::Open3::Callback::Command::CommandOptions::VERSION = '1.18';
313 1 ▶use parent qw(Class::Accessor);
Subroutine BEGIN: called CC=1 SCAR=0.0
314 1 __PACKAGE__->follow_best_practice;
315 1 __PACKAGE__->mk_ro_accessors(qw(hostname pretty ssh sudo_username username));
316  
317 sub new {
318 45 ▶ my ( $class, @args ) = @_;
Subroutine new: called CC=1 SCAR=0.0
319 45 return bless( {}, $class )->_init(@args);
320 }
321  
322 sub clone {
323 5 ▶ my ( $instance, %options ) = @_;
Subroutine clone: called CC=11 SCAR=30.3
324 5 ▶ if ( exists( $instance->{hostname} ) && !exists( $options{hostname} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $instance->{"hostname"} and not exists $options{"hostname"}) 3 2 5
Condition66%2/3
exists $instance->{"hostname"} and not exists $options{"hostname"}
!ll&&!rl&&r
203
MC/DC50%1/2
exists $instance->{"hostname"} and not exists $options{"hostname"}
exists $instance->{"hostname"} not exists $options{"hostname"}
Truth table66%2/3
A and not(B)
A= exists $instance->{"hostname"}B= not exists $options{"hostname"}
ABresult
0X0
100
111
325 3 $options{hostname} = $instance->{hostname};
326 }
327 5 ▶ if ( exists( $instance->{ssh} ) && !exists( $options{ssh} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $instance->{"ssh"} and not exists $options{"ssh"}) 0 5 5
Condition33%1/3
exists $instance->{"ssh"} and not exists $options{"ssh"}
!ll&&!rl&&r
500
MC/DC0%0/2
exists $instance->{"ssh"} and not exists $options{"ssh"}
exists $instance->{"ssh"} not exists $options{"ssh"}
Truth table33%1/3
A and not(B)
A= exists $instance->{"ssh"}B= not exists $options{"ssh"}
ABresult
0X0
100
111
328 0 $options{ssh} = $instance->{ssh};
329 }
330 5 ▶ if ( exists( $instance->{username} ) && !exists( $options{username} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $instance->{"username"} and not exists $options{"username"}) 0 5 5
Condition33%1/3
exists $instance->{"username"} and not exists $options{"username"}
!ll&&!rl&&r
500
MC/DC0%0/2
exists $instance->{"username"} and not exists $options{"username"}
exists $instance->{"username"} not exists $options{"username"}
Truth table33%1/3
A and not(B)
A= exists $instance->{"username"}B= not exists $options{"username"}
ABresult
0X0
100
111
331 0 $options{username} = $instance->{username};
332 }
333 5 ▶ if ( exists( $instance->{sudo_username} ) && !exists( $options{sudo_username} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $instance->{"sudo_username"} and not exists $options{"sudo_username"}) 0 5 5
Condition66%2/3
exists $instance->{"sudo_username"} and not exists $options{"sudo_username"}
!ll&&!rl&&r
230
MC/DC0%0/2
exists $instance->{"sudo_username"} and not exists $options{"sudo_username"}
exists $instance->{"sudo_username"} not exists $options{"sudo_username"}
Truth table66%2/3
A and not(B)
A= exists $instance->{"sudo_username"}B= not exists $options{"sudo_username"}
ABresult
0X0
100
111
334 0 $options{sudo_username} = $instance->{sudo_username};
335 }
336 5 ▶ if ( exists( $instance->{pretty} ) && !exists( $options{pretty} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $instance->{"pretty"} and not exists $options{"pretty"}) 0 5 5
Condition33%1/3
exists $instance->{"pretty"} and not exists $options{"pretty"}
!ll&&!rl&&r
500
MC/DC0%0/2
exists $instance->{"pretty"} and not exists $options{"pretty"}
exists $instance->{"pretty"} not exists $options{"pretty"}
Truth table33%1/3
A and not(B)
A= exists $instance->{"pretty"}B= not exists $options{"pretty"}
ABresult
0X0
100
111
337 0 $options{pretty} = $instance->{pretty};
338 }
339 5 return new( ref($instance), %options );
340 }
341  
342 sub _init {
343 45 ▶ my ( $self, %options ) = @_;
Subroutine _init: called CC=6 SCAR=17.9
344  
345 45 ▶ $self->{hostname} = $options{hostname} if ( defined( $options{hostname} ) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $options{"hostname"} 32 13 45
346 45 ▶ $self->{ssh} = $options{ssh} if ( defined( $options{ssh} ) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $options{"ssh"} 1 44 45
347 45 ▶ $self->{username} = $options{username} if ( defined( $options{username} ) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $options{"username"} 5 40 45
348 45 ▶ $self->{sudo_username} = $options{sudo_username} if ( defined( $options{sudo_username} ) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $options{"sudo_username"} 17 28 45
349 45 ▶ $self->{pretty} = $options{pretty} if ( defined( $options{pretty} ) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $options{"pretty"} 0 45 45
350  
351 45 return $self;
352 }
353  
354 1 1;
355  
356 __END__
« Callback/CommandFailedException.pm ↑ Summary Callback/CommandRunner.pm »