line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::NDTools::NDProc::Module::Insert; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
54298
|
use strict; |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
126
|
|
4
|
4
|
|
|
4
|
|
20
|
use warnings FATAL => 'all'; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
148
|
|
5
|
4
|
|
|
4
|
|
397
|
use parent 'App::NDTools::NDProc::Module'; |
|
4
|
|
|
|
|
261
|
|
|
4
|
|
|
|
|
21
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
216
|
use Log::Log4Cli; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
286
|
|
8
|
4
|
|
|
4
|
|
21
|
use Scalar::Util qw(looks_like_number); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
190
|
|
9
|
4
|
|
|
4
|
|
23
|
use Struct::Path 0.80 qw(path); |
|
4
|
|
|
|
|
61
|
|
|
4
|
|
|
|
|
152
|
|
10
|
|
|
|
|
|
|
|
11
|
4
|
|
|
4
|
|
21
|
use App::NDTools::Util qw(chomp_evaled_error); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
2330
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.18'; |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
0
|
5
|
sub MODINFO { "Insert value into structure" } |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub arg_opts { |
18
|
29
|
|
|
29
|
0
|
35
|
my $self = shift; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
return ( |
21
|
|
|
|
|
|
|
$self->SUPER::arg_opts(), |
22
|
|
|
|
|
|
|
'boolean=s' => sub { |
23
|
10
|
100
|
100
|
10
|
|
8077
|
if ($_[1] eq '1' or $_[1] =~ /^(T|t)rue$/) { |
|
|
100
|
100
|
|
|
|
|
24
|
3
|
|
|
|
|
12
|
$self->{OPTS}->{value} = JSON::true; |
25
|
|
|
|
|
|
|
} elsif ($_[1] eq '0' or $_[1] =~ /^(F|f)alse$/) { |
26
|
3
|
|
|
|
|
11
|
$self->{OPTS}->{value} = JSON::false; |
27
|
|
|
|
|
|
|
} else { |
28
|
4
|
|
|
|
|
10
|
$self->{ARG_ERROR} = "Unsuitable value for --boolean"; |
29
|
4
|
|
|
|
|
11
|
die "!FINISH"; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
}, |
32
|
|
|
|
|
|
|
'file|f=s' => \$self->{OPTS}->{file}, |
33
|
|
|
|
|
|
|
'file-fmt=s' => \$self->{OPTS}->{'file-fmt'}, |
34
|
2
|
|
|
2
|
|
1674
|
'null|undef' => sub { $self->{OPTS}->{value} = undef }, |
35
|
|
|
|
|
|
|
'number=s' => sub { |
36
|
6
|
100
|
|
6
|
|
4806
|
if (looks_like_number($_[1])) { |
37
|
5
|
|
|
|
|
20
|
$self->{OPTS}->{value} = 0 + $_[1]; |
38
|
|
|
|
|
|
|
} else { |
39
|
1
|
|
|
|
|
3
|
$self->{ARG_ERROR} = "Unsuitable value for --number"; |
40
|
1
|
|
|
|
|
3
|
die "!FINISH"; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
}, |
43
|
5
|
|
|
5
|
|
3961
|
'string|value=s' => sub { $self->{OPTS}->{value} = $_[1] }, |
44
|
|
|
|
|
|
|
) |
45
|
29
|
|
|
|
|
78
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub check_rule { |
48
|
24
|
|
|
24
|
0
|
44
|
my ($self, $rule) = @_; |
49
|
24
|
|
|
|
|
31
|
my $out = $self; |
50
|
|
|
|
|
|
|
|
51
|
24
|
100
|
|
|
|
70
|
unless (exists $rule->{value}) { |
52
|
1
|
|
|
1
|
|
6
|
log_error { "Value to insert should be defined" }; |
|
1
|
|
|
|
|
62
|
|
53
|
1
|
|
|
|
|
6
|
$out = undef; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
24
|
100
|
|
|
|
31
|
push @{$rule->{path}}, '' unless (@{$rule->{path}}); |
|
1
|
|
|
|
|
3
|
|
|
24
|
|
|
|
|
54
|
|
57
|
|
|
|
|
|
|
|
58
|
24
|
|
|
|
|
64
|
return $out; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub configure { |
62
|
74
|
|
|
74
|
0
|
112
|
my $self = shift; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
$self->{OPTS}->{value} = |
65
|
|
|
|
|
|
|
$self->load_struct($self->{OPTS}->{file}, $self->{OPTS}->{'file-fmt'}) |
66
|
74
|
100
|
|
|
|
193
|
if (defined $self->{OPTS}->{file}); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub process_path { |
70
|
24
|
|
|
24
|
0
|
60
|
my ($self, $data, $path, $spath, $opts) = @_; |
71
|
|
|
|
|
|
|
|
72
|
24
|
|
|
0
|
|
118
|
log_info { 'Updating path "' . $path . '"' }; |
|
0
|
|
|
|
|
0
|
|
73
|
24
|
|
|
|
|
95
|
eval { path(${$data}, $spath, assign => $opts->{value}, expand => 1) }; |
|
24
|
|
|
|
|
36
|
|
|
24
|
|
|
|
|
81
|
|
74
|
24
|
100
|
|
|
|
3495
|
die_fatal "Failed to lookup path '$path' (" . |
75
|
|
|
|
|
|
|
chomp_evaled_error($@) . ")", 4 if ($@); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; # End of App::NDTools::NDProc::Module::Insert |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
__END__ |