line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::NDTools::NDProc::Module::Insert; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
72239
|
use strict; |
|
4
|
|
|
|
|
19
|
|
|
4
|
|
|
|
|
159
|
|
4
|
4
|
|
|
4
|
|
23
|
use warnings FATAL => 'all'; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
184
|
|
5
|
4
|
|
|
4
|
|
464
|
use parent 'App::NDTools::NDProc::Module'; |
|
4
|
|
|
|
|
333
|
|
|
4
|
|
|
|
|
68
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
234
|
use Log::Log4Cli; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
339
|
|
8
|
4
|
|
|
4
|
|
24
|
use Scalar::Util qw(looks_like_number); |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
212
|
|
9
|
4
|
|
|
4
|
|
25
|
use Struct::Path 0.80 qw(path); |
|
4
|
|
|
|
|
74
|
|
|
4
|
|
|
|
|
204
|
|
10
|
4
|
|
|
4
|
|
28
|
use Struct::Path::PerlStyle 0.80 qw(str2path); |
|
4
|
|
|
|
|
55
|
|
|
4
|
|
|
|
|
2708
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.13'; |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
0
|
6
|
sub MODINFO { "Insert value into structure" } |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub arg_opts { |
17
|
21
|
|
|
21
|
0
|
36
|
my $self = shift; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
return ( |
20
|
|
|
|
|
|
|
$self->SUPER::arg_opts(), |
21
|
|
|
|
|
|
|
'boolean=s' => sub { |
22
|
6
|
100
|
100
|
6
|
|
6490
|
if ($_[1] eq '1' or $_[1] =~ /(T|t)rue/) { |
|
|
50
|
66
|
|
|
|
|
23
|
3
|
|
|
|
|
14
|
$self->{OPTS}->{value} = JSON::true; |
24
|
|
|
|
|
|
|
} elsif ($_[1] eq '0' or $_[1] =~ /(F|f)alse/) { |
25
|
3
|
|
|
|
|
14
|
$self->{OPTS}->{value} = JSON::false; |
26
|
|
|
|
|
|
|
} else { |
27
|
0
|
|
|
|
|
0
|
log_error { "Unsuitable value for --boolean" }; |
|
0
|
|
|
|
|
0
|
|
28
|
0
|
|
|
|
|
0
|
exit 1; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
}, |
31
|
|
|
|
|
|
|
'file|f=s' => \$self->{OPTS}->{file}, |
32
|
|
|
|
|
|
|
'file-fmt=s' => \$self->{OPTS}->{'file-fmt'}, |
33
|
2
|
|
|
2
|
|
2033
|
'null|undef' => sub { $self->{OPTS}->{value} = undef }, |
34
|
|
|
|
|
|
|
'number=s' => sub { |
35
|
5
|
50
|
|
5
|
|
5047
|
if (looks_like_number($_[1])) { |
36
|
5
|
|
|
|
|
27
|
$self->{OPTS}->{value} = 0 + $_[1]; |
37
|
|
|
|
|
|
|
} else { |
38
|
0
|
|
|
|
|
0
|
log_error { "Unsuitable value for --number" }; |
|
0
|
|
|
|
|
0
|
|
39
|
0
|
|
|
|
|
0
|
exit 1; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
}, |
42
|
4
|
|
|
4
|
|
4003
|
'string|value=s' => sub { $self->{OPTS}->{value} = $_[1] }, |
43
|
|
|
|
|
|
|
) |
44
|
21
|
|
|
|
|
75
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub check_rule { |
47
|
23
|
|
|
23
|
0
|
48
|
my ($self, $rule) = @_; |
48
|
23
|
|
|
|
|
45
|
my $out = $self; |
49
|
|
|
|
|
|
|
|
50
|
23
|
100
|
|
|
|
67
|
unless (exists $rule->{value}) { |
51
|
1
|
|
|
1
|
|
16
|
log_error { "Value to insert should be defined" }; |
|
1
|
|
|
|
|
90
|
|
52
|
1
|
|
|
|
|
7
|
$out = undef; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
23
|
|
|
|
|
67
|
return $out; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub configure { |
59
|
65
|
|
|
65
|
0
|
113
|
my $self = shift; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
$self->{OPTS}->{value} = |
62
|
|
|
|
|
|
|
$self->load_struct($self->{OPTS}->{file}, $self->{OPTS}->{'file-fmt'}) |
63
|
65
|
100
|
|
|
|
265
|
if (defined $self->{OPTS}->{file}); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub process_path { |
67
|
22
|
|
|
22
|
0
|
62
|
my ($self, $data, $path, $opts) = @_; |
68
|
|
|
|
|
|
|
|
69
|
22
|
|
|
|
|
43
|
my $spath = eval { str2path($path) }; |
|
22
|
|
|
|
|
95
|
|
70
|
22
|
50
|
|
|
|
46472
|
die_fatal "Failed to parse path ($@)", 4 if ($@); |
71
|
|
|
|
|
|
|
|
72
|
22
|
|
|
0
|
|
152
|
log_info { 'Updating path "' . $path . '"' }; |
|
0
|
|
|
|
|
0
|
|
73
|
22
|
|
|
|
|
122
|
eval { path(${$data}, $spath, assign => $opts->{value}, expand => 1) }; |
|
22
|
|
|
|
|
49
|
|
|
22
|
|
|
|
|
149
|
|
74
|
22
|
50
|
|
|
|
3041
|
die_fatal "Failed to lookup path '$path' ($@)", 4 if ($@); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; # End of App::NDTools::NDProc::Module::Insert |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__END__ |