line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
41765
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
43
|
|
2
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
66
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package PowerShell::Pipeline; |
5
|
|
|
|
|
|
|
$PowerShell::Pipeline::VERSION = '1.00'; |
6
|
|
|
|
|
|
|
# ABSTRACT: Wraps powershell cmdlet pipeline |
7
|
|
|
|
|
|
|
# PODNAME: PowerShell::Pipeline |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
6
|
use Carp; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
165
|
|
10
|
2
|
|
|
2
|
|
609
|
use PowerShell::Cmdlet; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
421
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
5
|
|
|
5
|
1
|
14155
|
return bless( {}, shift )->_init(@_); |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub add { |
17
|
8
|
|
|
8
|
1
|
12
|
my ( $self, $cmdlet, @parameters ) = @_; |
18
|
|
|
|
|
|
|
|
19
|
8
|
|
|
|
|
5
|
delete( $self->{command} ); #clear cached command |
20
|
|
|
|
|
|
|
|
21
|
8
|
100
|
66
|
|
|
35
|
unless ( ref($cmdlet) && $cmdlet->isa('PowerShell::Cmdlet') ) { |
22
|
4
|
|
|
|
|
9
|
$cmdlet = PowerShell::Cmdlet->new($cmdlet); |
23
|
4
|
|
|
|
|
5
|
foreach my $parameter (@parameters) { |
24
|
2
|
|
|
|
|
3
|
my $ref = ref($parameter); |
25
|
2
|
100
|
66
|
|
|
14
|
if ( !$ref || $ref eq 'SCALAR' ) { |
|
|
50
|
33
|
|
|
|
|
26
|
1
|
|
|
|
|
3
|
$cmdlet->parameter($parameter); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
elsif ( $ref eq 'ARRAY' && scalar(@$parameter) == 2 ) { |
29
|
1
|
|
|
|
|
2
|
$cmdlet->parameter(@$parameter); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
else { |
32
|
0
|
|
|
|
|
0
|
croak('inline parameters must be name value array ref, or scalar value'); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
8
|
|
|
|
|
7
|
push( @{ $self->{pipeline} }, $cmdlet ); |
|
8
|
|
|
|
|
12
|
|
38
|
|
|
|
|
|
|
|
39
|
8
|
|
|
|
|
24
|
return $self; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub _init { |
43
|
5
|
|
|
5
|
|
7
|
my ($self) = @_; |
44
|
|
|
|
|
|
|
|
45
|
5
|
|
|
|
|
9
|
$self->{pipeline} = []; |
46
|
|
|
|
|
|
|
|
47
|
5
|
|
|
|
|
17
|
return $self; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub command { |
51
|
5
|
|
|
5
|
1
|
5
|
my ($self) = @_; |
52
|
5
|
50
|
|
|
|
11
|
unless ( $self->{command} ) { |
53
|
5
|
|
|
|
|
4
|
$self->{command} = join( '|', map { $_->command() } @{ $self->{pipeline} } ); |
|
8
|
|
|
|
|
15
|
|
|
5
|
|
|
|
|
6
|
|
54
|
|
|
|
|
|
|
} |
55
|
5
|
|
|
|
|
16
|
return $self->{command}; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__ |