| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Business::NAB::CSV; |
|
2
|
|
|
|
|
|
|
$Business::NAB::CSV::VERSION = '0.03'; |
|
3
|
|
|
|
|
|
|
# undocument abstract class for parsing/creating CSV lines |
|
4
|
|
|
|
|
|
|
# mostly delegated to Text::CSV_XS |
|
5
|
|
|
|
|
|
|
|
|
6
|
8
|
|
|
8
|
|
6623
|
use strict; |
|
|
8
|
|
|
|
|
23
|
|
|
|
8
|
|
|
|
|
435
|
|
|
7
|
8
|
|
|
8
|
|
52
|
use warnings; |
|
|
8
|
|
|
|
|
18
|
|
|
|
8
|
|
|
|
|
626
|
|
|
8
|
8
|
|
|
8
|
|
60
|
use feature qw/ signatures /; |
|
|
8
|
|
|
|
|
25
|
|
|
|
8
|
|
|
|
|
1243
|
|
|
9
|
8
|
|
|
8
|
|
3861
|
use autodie qw/ :all /; |
|
|
8
|
|
|
|
|
133509
|
|
|
|
8
|
|
|
|
|
49
|
|
|
10
|
8
|
|
|
8
|
|
170765
|
use Carp qw/ croak /; |
|
|
8
|
|
|
|
|
26
|
|
|
|
8
|
|
|
|
|
577
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
8
|
|
|
8
|
|
62
|
use Moose; |
|
|
8
|
|
|
|
|
23
|
|
|
|
8
|
|
|
|
|
103
|
|
|
13
|
8
|
|
|
8
|
|
83082
|
use Moose::Util::TypeConstraints; |
|
|
8
|
|
|
|
|
18
|
|
|
|
8
|
|
|
|
|
139
|
|
|
14
|
8
|
|
|
8
|
|
24986
|
no warnings qw/ experimental::signatures /; |
|
|
8
|
|
|
|
|
48
|
|
|
|
8
|
|
|
|
|
595
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
8
|
|
|
8
|
|
9648
|
use Text::CSV_XS qw/ csv /; |
|
|
8
|
|
|
|
|
215160
|
|
|
|
8
|
|
|
|
|
4833
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
0
|
|
|
0
|
|
0
|
sub _record_type { croak( "You must define the _record_type method" ) } |
|
19
|
|
|
|
|
|
|
|
|
20
|
0
|
|
|
0
|
|
0
|
sub _attributes { croak( "You must define the _attributes method" ) } |
|
21
|
|
|
|
|
|
|
|
|
22
|
24
|
|
|
24
|
0
|
125155
|
sub new_from_record ( $class, $line ) { |
|
|
24
|
|
|
|
|
94
|
|
|
|
24
|
|
|
|
|
51
|
|
|
|
24
|
|
|
|
|
48
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
24
|
50
|
|
|
|
251
|
my $aoh = csv( |
|
25
|
|
|
|
|
|
|
in => \$line, |
|
26
|
|
|
|
|
|
|
headers => [ 'record_type', $class->_attributes ], |
|
27
|
|
|
|
|
|
|
) or croak( Text::CSV->error_diag ); |
|
28
|
|
|
|
|
|
|
|
|
29
|
24
|
|
|
|
|
25601
|
my $self = $class->new( my %record = $aoh->[ 0 ]->%* ); |
|
30
|
|
|
|
|
|
|
|
|
31
|
22
|
100
|
|
|
|
211
|
if ( $record{ record_type } ne $self->_record_type ) { |
|
32
|
5
|
|
|
|
|
22
|
croak( "unsupported record type (@{[ $record{record_type} ]})" ); |
|
|
5
|
|
|
|
|
126
|
|
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
17
|
|
|
|
|
260
|
return $self; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
38
|
|
|
38
|
0
|
92
|
sub to_record ( $self, $aoa = undef ) { |
|
|
38
|
|
|
|
|
79
|
|
|
|
38
|
|
|
|
|
78
|
|
|
|
38
|
|
|
|
|
90
|
|
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$aoa //= [ [ |
|
41
|
38
|
|
100
|
|
|
285
|
map { $self->$_ } |
|
|
227
|
|
|
|
|
6623
|
|
|
42
|
|
|
|
|
|
|
'_record_type', $self->_attributes, |
|
43
|
|
|
|
|
|
|
] ]; |
|
44
|
|
|
|
|
|
|
|
|
45
|
38
|
|
|
|
|
354
|
csv( |
|
46
|
|
|
|
|
|
|
in => $aoa, |
|
47
|
|
|
|
|
|
|
out => \my $data, |
|
48
|
|
|
|
|
|
|
quote_space => 0, |
|
49
|
|
|
|
|
|
|
eol => '', |
|
50
|
|
|
|
|
|
|
); |
|
51
|
|
|
|
|
|
|
|
|
52
|
38
|
|
|
|
|
19246
|
return $data; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |