line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::TableReader::Decoder::Mock; |
2
|
2
|
|
|
2
|
|
1128
|
use Moo 2; |
|
2
|
|
|
|
|
40
|
|
|
2
|
|
|
|
|
13
|
|
3
|
2
|
|
|
2
|
|
583
|
use Carp 'croak'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
104
|
|
4
|
2
|
|
|
2
|
|
915
|
use IO::Handle; |
|
2
|
|
|
|
|
10093
|
|
|
2
|
|
|
|
|
367
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
extends 'Data::TableReader::Decoder'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# ABSTRACT: Mock decoder for test cases |
9
|
|
|
|
|
|
|
our $VERSION = '0.011'; # VERSION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has data => ( is => 'rw' ); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub iterator { |
15
|
11
|
|
|
11
|
1
|
2803
|
my $self= shift; |
16
|
11
|
|
|
|
|
52
|
my $data= $self->data; |
17
|
11
|
|
|
|
|
20
|
my $table= $data->[0]; |
18
|
11
|
50
|
|
|
|
26
|
my $colmax= $table? scalar(@{$table->[0]})-1 : -1; |
|
11
|
|
|
|
|
22
|
|
19
|
11
|
50
|
|
|
|
25
|
my $rowmax= $table? $#$table : -1; |
20
|
11
|
|
|
|
|
16
|
my $row= -1; |
21
|
|
|
|
|
|
|
Data::TableReader::Decoder::Mock::_Iter->new( |
22
|
|
|
|
|
|
|
sub { |
23
|
46
|
|
|
46
|
|
65
|
my $slice= shift; |
24
|
46
|
100
|
|
|
|
142
|
return undef unless $row < $rowmax; |
25
|
35
|
|
|
|
|
46
|
++$row; |
26
|
35
|
|
|
|
|
53
|
my $datarow= $table->[$row]; |
27
|
35
|
100
|
|
|
|
60
|
return [ @{$datarow}[@$slice] ] if $slice; |
|
17
|
|
|
|
|
82
|
|
28
|
18
|
|
|
|
|
32
|
return $datarow; |
29
|
|
|
|
|
|
|
}, |
30
|
|
|
|
|
|
|
{ |
31
|
11
|
|
|
|
|
123
|
data => $data, |
32
|
|
|
|
|
|
|
table_idx => 0, |
33
|
|
|
|
|
|
|
table_ref => \$table, |
34
|
|
|
|
|
|
|
row_ref => \$row, |
35
|
|
|
|
|
|
|
colmax_ref => \$colmax, |
36
|
|
|
|
|
|
|
rowmax_ref => \$rowmax, |
37
|
|
|
|
|
|
|
origin => [ $table, $row ], |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# If you need to subclass this iterator, don't. Just implement your own. |
43
|
|
|
|
|
|
|
# i.e. I'm not declaring this implementation stable, yet. |
44
|
2
|
|
|
2
|
|
14
|
use Data::TableReader::Iterator; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
66
|
|
45
|
2
|
|
|
2
|
|
609
|
BEGIN { @Data::TableReader::Decoder::Mock::_Iter::ISA= ('Data::TableReader::Iterator'); } |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub Data::TableReader::Decoder::Mock::_Iter::position { |
48
|
20
|
|
|
20
|
|
64
|
my $f= shift->_fields; |
49
|
20
|
|
|
|
|
27
|
'row '.${ $f->{row_ref} }; |
|
20
|
|
|
|
|
73
|
|
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub Data::TableReader::Decoder::Mock::_Iter::progress { |
53
|
0
|
|
|
0
|
|
0
|
my $f= shift->_fields; |
54
|
0
|
|
0
|
|
|
0
|
return ${ $f->{row_ref} } / (${ $f->{rowmax_ref} } || 1); |
|
0
|
|
|
|
|
0
|
|
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub Data::TableReader::Decoder::Mock::_Iter::tell { |
58
|
9
|
|
|
9
|
|
25
|
my $f= shift->_fields; |
59
|
9
|
|
|
|
|
18
|
return [ $f->{table_idx}, ${$f->{row_ref}} ]; |
|
9
|
|
|
|
|
29
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub Data::TableReader::Decoder::Mock::_Iter::seek { |
63
|
3
|
|
|
3
|
|
17
|
my ($self, $to)= @_; |
64
|
3
|
|
|
|
|
7
|
my $f= $self->_fields; |
65
|
3
|
|
33
|
|
|
10
|
$to ||= $f->{origin}; |
66
|
3
|
|
|
|
|
8
|
my ($table_idx, $row)= @$to; |
67
|
3
|
|
|
|
|
6
|
my $table= $f->{data}[$table_idx]; |
68
|
3
|
50
|
|
|
|
9
|
my $colmax= $table? scalar(@{$table->[0]})-1 : -1; |
|
3
|
|
|
|
|
8
|
|
69
|
3
|
50
|
|
|
|
9
|
my $rowmax= $table? $#$table : -1; |
70
|
3
|
100
|
|
|
|
8
|
$row= -1 unless defined $row; |
71
|
3
|
|
|
|
|
5
|
$f->{table_idx}= $table_idx; |
72
|
3
|
|
|
|
|
6
|
${$f->{table_ref}}= $table; |
|
3
|
|
|
|
|
5
|
|
73
|
3
|
|
|
|
|
6
|
${$f->{row_ref}}= $row; |
|
3
|
|
|
|
|
7
|
|
74
|
3
|
|
|
|
|
5
|
${$f->{colmax_ref}}= $colmax; |
|
3
|
|
|
|
|
5
|
|
75
|
3
|
|
|
|
|
4
|
${$f->{rowmax_ref}}= $rowmax; |
|
3
|
|
|
|
|
4
|
|
76
|
3
|
|
|
|
|
11
|
1; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub Data::TableReader::Decoder::Mock::_Iter::next_dataset { |
80
|
1
|
|
|
1
|
|
3
|
my $self= shift; |
81
|
1
|
|
|
|
|
4
|
my $f= $self->_fields; |
82
|
|
|
|
|
|
|
return defined $f->{data}[ $f->{table_idx}+1 ] |
83
|
1
|
|
33
|
|
|
9
|
&& $self->seek([ $f->{table_idx}+1 ]); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
__END__ |