line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Spreadsheet::Compare::Record; |
2
|
|
|
|
|
|
|
|
3
|
14
|
|
|
14
|
|
124
|
use Mojo::Base -base, -signatures; |
|
14
|
|
|
|
|
36
|
|
|
14
|
|
|
|
|
284
|
|
4
|
14
|
|
|
14
|
|
3950
|
use B qw(); |
|
14
|
|
|
|
|
36
|
|
|
14
|
|
|
|
|
7567
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# own attributes |
7
|
|
|
|
|
|
|
has [qw(h2i reader rec sln)]; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has limit_mask => sub { [] }; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has diff_info => sub { {} }; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has id => sub { |
14
|
|
|
|
|
|
|
my $identity = $_[0]->reader->identity; |
15
|
|
|
|
|
|
|
my @parts = map { $_[0]->val($_) } @$identity; |
16
|
|
|
|
|
|
|
return join( '_', @parts ); |
17
|
|
|
|
|
|
|
}; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has hash => sub { |
20
|
|
|
|
|
|
|
B::hash( join( '', grep { defined } @{ $_[0]->rec } ) ); |
21
|
|
|
|
|
|
|
}; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has side => sub { $_[0]->reader->side }; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has side_name => sub { $_[0]->reader->side_name }; |
26
|
|
|
|
|
|
|
|
27
|
18264
|
|
50
|
18264
|
1
|
77890
|
sub val { return $_[0]->{rec}[ $_[0]->{h2i}->{ $_[1] } ] // '' } |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub new { |
30
|
17370
|
|
|
17370
|
1
|
56648
|
my $self = shift->SUPER::new(@_); |
31
|
17370
|
|
66
|
|
|
178886
|
$self->{h2i} //= $self->reader->h2i; |
32
|
17370
|
|
|
|
|
114328
|
return $self; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 NAME |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Spreadsheet::Compare::Record - Class Representing a Single Record |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 SYNOPSIS |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
use Spreadsheet::Compare::Record; |
46
|
|
|
|
|
|
|
my $rec = Spreadsheet::Compare::Record->new( |
47
|
|
|
|
|
|
|
rec => \@record, |
48
|
|
|
|
|
|
|
reader => $reader_object; |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 DESCRIPTION |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Spreadsheet::Compare::Record represents a single record read by one of the reader classes. |
54
|
|
|
|
|
|
|
It will normally be of little interest unless you are developing a new Reader class. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 diff_info |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
A reference to a hash with summary information from the comparison with the corresponding |
61
|
|
|
|
|
|
|
record on the opposite side. Modification (don't do that) will also modify the corresponding |
62
|
|
|
|
|
|
|
record, the reference is shallow. It has the following structure: |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
{ |
65
|
|
|
|
|
|
|
ABS_FIELD => <name of the column with highest absolute deviation>, |
66
|
|
|
|
|
|
|
ABS_VALUE => <highest absolute deviation>, |
67
|
|
|
|
|
|
|
REL_FIELD => <name of the column with highest relative deviation>, |
68
|
|
|
|
|
|
|
REL_VALUE => <highest relative deviation>, |
69
|
|
|
|
|
|
|
limit => <true if all deviations are below their configured limits>, |
70
|
|
|
|
|
|
|
equal => <true if the records are considered equal>, |
71
|
|
|
|
|
|
|
}; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 h2i |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 hash |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
A hash value set by the reader. If the hash values for two record match, they are |
78
|
|
|
|
|
|
|
considered equal and no detailed comparisons will take place. This enhances |
79
|
|
|
|
|
|
|
performance significantly. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 id |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
The id of the record constructed from the configuration value of |
84
|
|
|
|
|
|
|
L<Spreadsheet::Compare::Reader/identity> |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 limit_mask |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
A reference to a hash with information from the comparison with the corresponding |
89
|
|
|
|
|
|
|
record on the opposite side. Modification (don't do that) will also modify the corresponding |
90
|
|
|
|
|
|
|
record, the reference is shallow. It has the following structure: |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
{ |
93
|
|
|
|
|
|
|
<columnindex> => [-1|0|1], |
94
|
|
|
|
|
|
|
... |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
with 0 means the values are equal, 1 means the values differ and -1 means they differ |
98
|
|
|
|
|
|
|
but the deviation is below the configured limits. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 reader |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
The L<Spreadsheet::Compare::Reader> object the record belongs to. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 rec |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
A reference to an array with the record values. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head2 side |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
A shortcut for $self->reader->side |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head2 side_name |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
A shortcut for $self->reader->side_name |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 sln |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Source line number for the record, if the reader provides it (eg. file based readers). |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 METHODS |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head2 val($index) |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Return the value at column index $index. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=cut |