line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::NDTools::NDPatch; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
522
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings FATAL => 'all'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
45
|
|
5
|
1
|
|
|
1
|
|
7
|
use parent 'App::NDTools::NDTool'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
56
|
use App::NDTools::Slurp qw(s_dump); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
51
|
|
8
|
1
|
|
|
1
|
|
6
|
use Log::Log4Cli; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
77
|
|
9
|
1
|
|
|
1
|
|
517
|
use Struct::Diff 0.96 qw(); |
|
1
|
|
|
|
|
6514
|
|
|
1
|
|
|
|
|
414
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.09'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub arg_opts { |
14
|
7
|
|
|
7
|
0
|
15
|
my $self = shift; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
return ( |
17
|
7
|
|
|
|
|
33
|
$self->SUPER::arg_opts(), |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub check_args { |
22
|
5
|
|
|
5
|
0
|
10
|
my $self = shift; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
die_fatal "One or two arguments expected", 1 |
25
|
5
|
100
|
66
|
|
|
9
|
if (@{$self->{ARGV}} < 1 or @{$self->{ARGV}} > 2); |
|
5
|
|
|
|
|
25
|
|
|
4
|
|
|
|
|
21
|
|
26
|
|
|
|
|
|
|
|
27
|
4
|
|
|
|
|
11
|
return $self; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub defaults { |
31
|
7
|
|
|
7
|
0
|
16
|
my $self = shift; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
return { |
34
|
7
|
|
|
|
|
12
|
%{$self->SUPER::defaults()}, |
|
7
|
|
|
|
|
25
|
|
35
|
|
|
|
|
|
|
}; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub dump { |
39
|
4
|
|
|
4
|
0
|
9
|
my ($self, $uri, $struct) = @_; |
40
|
|
|
|
|
|
|
|
41
|
4
|
|
|
0
|
|
30
|
log_debug { "Restoring structure to '$uri'" }; |
|
0
|
|
|
|
|
0
|
|
42
|
|
|
|
|
|
|
s_dump($uri, $self->{OPTS}->{ofmt}, |
43
|
4
|
|
|
|
|
41
|
{pretty => $self->{OPTS}->{pretty}}, $struct); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub exec { |
47
|
4
|
|
|
4
|
0
|
11
|
my $self = shift; |
48
|
|
|
|
|
|
|
|
49
|
4
|
|
|
|
|
6
|
my $uri = shift @{$self->{ARGV}}; |
|
4
|
|
|
|
|
9
|
|
50
|
4
|
|
|
|
|
27
|
my $struct = $self->load_struct($uri, $self->{OPTS}->{ifmt}); |
51
|
|
|
|
|
|
|
my $patch = $self->load_patch( |
52
|
4
|
|
|
|
|
12
|
@{$self->{ARGV}} ? shift @{$self->{ARGV}} : \*STDIN, |
|
4
|
|
|
|
|
20
|
|
53
|
|
|
|
|
|
|
$self->{OPTS}->{ifmt} |
54
|
4
|
50
|
|
|
|
8
|
); |
55
|
|
|
|
|
|
|
|
56
|
4
|
|
|
|
|
15
|
$self->patch($struct, $patch); |
57
|
4
|
|
|
|
|
14
|
$self->dump($uri, $struct); |
58
|
|
|
|
|
|
|
|
59
|
4
|
|
|
|
|
29
|
die_info "All done", 0; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub load_patch { |
63
|
4
|
|
|
4
|
0
|
13
|
shift->load_struct(@_); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub patch { |
67
|
4
|
|
|
4
|
0
|
13
|
my ($self, $struct, $patch) = @_; |
68
|
|
|
|
|
|
|
|
69
|
4
|
|
|
|
|
6
|
eval { Struct::Diff::patch($struct, $patch) }; |
|
4
|
|
|
|
|
16
|
|
70
|
4
|
50
|
|
|
|
391
|
die_fatal "Failed to patch structure ($@)", 8 if ($@); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; # End of App::NDTools::NDPatch |