| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Data::TableReader::Decoder::Mock; |
|
2
|
7
|
|
|
7
|
|
179642
|
use Moo 2; |
|
|
7
|
|
|
|
|
10626
|
|
|
|
7
|
|
|
|
|
52
|
|
|
3
|
7
|
|
|
7
|
|
4861
|
use Carp 'croak'; |
|
|
7
|
|
|
|
|
18
|
|
|
|
7
|
|
|
|
|
564
|
|
|
4
|
7
|
|
|
7
|
|
4780
|
use IO::Handle; |
|
|
7
|
|
|
|
|
71462
|
|
|
|
7
|
|
|
|
|
4114
|
|
|
5
|
|
|
|
|
|
|
require MRO::Compat if $] < '5.010'; |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
extends 'Data::TableReader::Decoder'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: Decoder that returns supplied data without decoding anything |
|
10
|
|
|
|
|
|
|
our $VERSION = '0.021'; # VERSION |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub BUILDARGS { |
|
14
|
25
|
|
|
25
|
0
|
297583
|
my $args= $_[0]->next::method(@_[1..$#_]); |
|
15
|
|
|
|
|
|
|
# back-compat with earlier versions |
|
16
|
25
|
50
|
|
|
|
786
|
$args->{datasets}= delete $args->{data} if defined $args->{data}; |
|
17
|
|
|
|
|
|
|
# allow simple way for user to specify a single table |
|
18
|
25
|
100
|
|
|
|
105
|
$args->{datasets}= [ delete $args->{table} ] if defined $args->{table}; |
|
19
|
25
|
|
|
|
|
544
|
$args; |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has datasets => ( is => 'rw', isa => \&_arrayref_3_deep ); |
|
23
|
|
|
|
|
|
|
*data= *datasets; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _arrayref_3_deep { |
|
26
|
25
|
50
|
|
25
|
|
765
|
ref $_[0] eq 'ARRAY' or return 'Not an arrayref'; |
|
27
|
25
|
100
|
|
|
|
47
|
return undef unless @{$_[0]}; |
|
|
25
|
|
|
|
|
109
|
|
|
28
|
24
|
50
|
|
|
|
87
|
ref $_[0][0] eq 'ARRAY' or return 'Not an arrayref of tables'; |
|
29
|
24
|
100
|
|
|
|
40
|
return undef unless @{$_[0][0]}; |
|
|
24
|
|
|
|
|
131
|
|
|
30
|
23
|
50
|
|
|
|
85
|
ref $_[0][0][0] eq 'ARRAY' or return 'Not an arrayref of tables of rows'; |
|
31
|
23
|
50
|
|
|
|
37
|
return undef unless @{$_[0][0][0]}; |
|
|
23
|
|
|
|
|
78
|
|
|
32
|
23
|
50
|
|
|
|
78
|
ref $_[0][0][0][0] ne 'ARRAY' |
|
33
|
|
|
|
|
|
|
or return 'Expected plain cell value at ->[$dataset][$table][$cell] depth of arrayrefs'; |
|
34
|
23
|
|
|
|
|
483
|
undef; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub iterator { |
|
38
|
28
|
|
|
28
|
1
|
2953
|
my $self= shift; |
|
39
|
28
|
|
|
|
|
647
|
my $data= $self->datasets; |
|
40
|
28
|
|
|
|
|
189
|
my $table= $data->[0]; |
|
41
|
28
|
100
|
|
|
|
92
|
my $rowmax= $table? $#$table : -1; |
|
42
|
28
|
|
|
|
|
56
|
my $row= -1; |
|
43
|
|
|
|
|
|
|
Data::TableReader::Decoder::Mock::_Iter->new( |
|
44
|
|
|
|
|
|
|
sub { |
|
45
|
124
|
|
|
124
|
|
229
|
my $slice= shift; |
|
46
|
124
|
100
|
|
|
|
477
|
return undef unless $row < $rowmax; |
|
47
|
95
|
|
|
|
|
180
|
my $datarow= $table->[++$row]; |
|
48
|
95
|
100
|
|
|
|
220
|
return [ @{$datarow}[@$slice] ] if $slice; |
|
|
57
|
|
|
|
|
307
|
|
|
49
|
38
|
|
|
|
|
102
|
return $datarow; |
|
50
|
|
|
|
|
|
|
}, |
|
51
|
|
|
|
|
|
|
{ |
|
52
|
28
|
|
|
|
|
531
|
data => $data, |
|
53
|
|
|
|
|
|
|
table_idx => 0, |
|
54
|
|
|
|
|
|
|
table_ref => \$table, |
|
55
|
|
|
|
|
|
|
row_ref => \$row, |
|
56
|
|
|
|
|
|
|
rowmax_ref => \$rowmax, |
|
57
|
|
|
|
|
|
|
origin => [ 0, $row ], |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
); |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# If you need to subclass this iterator, don't. Just implement your own. |
|
63
|
|
|
|
|
|
|
# i.e. I'm not declaring this implementation stable, yet. |
|
64
|
7
|
|
|
7
|
|
748
|
use Data::TableReader::Iterator; |
|
|
7
|
|
|
|
|
16
|
|
|
|
7
|
|
|
|
|
409
|
|
|
65
|
7
|
|
|
7
|
|
3743
|
BEGIN { @Data::TableReader::Decoder::Mock::_Iter::ISA= ('Data::TableReader::Iterator'); } |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub Data::TableReader::Decoder::Mock::_Iter::position { |
|
68
|
41
|
|
|
41
|
|
150
|
my $f= shift->_fields; |
|
69
|
41
|
|
|
|
|
74
|
'row '.(1 + ${ $f->{row_ref} }); |
|
|
41
|
|
|
|
|
383
|
|
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub Data::TableReader::Decoder::Mock::_Iter::row { |
|
73
|
24
|
|
|
24
|
|
48
|
1 + ${ shift->_fields->{row_ref} }; |
|
|
24
|
|
|
|
|
93
|
|
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub Data::TableReader::Decoder::Mock::_Iter::dataset_idx { |
|
77
|
|
|
|
|
|
|
shift->_fields->{table_idx} |
|
78
|
9
|
|
|
9
|
|
37
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub Data::TableReader::Decoder::Mock::_Iter::progress { |
|
81
|
0
|
|
|
0
|
|
0
|
my $f= shift->_fields; |
|
82
|
0
|
|
0
|
|
|
0
|
return ${ $f->{row_ref} } / (${ $f->{rowmax_ref} } || 1); |
|
|
0
|
|
|
|
|
0
|
|
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub Data::TableReader::Decoder::Mock::_Iter::tell { |
|
86
|
33
|
|
|
33
|
|
126
|
my $f= shift->_fields; |
|
87
|
33
|
|
|
|
|
69
|
return [ $f->{table_idx}, ${$f->{row_ref}} ]; |
|
|
33
|
|
|
|
|
140
|
|
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub Data::TableReader::Decoder::Mock::_Iter::seek { |
|
91
|
6
|
|
|
6
|
|
41
|
my ($self, $to)= @_; |
|
92
|
6
|
|
|
|
|
22
|
my $f= $self->_fields; |
|
93
|
6
|
|
66
|
|
|
25
|
$to ||= $f->{origin}; |
|
94
|
6
|
|
|
|
|
17
|
my ($table_idx, $row)= @$to; |
|
95
|
6
|
|
|
|
|
15
|
my $table= $f->{data}[$table_idx]; |
|
96
|
6
|
50
|
|
|
|
23
|
my $rowmax= $table? $#$table : -1; |
|
97
|
6
|
100
|
|
|
|
22
|
$row= -1 unless defined $row; |
|
98
|
6
|
|
|
|
|
13
|
$f->{table_idx}= $table_idx; |
|
99
|
6
|
|
|
|
|
13
|
${$f->{table_ref}}= $table; |
|
|
6
|
|
|
|
|
15
|
|
|
100
|
6
|
|
|
|
|
11
|
${$f->{row_ref}}= $row; |
|
|
6
|
|
|
|
|
12
|
|
|
101
|
6
|
|
|
|
|
11
|
${$f->{rowmax_ref}}= $rowmax; |
|
|
6
|
|
|
|
|
15
|
|
|
102
|
6
|
|
|
|
|
27
|
1; |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub Data::TableReader::Decoder::Mock::_Iter::next_dataset { |
|
106
|
6
|
|
|
6
|
|
16
|
my $self= shift; |
|
107
|
6
|
|
|
|
|
37
|
my $f= $self->_fields; |
|
108
|
|
|
|
|
|
|
return defined $f->{data}[ $f->{table_idx}+1 ] |
|
109
|
6
|
|
66
|
|
|
58
|
&& $self->seek([ $f->{table_idx}+1 ]); |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
__END__ |