line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::NDTools::NDProc::Module::JsonPatch; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
22
|
use strict; |
|
3
|
|
|
|
|
17
|
|
|
3
|
|
|
|
|
134
|
|
4
|
3
|
|
|
3
|
|
19
|
use warnings FATAL => 'all'; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
132
|
|
5
|
3
|
|
|
3
|
|
23
|
use parent 'App::NDTools::NDProc::Module'; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
19
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
195
|
use App::NDTools::Util qw(chomp_evaled_error); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
164
|
|
8
|
3
|
|
|
3
|
|
1389
|
use JSON::Patch 0.04 qw(patch); |
|
3
|
|
|
|
|
8520
|
|
|
3
|
|
|
|
|
209
|
|
9
|
3
|
|
|
3
|
|
25
|
use Log::Log4Cli; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
253
|
|
10
|
3
|
|
|
3
|
|
19
|
use Struct::Path 0.80 qw(path); |
|
3
|
|
|
|
|
60
|
|
|
3
|
|
|
|
|
1106
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
0
|
6
|
sub MODINFO { "Apply JSON Patch (rfc6902) patches" } |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub arg_opts { |
17
|
11
|
|
|
11
|
0
|
20
|
my $self = shift; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
return ( |
20
|
|
|
|
|
|
|
$self->SUPER::arg_opts(), |
21
|
|
|
|
|
|
|
'source=s' => \$self->{OPTS}->{source}, |
22
|
|
|
|
|
|
|
'strict!' => \$self->{OPTS}->{strict}, |
23
|
|
|
|
|
|
|
) |
24
|
11
|
|
|
|
|
38
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub check_rule { |
27
|
7
|
|
|
7
|
0
|
13
|
my ($self, $rule) = @_; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
die_fatal "Source file should be specified", 1 |
30
|
7
|
100
|
|
|
|
25
|
unless ($rule->{source}); |
31
|
|
|
|
|
|
|
|
32
|
6
|
100
|
|
|
|
10
|
push @{$rule->{path}}, '' unless (@{$rule->{path}}); |
|
2
|
|
|
|
|
6
|
|
|
6
|
|
|
|
|
22
|
|
33
|
|
|
|
|
|
|
|
34
|
6
|
|
|
|
|
19
|
return $self; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub configure { |
38
|
26
|
|
|
26
|
0
|
50
|
my $self = shift; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# to prevent source resolve to target (ndproc defaults) |
41
|
|
|
|
|
|
|
delete $self->{OPTS}->{source} |
42
|
26
|
100
|
|
|
|
99
|
unless (defined $self->{OPTS}->{source}); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub process_path { |
46
|
6
|
|
|
6
|
0
|
23
|
my ($self, $data, $path, $spath, $opts, $source) = @_; |
47
|
|
|
|
|
|
|
|
48
|
6
|
|
|
|
|
10
|
my @refs = eval { path(${$data}, $spath, strict => $opts->{strict}) }; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
33
|
|
49
|
6
|
100
|
|
|
|
730
|
die_fatal "Failed to lookup path '$path'", 4 if ($@); |
50
|
|
|
|
|
|
|
|
51
|
5
|
|
|
|
|
12
|
for (@refs) { |
52
|
5
|
|
|
|
|
10
|
eval { patch(${$_}, $source) }; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
26
|
|
53
|
5
|
100
|
|
|
|
2252
|
die_fatal chomp_evaled_error($@), 8 if ($@); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; # End of App::NDTools::NDProc::Module::JsonPatch |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__END__ |