line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::MasterData::Declare::Row; |
2
|
5
|
|
|
5
|
|
74
|
use 5.010001; |
|
5
|
|
|
|
|
15
|
|
3
|
5
|
|
|
5
|
|
20
|
use strict; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
134
|
|
4
|
5
|
|
|
5
|
|
22
|
use warnings; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
113
|
|
5
|
5
|
|
|
5
|
|
21
|
use utf8; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
21
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Class::Accessor::Lite ( |
8
|
5
|
|
|
|
|
31
|
new => 1, |
9
|
|
|
|
|
|
|
rw => [qw/_cached_compare_row/], |
10
|
|
|
|
|
|
|
ro => [qw/table_name _row identifier_key lineno file/], |
11
|
5
|
|
|
5
|
|
192
|
); |
|
5
|
|
|
|
|
8
|
|
12
|
|
|
|
|
|
|
|
13
|
5
|
|
|
5
|
|
657
|
use Test2::Compare::Number qw/number/; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
148
|
|
14
|
5
|
|
|
5
|
|
23
|
use Test2::Compare::String; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
159
|
|
15
|
5
|
|
|
5
|
|
23
|
use Carp qw/croak/; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
267
|
|
16
|
5
|
|
|
5
|
|
2541
|
use JSON; |
|
5
|
|
|
|
|
39110
|
|
|
5
|
|
|
|
|
23
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $json = JSON->new->utf8; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub row { |
21
|
30
|
|
|
30
|
0
|
630
|
my $self = shift; |
22
|
|
|
|
|
|
|
|
23
|
30
|
|
|
|
|
69
|
my $cached_compare_row = $self->_cached_compare_row; |
24
|
30
|
100
|
|
|
|
163
|
return $cached_compare_row if $cached_compare_row; |
25
|
|
|
|
|
|
|
|
26
|
13
|
|
|
|
|
21
|
my %compare_row; |
27
|
13
|
|
|
|
|
17
|
for my $key (keys %{$self->_row}) { |
|
13
|
|
|
|
|
31
|
|
28
|
62
|
|
|
|
|
342
|
$compare_row{$key} = $self->_row->{$key}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
13
|
|
|
|
|
83
|
$self->_cached_compare_row(\%compare_row); |
32
|
13
|
|
|
|
|
76
|
return \%compare_row; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub source { |
36
|
1
|
|
|
1
|
0
|
3
|
my ($self, $column) = @_; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
return sprintf( |
39
|
|
|
|
|
|
|
"%s#%s=%s", |
40
|
|
|
|
|
|
|
$self->file, |
41
|
1
|
|
|
|
|
3
|
$self->identifier_key, $self->row->{$self->identifier_key}, |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub json { |
46
|
6
|
|
|
6
|
0
|
11
|
my ($self, $column, @keys) = @_; |
47
|
6
|
|
|
|
|
38
|
my $json_data = $self->row->{$column}; |
48
|
6
|
|
|
|
|
38
|
my $data = $json->decode($json_data); |
49
|
|
|
|
|
|
|
|
50
|
6
|
|
|
|
|
8
|
my $out = $data; |
51
|
6
|
|
|
|
|
12
|
for my $key (@keys) { |
52
|
6
|
50
|
0
|
|
|
21
|
if (ref $out eq "HASH") { |
|
|
0
|
|
|
|
|
|
53
|
6
|
|
|
|
|
12
|
$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
|
|
|
|
|
17
|
return $out; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |