blib/lib/ExtUtils/Builder/Action/Command.pm

filter: Statementstmt 95.0% 38 / 40 Branchbran 72.2% 13 / 18 Conditioncond 40.0% 4 / 10 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 8 / 8 Podpod 100% 3 / 3 totaltotal 79.5% 66 / 83 CC 11 SCAR 18.2
CC
11
Cov
81%
execute
10.9
to_code
2.0
to_command
2.0
CRAP 6.2
« blib/lib/ExtUtils/Builder/Util.pm ↑ Summary blib/lib/ExtUtils/Builder/Plan.pm »
1 package ExtUtils::Builder::Action::Command;
2 5 $ExtUtils::Builder::Action::Command::VERSION = '0.020';
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 5 ▶use parent 'ExtUtils::Builder::Action::Primitive';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶sub _preference_map {
Subroutine _preference_map: called CC=1 SCAR=0.0
9 return {
10 2 command => 3,
11 execute => 2,
12 code => 1,
13 flatten => 0,
14 };
15 }
16  
17 2 ▶sub to_code {
Subroutine to_code: called CC=2 SCAR=6.9
Pod documented
18 2 my ($self, %args) = @_;
19 2 require Data::Dumper;
20 2 ▶ if (ref $self->{command}) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->{'command'}) { } 1 1 2
21 1 my $serialized = Data::Dumper->new([$self->{command}])->Terse(1)->Indent(0)->Dump;
22 1 $serialized =~ s/ \A \[ (.*?) \] \z /$1/xms;
23 1 return qq{system($serialized) and die "Could not run command " . join ' ', $serialized};
24 } else {
25 1 my $serialized = Data::Dumper->new([$self->{command}])->Terse(1)->Indent(0)->Dump;
26 1 return qq{system($serialized) and die "Could not run command $serialized"};
27 }
28 }
29  
30 3 ▶sub to_command {
Subroutine to_command: called CC=2 SCAR=6.9
Pod documented
31 3 my $self = shift;
32 3 ▶ return ref $self->{command} ? [ @{ $self->{command} } ] : $self->{command};
Branch: 1 branch
BranchTrueFalseTotal
ref $self->{'command'} ? : 2 1 3
33 }
34  
35 0 ▶my $quote = $^O eq 'MSWin32' ? do { require Win32::ShellQuote; \&Win32::ShellQuote::quote_system_list } : sub { @_ };
Subroutine __ANON__: called CC=1 SCAR=1.2
Branch: 1 branch
BranchTrueFalseTotal
$^O eq 'MSWin32' ? : 0 5 5
36 3 ▶sub execute {
Subroutine execute: called CC=9 SCAR=23.9
Pod documented
37 3 my ($self, %opts) = @_;
38 3 ▶ if (ref $self->{command}) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->{'command'}) { } 2 1 3
39 2 my @command = @{ $self->{command} };
40 2 ▶ my $message = join ' ', map { my $arg = $_; $arg =~ s/ (?= ['#] ) /\\/gx ? "'$arg'" : $arg } @command;
Branch: 1 branch
BranchTrueFalseTotal
$arg =~ s/ (?= ['#] ) /\\/gx ? : 0 4 4
41 2 ▶ print "$message\n" if not $opts{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $opts{"quiet"} 1 1 2
42 2 ▶ system($quote->(@command)) and die "Could not run command @command" if not $opts{dry_run};
Branch: 1 branch
BranchTrueFalseTotal
unless $opts{"dry_run"} 2 0 2
Condition40%2/5
$opts{'dry_run'} || system(&$quote(@command)) && die("Could not run command @command")
l!l&&r!l&&!r
020
system &$quote(@command) and die "Could not run command @command"
!ll
20
MC/DC0%0/2
$opts{'dry_run'} || system(&$quote(@command)) && die("Could not run command @command")
$opts{'dry_run'} system &$quote(@command)
Truth table0%0/3
A || B
A= $opts{'dry_run'}B= system &$quote(@command)
ABresult
1X1
011
000
43 } else {
44 1 my $command = $self->{command};
45 1 ▶ print "$command\n" if not $opts{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $opts{"quiet"} 1 0 1
46 1 ▶ system($command) and die "Could not run command $command" if not $opts{dry_run};
Branch: 1 branch
BranchTrueFalseTotal
unless $opts{"dry_run"} 1 0 1
Condition40%2/5
$opts{'dry_run'} || system($command) && die("Could not run command $command")
l!l&&r!l&&!r
010
system $command and die "Could not run command $command"
!ll
10
MC/DC0%0/2
$opts{'dry_run'} || system($command) && die("Could not run command $command")
$opts{'dry_run'} system $command
Truth table0%0/3
A || B
A= $opts{'dry_run'}B= system $command
ABresult
1X1
011
000
47 }
48 3 return;
49 }
50  
51 5 1;
52  
53 #ABSTRACT: An action object for external commands
54  
55 __END__
« blib/lib/ExtUtils/Builder/Util.pm ↑ Summary blib/lib/ExtUtils/Builder/Plan.pm »