line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TableData::Test::Spec::Basic; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
4
|
|
|
|
|
|
|
our $DATE = '2021-06-01'; # DATE |
5
|
|
|
|
|
|
|
our $DIST = 'TableData'; # DIST |
6
|
|
|
|
|
|
|
our $VERSION = '0.2.1'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
64442
|
use strict; |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
27
|
|
9
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
478
|
use Role::Tiny::With; |
|
1
|
|
|
|
|
4414
|
|
|
1
|
|
|
|
|
331
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
with 'TableDataRole::Spec::Basic'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $rows = [ |
16
|
|
|
|
|
|
|
{a=>1, b=>2}, |
17
|
|
|
|
|
|
|
{a=>3, b=>4}, |
18
|
|
|
|
|
|
|
{a=>"5 2", b=>"6,2"}, |
19
|
|
|
|
|
|
|
]; |
20
|
|
|
|
|
|
|
my $columns = [qw/a b/]; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new { |
23
|
1
|
|
|
1
|
0
|
92
|
my $class = shift; |
24
|
1
|
|
|
|
|
6
|
bless {pos=>0}, $class; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _rows { |
28
|
0
|
|
|
0
|
|
0
|
$rows; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub reset_iterator { |
32
|
9
|
|
|
9
|
0
|
6861
|
my $self = shift; |
33
|
9
|
|
|
|
|
19
|
$self->{pos} = 0; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub get_iterator_pos { |
37
|
1
|
|
|
1
|
0
|
4
|
my $self = shift; |
38
|
1
|
|
|
|
|
5
|
$self->{pos}; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub has_next_item { |
42
|
32
|
|
|
32
|
0
|
1156
|
my $self = shift; |
43
|
32
|
|
|
|
|
76
|
$self->{pos} < @$rows; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub get_next_item { |
47
|
18
|
|
|
18
|
0
|
41
|
my $self = shift; |
48
|
18
|
50
|
|
|
|
34
|
die "StopIteration" if $self->{pos} >= @$rows; |
49
|
18
|
|
|
|
|
43
|
my $row_hashref = $rows->[ $self->{pos}++ ]; |
50
|
18
|
|
|
|
|
28
|
[map {$row_hashref->{$_}} @$columns]; |
|
36
|
|
|
|
|
84
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub get_next_row_hashref { |
54
|
8
|
|
|
8
|
0
|
49
|
my $self = shift; |
55
|
8
|
100
|
|
|
|
26
|
die "StopIteration" if $self->{pos} >= @$rows; |
56
|
7
|
|
|
|
|
19
|
$rows->[ $self->{pos}++ ]; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub get_row_hashref { |
60
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
61
|
0
|
0
|
|
|
|
0
|
return undef unless $rows->[ $self->{index} ]; |
62
|
0
|
|
|
|
|
0
|
$rows->[ $self->{index}++ ]; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub get_column_count { |
66
|
1
|
|
|
1
|
0
|
1974
|
my $self = shift; |
67
|
1
|
|
|
|
|
2
|
scalar(keys %{$rows->[0]}); |
|
1
|
|
|
|
|
6
|
|
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub get_column_names { |
71
|
2
|
|
|
2
|
0
|
2105
|
my $self = shift; |
72
|
2
|
|
|
|
|
4
|
my @names = sort keys %{$rows->[0]}; |
|
2
|
|
|
|
|
14
|
|
73
|
2
|
50
|
|
|
|
14
|
wantarray ? @names : \@names; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# ABSTRACT: A test table data |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__END__ |