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