PowerShell/Pipeline.pm

filter: Statementstmt 97.3% 36 / 37 Branchbran 75.0% 6 / 8 Conditioncond 55.5% 5 / 9 MC/DCmcdc 33.3% 2 / 6 Subroutinesub 100% 8 / 8 Podpod 100% 3 / 3 totaltotal 84.5% 60 / 71 CC 9 SCAR 16.0
CC
9
Cov
87%
add
8.6
command
2.0
BEGIN
1.0
CRAP 4.9
« PowerShell.pm ↑ Summary PowerShell/Cmdlet.pm »
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
BranchTrueFalseTotal
unless (ref $cmdlet and $cmdlet->isa("PowerShell::Cmdlet")) 4 4 8
Condition66%2/3
ref $cmdlet and $cmdlet->isa("PowerShell::Cmdlet")
!ll&&!rl&&r
404
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")
ABresult
0X0
100
111
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
BranchTrueFalseTotal
if (not $ref or $ref eq 'SCALAR') { } 1 1 2
elsif ($ref eq 'ARRAY' and scalar @$parameter == 2) { } 1 0 1
Condition66%2/3
not $ref or $ref eq "SCALAR"
l!l&&r!l&&!r
101
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"
ABresult
1X1
011
000
26 1 $cmdlet->parameter($parameter);
27 }
28 ▶ elsif ( $ref eq 'ARRAY' && scalar(@$parameter) == 2 ) {
Condition33%1/3
$ref eq "ARRAY" and scalar @$parameter == 2
!ll&&!rl&&r
001
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
ABresult
0X0
100
111
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
BranchTrueFalseTotal
unless ($self->{"command"}) 5 0 5
53 5 $self->{command} = join( '|', map { $_->command() } @{ $self->{pipeline} } );
54 }
55 5 return $self->{command};
56 }
57  
58 2 1;
59  
60 __END__
« PowerShell.pm ↑ Summary PowerShell/Cmdlet.pm »