line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::MasterData::Declare::Reader; |
2
|
5
|
|
|
5
|
|
193674
|
use 5.010001; |
|
5
|
|
|
|
|
68
|
|
3
|
5
|
|
|
5
|
|
62
|
use strict; |
|
5
|
|
|
|
|
16
|
|
|
5
|
|
|
|
|
166
|
|
4
|
5
|
|
|
5
|
|
38
|
use warnings; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
225
|
|
5
|
5
|
|
|
5
|
|
38
|
use utf8; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
40
|
|
6
|
|
|
|
|
|
|
|
7
|
5
|
|
|
5
|
|
3998
|
use Text::CSV_PP; |
|
5
|
|
|
|
|
99754
|
|
|
5
|
|
|
|
|
347
|
|
8
|
5
|
|
|
5
|
|
55
|
use Carp qw/croak/; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
323
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Class::Accessor::Lite ( |
11
|
5
|
|
|
|
|
48
|
new => 1, |
12
|
|
|
|
|
|
|
ro => [qw/_rows table_name/], |
13
|
5
|
|
|
5
|
|
380
|
); |
|
5
|
|
|
|
|
861
|
|
14
|
|
|
|
|
|
|
|
15
|
5
|
|
|
5
|
|
2510
|
use Test::MasterData::Declare::Row; |
|
5
|
|
|
|
|
21
|
|
|
5
|
|
|
|
|
1478
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub read_csv_from { |
18
|
6
|
|
|
6
|
0
|
128
|
my ($class, %args) = @_; |
19
|
6
|
|
|
|
|
20
|
my $filepath = $args{filepath}; |
20
|
6
|
|
|
|
|
21
|
my $table_name = $args{table_name}; |
21
|
6
|
|
|
|
|
18
|
my $identifier_key = $args{identifier_key}; |
22
|
|
|
|
|
|
|
|
23
|
6
|
50
|
|
4
|
|
234
|
open my $fh, "<:encoding(utf8)", $filepath or croak "cannot open $filepath"; |
|
4
|
|
|
|
|
30
|
|
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
32
|
|
24
|
6
|
50
|
|
|
|
3791
|
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
|
|
|
|
|
1683
|
$csv->header($fh); |
31
|
6
|
|
|
|
|
34282
|
my @rows; |
32
|
6
|
|
|
|
|
39
|
while (my $row = $csv->getline_hr($fh)) { |
33
|
18
|
|
|
|
|
15432
|
my $lineno = $csv->record_number; |
34
|
18
|
|
|
|
|
196
|
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
|
|
|
|
|
2166
|
return $class->new( |
44
|
|
|
|
|
|
|
_rows => \@rows, |
45
|
|
|
|
|
|
|
table_name => $table_name, |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub rows { |
50
|
8
|
|
|
8
|
0
|
6468
|
my $self = shift; |
51
|
|
|
|
|
|
|
|
52
|
8
|
|
|
|
|
52
|
return $self->_rows; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |