line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::NDTools::NDProc::Module::JsonMergePatch; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
21
|
use strict; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
115
|
|
4
|
3
|
|
|
3
|
|
18
|
use warnings FATAL => 'all'; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
140
|
|
5
|
3
|
|
|
3
|
|
19
|
use parent 'App::NDTools::NDProc::Module'; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
19
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
192
|
use Log::Log4Cli; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
257
|
|
8
|
3
|
|
|
3
|
|
1391
|
use Struct::Diff::MergePatch qw(patch); |
|
3
|
|
|
|
|
2378
|
|
|
3
|
|
|
|
|
205
|
|
9
|
3
|
|
|
3
|
|
20
|
use Struct::Path 0.80 qw(path); |
|
3
|
|
|
|
|
48
|
|
|
3
|
|
|
|
|
1006
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
0
|
6
|
sub MODINFO { "Apply JSON Merge Patch (rfc7396) patches" } |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub arg_opts { |
16
|
9
|
|
|
9
|
0
|
18
|
my $self = shift; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
return ( |
19
|
|
|
|
|
|
|
$self->SUPER::arg_opts(), |
20
|
|
|
|
|
|
|
'source=s' => \$self->{OPTS}->{source}, |
21
|
|
|
|
|
|
|
'strict!' => \$self->{OPTS}->{strict}, |
22
|
|
|
|
|
|
|
) |
23
|
9
|
|
|
|
|
29
|
} |
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
|
|
|
|
9
|
push @{$rule->{path}}, '' unless (@{$rule->{path}}); |
|
2
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
16
|
|
32
|
|
|
|
|
|
|
|
33
|
5
|
|
|
|
|
16
|
return $self; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub configure { |
37
|
22
|
|
|
22
|
0
|
39
|
my $self = shift; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# to prevent source resolve to target (ndproc defaults) |
40
|
|
|
|
|
|
|
delete $self->{OPTS}->{source} |
41
|
22
|
100
|
|
|
|
79
|
unless (defined $self->{OPTS}->{source}); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub process_path { |
45
|
5
|
|
|
5
|
0
|
15
|
my ($self, $data, $path, $spath, $opts, $source) = @_; |
46
|
|
|
|
|
|
|
|
47
|
5
|
|
|
|
|
10
|
my @refs = eval { path(${$data}, $spath, strict => $opts->{strict}) }; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
27
|
|
48
|
5
|
100
|
|
|
|
589
|
die_fatal "Failed to lookup path '$path'", 4 if ($@); |
49
|
|
|
|
|
|
|
|
50
|
4
|
|
|
|
|
9
|
map { patch(${$_}, $source) } @refs; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
12
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; # End of App::NDTools::NDProc::Module::JsonMergePatch |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |