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