| 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
| |||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||
| 39 | 2 | my @command = @{ $self->{command} }; | |||||||||||||||||||||||||||||||
| 40 | 2 | ▶ | my $message = join ' ', map { my $arg = $_; $arg =~ s/ (?= ['#] ) /\\/gx ? "'$arg'" : $arg } @command; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 41 | 2 | ▶ | print "$message\n" if not $opts{quiet}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 42 | 2 | ▶ | system($quote->(@command)) and die "Could not run command @command" if not $opts{dry_run}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition40%2/5
$opts{'dry_run'} || system(&$quote(@command)) && die("Could not run command @command")
system &$quote(@command) and die "Could not run command @command"
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)
| |||||||||||||||||||||||||||||||||
| 43 | } else { | ||||||||||||||||||||||||||||||||
| 44 | 1 | my $command = $self->{command}; | |||||||||||||||||||||||||||||||
| 45 | 1 | ▶ | print "$command\n" if not $opts{quiet}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 46 | 1 | ▶ | system($command) and die "Could not run command $command" if not $opts{dry_run}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition40%2/5
$opts{'dry_run'} || system($command) && die("Could not run command $command")
system $command and die "Could not run command $command"
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
| |||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||
| 48 | 3 | return; | |||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||
| 51 | 5 | 1; | |||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||
| 53 | #ABSTRACT: An action object for external commands | ||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||
| 55 | __END__ | ||||||||||||||||||||||||||||||||