line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::NDTools::NDProc::Module::Pipe; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
71808
|
use strict; |
|
2
|
|
|
|
|
17
|
|
|
2
|
|
|
|
|
68
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings FATAL => 'all'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
68
|
|
5
|
2
|
|
|
2
|
|
588
|
use parent 'App::NDTools::NDProc::Module'; |
|
2
|
|
|
|
|
326
|
|
|
2
|
|
|
|
|
21
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
1261
|
use IPC::Run3; |
|
2
|
|
|
|
|
41197
|
|
|
2
|
|
|
|
|
111
|
|
8
|
2
|
|
|
2
|
|
15
|
use Log::Log4Cli; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
159
|
|
9
|
2
|
|
|
2
|
|
23
|
use App::NDTools::Slurp qw(s_decode s_encode); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
123
|
|
10
|
2
|
|
|
2
|
|
13
|
use Struct::Path 0.80 qw(path); |
|
2
|
|
|
|
|
41
|
|
|
2
|
|
|
|
|
98
|
|
11
|
2
|
|
|
2
|
|
12
|
use Struct::Path::PerlStyle 0.80 qw(str2path); |
|
2
|
|
|
|
|
29
|
|
|
2
|
|
|
|
|
1167
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
0
|
0
|
|
sub MODINFO { "Modify structure using external process" } |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub arg_opts { |
18
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
return ( |
21
|
|
|
|
|
|
|
$self->SUPER::arg_opts(), |
22
|
|
|
|
|
|
|
'command|cmd=s' => \$self->{OPTS}->{command}, |
23
|
|
|
|
|
|
|
'preserve=s@' => \$self->{OPTS}->{preserve}, |
24
|
|
|
|
|
|
|
'strict' => \$self->{OPTS}->{strict}, |
25
|
|
|
|
|
|
|
) |
26
|
0
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub check_rule { |
29
|
0
|
|
|
0
|
0
|
|
my ($self, $rule) = @_; |
30
|
0
|
|
|
|
|
|
my $out = $self; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# process full source if no paths defined # FIXME: move it to parent and make common for all mods |
33
|
0
|
0
|
|
|
|
|
push @{$rule->{path}}, '' unless (@{$rule->{path}}); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
0
|
0
|
|
|
|
|
unless (defined $rule->{command}) { |
36
|
0
|
|
|
0
|
|
|
log_error { 'Command to run should be defined' }; |
|
0
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
$out = undef; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
return $out; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub process_path { |
44
|
0
|
|
|
0
|
0
|
|
my ($self, $data, $path, $opts) = @_; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my $spath = eval { str2path($path) }; |
|
0
|
|
|
|
|
|
|
47
|
0
|
0
|
|
|
|
|
die_fatal "Failed to parse path ($@)", 4 if ($@); |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my @refs = eval { path(${$data}, $spath, strict => $opts->{strict}) }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
50
|
0
|
0
|
|
|
|
|
die_fatal "Failed to lookup path '$path'", 4 if ($@); |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
for my $r (@refs) { |
53
|
0
|
|
|
|
|
|
my $in = s_encode(${$r}, 'JSON', { pretty => 1 }); |
|
0
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my ($out, $err); |
56
|
0
|
|
|
|
|
|
run3($opts->{command}, \$in, \$out, \$err, { return_if_system_error => 1}); |
57
|
0
|
0
|
|
|
|
|
die_fatal "Failed to run '$opts->{command}' ($!)", 2 |
58
|
|
|
|
|
|
|
if ($? == -1); # run3 specific |
59
|
0
|
0
|
|
|
|
|
unless ($? == 0) { |
60
|
0
|
0
|
|
|
|
|
die_fatal "'$opts->{command}' exited with " . ($? >> 8) . |
61
|
|
|
|
|
|
|
($err ? " (" . join(" ", split("\n", $err)) . ")" : ""), 16; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
${$r} = s_decode($out, 'JSON'); |
|
0
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; # End of App::NDTools::NDProc::Module::Pipe |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |