line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::MasterData::Declare::Reader; |
2
|
5
|
|
|
5
|
|
179728
|
use 5.010001; |
|
5
|
|
|
|
|
18
|
|
3
|
5
|
|
|
5
|
|
22
|
use strict; |
|
5
|
|
|
|
|
41
|
|
|
5
|
|
|
|
|
106
|
|
4
|
5
|
|
|
5
|
|
46
|
use warnings; |
|
5
|
|
|
|
|
15
|
|
|
5
|
|
|
|
|
126
|
|
5
|
5
|
|
|
5
|
|
25
|
use utf8; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
22
|
|
6
|
|
|
|
|
|
|
|
7
|
5
|
|
|
5
|
|
4171
|
use Text::CSV_PP; |
|
5
|
|
|
|
|
75287
|
|
|
5
|
|
|
|
|
249
|
|
8
|
5
|
|
|
5
|
|
33
|
use Carp qw/croak/; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
219
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Class::Accessor::Lite ( |
11
|
5
|
|
|
|
|
30
|
new => 1, |
12
|
|
|
|
|
|
|
ro => [qw/_rows table_name/], |
13
|
5
|
|
|
5
|
|
446
|
); |
|
5
|
|
|
|
|
1000
|
|
14
|
|
|
|
|
|
|
|
15
|
5
|
|
|
5
|
|
2172
|
use Test::MasterData::Declare::Row; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
950
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub read_csv_from { |
18
|
6
|
|
|
6
|
0
|
96
|
my ($class, %args) = @_; |
19
|
6
|
|
|
|
|
13
|
my $filepath = $args{filepath}; |
20
|
6
|
|
|
|
|
12
|
my $table_name = $args{table_name}; |
21
|
6
|
|
|
|
|
11
|
my $identifier_key = $args{identifier_key}; |
22
|
|
|
|
|
|
|
|
23
|
6
|
50
|
|
4
|
|
201
|
open my $fh, "<:encoding(utf8)", $filepath or croak "cannot open $filepath"; |
|
4
|
|
|
|
|
22
|
|
|
4
|
|
|
|
|
51
|
|
|
4
|
|
|
|
|
25
|
|
24
|
6
|
50
|
|
|
|
3499
|
my $csv = Text::CSV_PP->new({ |
25
|
|
|
|
|
|
|
binary => 1, |
26
|
|
|
|
|
|
|
blank_is_undef => 1, |
27
|
|
|
|
|
|
|
eol => "\n", |
28
|
|
|
|
|
|
|
}) or croak Text::CSV_PP->error_diag(); |
29
|
|
|
|
|
|
|
|
30
|
6
|
|
|
|
|
979
|
$csv->header($fh); |
31
|
6
|
|
|
|
|
29237
|
my @rows; |
32
|
6
|
|
|
|
|
22
|
while (my $row = $csv->getline_hr($fh)) { |
33
|
18
|
|
|
|
|
9146
|
my $lineno = $csv->record_number; |
34
|
18
|
|
|
|
|
108
|
push @rows, Test::MasterData::Declare::Row->new( |
35
|
|
|
|
|
|
|
table_name => $table_name, |
36
|
|
|
|
|
|
|
_row => $row, |
37
|
|
|
|
|
|
|
identifier_key => $identifier_key, |
38
|
|
|
|
|
|
|
lineno => $lineno, |
39
|
|
|
|
|
|
|
file => $filepath, |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
6
|
|
|
|
|
1349
|
return $class->new( |
44
|
|
|
|
|
|
|
_rows => \@rows, |
45
|
|
|
|
|
|
|
table_name => $table_name, |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub rows { |
50
|
8
|
|
|
8
|
0
|
4836
|
my $self = shift; |
51
|
|
|
|
|
|
|
|
52
|
8
|
|
|
|
|
25
|
return $self->_rows; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |