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