line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::NDTools::NDProc::Module::Pipe; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
67311
|
use strict; |
|
4
|
|
|
|
|
20
|
|
|
4
|
|
|
|
|
153
|
|
4
|
4
|
|
|
4
|
|
36
|
use warnings FATAL => 'all'; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
184
|
|
5
|
4
|
|
|
4
|
|
484
|
use parent 'App::NDTools::NDProc::Module'; |
|
4
|
|
|
|
|
311
|
|
|
4
|
|
|
|
|
27
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
2355
|
use IPC::Run3; |
|
4
|
|
|
|
|
57996
|
|
|
4
|
|
|
|
|
254
|
|
8
|
4
|
|
|
4
|
|
34
|
use Log::Log4Cli; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
361
|
|
9
|
4
|
|
|
4
|
|
28
|
use App::NDTools::Slurp qw(s_decode s_encode); |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
252
|
|
10
|
4
|
|
|
4
|
|
27
|
use Struct::Path 0.80 qw(path); |
|
4
|
|
|
|
|
95
|
|
|
4
|
|
|
|
|
2032
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.08'; |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
0
|
7
|
sub MODINFO { "Modify structure using external process" } |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub arg_opts { |
17
|
13
|
|
|
13
|
0
|
109
|
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
|
13
|
|
|
|
|
74
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub check_rule { |
27
|
9
|
|
|
9
|
0
|
26
|
my ($self, $rule) = @_; |
28
|
9
|
|
|
|
|
15
|
my $out = $self; |
29
|
|
|
|
|
|
|
|
30
|
9
|
100
|
|
|
|
16
|
push @{$rule->{path}}, '' unless (@{$rule->{path}}); |
|
3
|
|
|
|
|
14
|
|
|
9
|
|
|
|
|
34
|
|
31
|
|
|
|
|
|
|
|
32
|
9
|
100
|
|
|
|
28
|
unless (defined $rule->{command}) { |
33
|
1
|
|
|
1
|
|
6
|
log_error { 'Command to run should be defined' }; |
|
1
|
|
|
|
|
100
|
|
34
|
1
|
|
|
|
|
6
|
$out = undef; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
9
|
|
|
|
|
36
|
return $out; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub process_path { |
41
|
7
|
|
|
7
|
0
|
22
|
my ($self, $data, $path, $spath, $opts) = @_; |
42
|
|
|
|
|
|
|
|
43
|
7
|
|
|
|
|
13
|
my @refs = eval { path(${$data}, $spath, strict => $opts->{strict}) }; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
63
|
|
44
|
7
|
100
|
|
|
|
933
|
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
|
|
|
|
|
31
|
|
48
|
|
|
|
|
|
|
|
49
|
6
|
|
|
|
|
17
|
my ($out, $err); |
50
|
6
|
|
|
|
|
38
|
run3($opts->{command}, \$in, \$out, \$err, { return_if_system_error => 1}); |
51
|
6
|
50
|
|
|
|
37903
|
die_fatal "Failed to run '$opts->{command}' ($!)", 2 |
52
|
|
|
|
|
|
|
if ($? == -1); # run3 specific |
53
|
6
|
100
|
|
|
|
58
|
unless ($? == 0) { |
54
|
1
|
50
|
|
|
|
51
|
die_fatal "'$opts->{command}' exited with " . ($? >> 8) . |
55
|
|
|
|
|
|
|
($err ? " (" . join(" ", split("\n", $err)) . ")" : ""), 16; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
5
|
|
|
|
|
110
|
${$r} = s_decode($out, 'JSON'); |
|
4
|
|
|
|
|
191
|
|
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; # End of App::NDTools::NDProc::Module::Pipe |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |