line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::NDTools::NDProc::Module::Pipe; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
57367
|
use strict; |
|
4
|
|
|
|
|
16
|
|
|
4
|
|
|
|
|
158
|
|
4
|
4
|
|
|
4
|
|
21
|
use warnings FATAL => 'all'; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
149
|
|
5
|
4
|
|
|
4
|
|
409
|
use parent 'App::NDTools::NDProc::Module'; |
|
4
|
|
|
|
|
281
|
|
|
4
|
|
|
|
|
30
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
2106
|
use IPC::Run3; |
|
4
|
|
|
|
|
52239
|
|
|
4
|
|
|
|
|
211
|
|
8
|
4
|
|
|
4
|
|
32
|
use Log::Log4Cli; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
286
|
|
9
|
4
|
|
|
4
|
|
21
|
use App::NDTools::Slurp qw(s_decode s_encode); |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
206
|
|
10
|
4
|
|
|
4
|
|
23
|
use Struct::Path 0.80 qw(path); |
|
4
|
|
|
|
|
83
|
|
|
4
|
|
|
|
|
1687
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.07'; |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
0
|
5
|
sub MODINFO { "Modify structure using external process" } |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub arg_opts { |
17
|
11
|
|
|
11
|
0
|
24
|
my $self = shift; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
return ( |
20
|
|
|
|
|
|
|
$self->SUPER::arg_opts(), |
21
|
|
|
|
|
|
|
'command|cmd=s' => \$self->{OPTS}->{command}, |
22
|
|
|
|
|
|
|
'strict' => \$self->{OPTS}->{strict}, |
23
|
|
|
|
|
|
|
) |
24
|
11
|
|
|
|
|
49
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub check_rule { |
27
|
9
|
|
|
9
|
0
|
30
|
my ($self, $rule) = @_; |
28
|
9
|
|
|
|
|
20
|
my $out = $self; |
29
|
|
|
|
|
|
|
|
30
|
9
|
100
|
|
|
|
18
|
push @{$rule->{path}}, '' unless (@{$rule->{path}}); |
|
3
|
|
|
|
|
20
|
|
|
9
|
|
|
|
|
30
|
|
31
|
|
|
|
|
|
|
|
32
|
9
|
100
|
|
|
|
28
|
unless (defined $rule->{command}) { |
33
|
1
|
|
|
1
|
|
7
|
log_error { 'Command to run should be defined' }; |
|
1
|
|
|
|
|
200
|
|
34
|
1
|
|
|
|
|
7
|
$out = undef; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
9
|
|
|
|
|
39
|
return $out; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub process_path { |
41
|
7
|
|
|
7
|
0
|
27
|
my ($self, $data, $path, $spath, $opts) = @_; |
42
|
|
|
|
|
|
|
|
43
|
7
|
|
|
|
|
13
|
my @refs = eval { path(${$data}, $spath, strict => $opts->{strict}) }; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
69
|
|
44
|
7
|
100
|
|
|
|
1036
|
die_fatal "Failed to lookup path '$path'", 4 if ($@); |
45
|
|
|
|
|
|
|
|
46
|
6
|
|
|
|
|
14
|
for my $r (@refs) { |
47
|
6
|
|
|
|
|
12
|
my $in = s_encode(${$r}, 'JSON', { pretty => 1 }); |
|
6
|
|
|
|
|
39
|
|
48
|
|
|
|
|
|
|
|
49
|
6
|
|
|
|
|
20
|
my ($out, $err); |
50
|
6
|
|
|
|
|
50
|
run3($opts->{command}, \$in, \$out, \$err, { return_if_system_error => 1}); |
51
|
6
|
50
|
|
|
|
47706
|
die_fatal "Failed to run '$opts->{command}' ($!)", 2 |
52
|
|
|
|
|
|
|
if ($? == -1); # run3 specific |
53
|
6
|
100
|
|
|
|
78
|
unless ($? == 0) { |
54
|
1
|
50
|
|
|
|
70
|
die_fatal "'$opts->{command}' exited with " . ($? >> 8) . |
55
|
|
|
|
|
|
|
($err ? " (" . join(" ", split("\n", $err)) . ")" : ""), 16; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
5
|
|
|
|
|
130
|
${$r} = s_decode($out, 'JSON'); |
|
4
|
|
|
|
|
204
|
|
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; # End of App::NDTools::NDProc::Module::Pipe |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |