| 1 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||
| 4 | package PowerShell::Pipeline; | ||||||||||||||||||||||||||||||||
| 5 | 2 | $PowerShell::Pipeline::VERSION = '1.00'; | |||||||||||||||||||||||||||||||
| 6 | # ABSTRACT: Wraps powershell cmdlet pipeline | ||||||||||||||||||||||||||||||||
| 7 | # PODNAME: PowerShell::Pipeline | ||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use PowerShell::Cmdlet; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | 5 | ▶ | sub new { | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 13 | 5 | return bless( {}, shift )->_init(@_); | |||||||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||
| 16 | 8 | ▶ | sub add { | ||||||||||||||||||||||||||||||
|
Subroutine
add: called CC=8 SCAR=21.6
Pod
documented
| |||||||||||||||||||||||||||||||||
| 17 | 8 | my ( $self, $cmdlet, @parameters ) = @_; | |||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||
| 19 | 8 | delete( $self->{command} ); #clear cached command | |||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||
| 21 | 8 | ▶ | unless ( ref($cmdlet) && $cmdlet->isa('PowerShell::Cmdlet') ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $cmdlet and $cmdlet->isa("PowerShell::Cmdlet")
MC/DC50%1/2
ref $cmdlet and $cmdlet->isa("PowerShell::Cmdlet")
ref $cmdlet
$cmdlet->isa("PowerShell::Cmdlet")
Truth table66%2/3
A and B
A= ref $cmdletB= $cmdlet->isa("PowerShell::Cmdlet")
| |||||||||||||||||||||||||||||||||
| 22 | 4 | $cmdlet = PowerShell::Cmdlet->new($cmdlet); | |||||||||||||||||||||||||||||||
| 23 | 4 | foreach my $parameter (@parameters) { | |||||||||||||||||||||||||||||||
| 24 | 2 | my $ref = ref($parameter); | |||||||||||||||||||||||||||||||
| 25 | 2 | ▶ | if ( !$ref || $ref eq 'SCALAR' ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
not $ref or $ref eq "SCALAR"
MC/DC50%1/2
not $ref or $ref eq "SCALAR"
not $ref
$ref eq "SCALAR"
Truth table66%2/3
not(A) or B
A= not $refB= $ref eq "SCALAR"
| |||||||||||||||||||||||||||||||||
| 26 | 1 | $cmdlet->parameter($parameter); | |||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||
| 28 | ▶ | elsif ( $ref eq 'ARRAY' && scalar(@$parameter) == 2 ) { | |||||||||||||||||||||||||||||||
|
Condition33%1/3
$ref eq "ARRAY" and scalar @$parameter == 2
MC/DC0%0/2
$ref eq "ARRAY" and scalar @$parameter == 2
$ref eq "ARRAY"
scalar @$parameter == 2
Truth table33%1/3
A and B
A= $ref eq "ARRAY"B= scalar @$parameter == 2
| |||||||||||||||||||||||||||||||||
| 29 | 1 | $cmdlet->parameter(@$parameter); | |||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||
| 31 | else { | ||||||||||||||||||||||||||||||||
| 32 | 0 | croak('inline parameters must be name value array ref, or scalar value'); | |||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||
| 37 | 8 | push( @{ $self->{pipeline} }, $cmdlet ); | |||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||
| 39 | 8 | return $self; | |||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||
| 42 | 5 | ▶ | sub _init { | ||||||||||||||||||||||||||||||
|
Subroutine
_init: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 43 | 5 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||
| 45 | 5 | $self->{pipeline} = []; | |||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||
| 47 | 5 | return $self; | |||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||
| 50 | 5 | ▶ | sub command { | ||||||||||||||||||||||||||||||
|
Subroutine
command: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 51 | 5 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 52 | 5 | ▶ | unless ( $self->{command} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 53 | 5 | $self->{command} = join( '|', map { $_->command() } @{ $self->{pipeline} } ); | |||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||
| 55 | 5 | return $self->{command}; | |||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||
| 58 | 2 | 1; | |||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||
| 60 | __END__ | ||||||||||||||||||||||||||||||||