| 1 | package App::NDTools::NDPatch; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use parent 'App::NDTools::NDTool'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use App::NDTools::Slurp qw(s_dump); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Log::Log4Cli; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Struct::Diff 0.96 qw(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 1 | our $VERSION = '0.09'; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | sub arg_opts { | ||||||||||||||||||||||||||||
| 14 | 6 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
arg_opts: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | return ( | ||||||||||||||||||||||||||||
| 17 | 6 | $self->SUPER::arg_opts(), | |||||||||||||||||||||||||||
| 18 | ); | ||||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | sub check_args { | ||||||||||||||||||||||||||||
| 22 | 5 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
check_args: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | die_fatal "One or two arguments expected", 1 | ||||||||||||||||||||||||||||
| 25 | 5 | ▶ | if (@{$self->{ARGV}} < 1 or @{$self->{ARGV}} > 2); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@{$self->{"ARGV"};} < 1 or @{$self->{"ARGV"};} > 2
MC/DC50%1/2
@{$self->{"ARGV"};} < 1 or @{$self->{"ARGV"};} > 2
@{$self->{"ARGV"};} < 1
@{$self->{"ARGV"};} > 2
Truth table66%2/3
A or B
A= @{$self->{"ARGV"};} < 1B= @{$self->{"ARGV"};} > 2
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 4 | return $self; | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | sub defaults { | ||||||||||||||||||||||||||||
| 31 | 6 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
defaults: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | return { | ||||||||||||||||||||||||||||
| 34 | 6 | %{$self->SUPER::defaults()}, | |||||||||||||||||||||||||||
| 35 | }; | ||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | sub dump { | ||||||||||||||||||||||||||||
| 39 | 4 | ▶ | my ($self, $uri, $struct) = @_; | ||||||||||||||||||||||||||
|
Subroutine
dump: called CC=1 SCAR=0.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 4 | ▶ | log_debug { "Restoring structure to '$uri'" }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 42 | s_dump($uri, $self->{OPTS}->{ofmt}, | ||||||||||||||||||||||||||||
| 43 | 4 | {pretty => $self->{OPTS}->{pretty}}, $struct); | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | sub exec { | ||||||||||||||||||||||||||||
| 47 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
exec: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 4 | my $uri = shift @{$self->{ARGV}}; | |||||||||||||||||||||||||||
| 50 | 4 | my $struct = $self->load_struct($uri, $self->{OPTS}->{ifmt}); | |||||||||||||||||||||||||||
| 51 | my $patch = $self->load_patch( | ||||||||||||||||||||||||||||
| 52 | 4 | @{$self->{ARGV}} ? shift @{$self->{ARGV}} : \*STDIN, | |||||||||||||||||||||||||||
| 53 | $self->{OPTS}->{ifmt} | ||||||||||||||||||||||||||||
| 54 | 4 | ▶ | ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 4 | $self->patch($struct, $patch); | |||||||||||||||||||||||||||
| 57 | 4 | $self->dump($uri, $struct); | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 3 | die_info "All done", 0; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | sub load_patch { | ||||||||||||||||||||||||||||
| 63 | 4 | ▶ | shift->load_struct(@_); | ||||||||||||||||||||||||||
|
Subroutine
load_patch: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | sub patch { | ||||||||||||||||||||||||||||
| 67 | 4 | ▶ | my ($self, $struct, $patch) = @_; | ||||||||||||||||||||||||||
|
Subroutine
patch: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 4 | eval { Struct::Diff::patch($struct, $patch) }; | |||||||||||||||||||||||||||
| 70 | 4 | ▶ | die_fatal "Failed to patch structure ($@)", 8 if ($@); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 1 | 1; # End of App::NDTools::NDPatch | |||||||||||||||||||||||||||