line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::NDTools::NDProc::Module::JsonMergePatch; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
24
|
use strict; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
114
|
|
4
|
3
|
|
|
3
|
|
17
|
use warnings FATAL => 'all'; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
141
|
|
5
|
3
|
|
|
3
|
|
18
|
use parent 'App::NDTools::NDProc::Module'; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
20
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
182
|
use Log::Log4Cli; |
|
3
|
|
|
|
|
16
|
|
|
3
|
|
|
|
|
264
|
|
8
|
3
|
|
|
3
|
|
1547
|
use Struct::Diff::MergePatch qw(patch); |
|
3
|
|
|
|
|
2416
|
|
|
3
|
|
|
|
|
218
|
|
9
|
3
|
|
|
3
|
|
22
|
use Struct::Path 0.80 qw(path); |
|
3
|
|
|
|
|
50
|
|
|
3
|
|
|
|
|
1021
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
0
|
6
|
sub MODINFO { "Apply JSON Merge Patch (rfc7396) patches" } |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub arg_opts { |
16
|
10
|
|
|
10
|
0
|
26
|
my $self = shift; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
return ( |
19
|
|
|
|
|
|
|
$self->SUPER::arg_opts(), |
20
|
|
|
|
|
|
|
'source=s' => \$self->{OPTS}->{source}, |
21
|
|
|
|
|
|
|
'strict!' => \$self->{OPTS}->{strict}, |
22
|
|
|
|
|
|
|
) |
23
|
10
|
|
|
|
|
36
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub check_rule { |
26
|
6
|
|
|
6
|
0
|
13
|
my ($self, $rule) = @_; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
die_fatal "Source file should be specified", 1 |
29
|
6
|
100
|
|
|
|
19
|
unless ($rule->{source}); |
30
|
|
|
|
|
|
|
|
31
|
5
|
100
|
|
|
|
11
|
push @{$rule->{path}}, '' unless (@{$rule->{path}}); |
|
2
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
21
|
|
32
|
|
|
|
|
|
|
|
33
|
5
|
|
|
|
|
17
|
return $self; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub configure { |
37
|
23
|
|
|
23
|
0
|
45
|
my $self = shift; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# to prevent source resolve to target (ndproc defaults) |
40
|
|
|
|
|
|
|
delete $self->{OPTS}->{source} |
41
|
23
|
100
|
|
|
|
86
|
unless (defined $self->{OPTS}->{source}); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub process_path { |
45
|
5
|
|
|
5
|
0
|
16
|
my ($self, $data, $path, $spath, $opts, $source) = @_; |
46
|
|
|
|
|
|
|
|
47
|
5
|
|
|
|
|
11
|
my @refs = eval { path(${$data}, $spath, strict => $opts->{strict}) }; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
23
|
|
48
|
5
|
100
|
|
|
|
741
|
die_fatal "Failed to lookup path '$path'", 4 if ($@); |
49
|
|
|
|
|
|
|
|
50
|
4
|
|
|
|
|
8
|
map { patch(${$_}, $source) } @refs; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
14
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; # End of App::NDTools::NDProc::Module::JsonMergePatch |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |