line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::MasterData::Declare::Row; |
2
|
5
|
|
|
5
|
|
92
|
use 5.010001; |
|
5
|
|
|
|
|
18
|
|
3
|
5
|
|
|
5
|
|
28
|
use strict; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
112
|
|
4
|
5
|
|
|
5
|
|
26
|
use warnings; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
155
|
|
5
|
5
|
|
|
5
|
|
29
|
use utf8; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
32
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Class::Accessor::Lite ( |
8
|
5
|
|
|
|
|
36
|
new => 1, |
9
|
|
|
|
|
|
|
rw => [qw/_cached_compare_row/], |
10
|
|
|
|
|
|
|
ro => [qw/table_name _row identifier_key lineno file/], |
11
|
5
|
|
|
5
|
|
320
|
); |
|
5
|
|
|
|
|
14
|
|
12
|
|
|
|
|
|
|
|
13
|
5
|
|
|
5
|
|
793
|
use Test2::Compare::Number qw/number/; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
180
|
|
14
|
5
|
|
|
5
|
|
39
|
use Test2::Compare::String; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
136
|
|
15
|
5
|
|
|
5
|
|
26
|
use Carp qw/croak/; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
224
|
|
16
|
5
|
|
|
5
|
|
2220
|
use JSON; |
|
5
|
|
|
|
|
52448
|
|
|
5
|
|
|
|
|
40
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $json = JSON->new->utf8; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub row { |
21
|
45
|
|
|
45
|
0
|
811
|
my $self = shift; |
22
|
|
|
|
|
|
|
|
23
|
45
|
|
|
|
|
156
|
my $cached_compare_row = $self->_cached_compare_row; |
24
|
45
|
100
|
|
|
|
365
|
return $cached_compare_row if $cached_compare_row; |
25
|
|
|
|
|
|
|
|
26
|
16
|
|
|
|
|
37
|
my %compare_row; |
27
|
16
|
|
|
|
|
36
|
for my $key (keys %{$self->_row}) { |
|
16
|
|
|
|
|
64
|
|
28
|
74
|
|
|
|
|
658
|
$compare_row{$key} = $self->_row->{$key}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
16
|
|
|
|
|
185
|
$self->_cached_compare_row(\%compare_row); |
32
|
16
|
|
|
|
|
138
|
return \%compare_row; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub source { |
36
|
1
|
|
|
1
|
0
|
5
|
my ($self, $column) = @_; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
return sprintf( |
39
|
|
|
|
|
|
|
"%s#%s=%s", |
40
|
|
|
|
|
|
|
$self->file, |
41
|
1
|
|
|
|
|
7
|
$self->identifier_key, $self->row->{$self->identifier_key}, |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub json { |
46
|
6
|
|
|
6
|
0
|
25
|
my ($self, $column, @keys) = @_; |
47
|
6
|
|
|
|
|
21
|
my $json_data = $self->row->{$column}; |
48
|
6
|
|
|
|
|
76
|
my $data = $json->decode($json_data); |
49
|
|
|
|
|
|
|
|
50
|
6
|
|
|
|
|
17
|
my $out = $data; |
51
|
6
|
|
|
|
|
27
|
for my $key (@keys) { |
52
|
6
|
50
|
0
|
|
|
22
|
if (ref $out eq "HASH") { |
|
|
0
|
|
|
|
|
|
53
|
6
|
|
|
|
|
20
|
$out = $out->{$key}; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
elsif (ref $out eq "ARRAY" && number($key)) { |
56
|
0
|
|
|
|
|
0
|
$out = $out->[$key]; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
else { |
59
|
0
|
|
|
|
|
0
|
return undef; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
6
|
|
|
|
|
33
|
return $out; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |