line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TableData::Test::Spec::Basic; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
70097
|
use strict; |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
405
|
use Role::Tiny::With; |
|
1
|
|
|
|
|
5045
|
|
|
1
|
|
|
|
|
412
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
with 'TableDataRole::Spec::Basic'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
11
|
|
|
|
|
|
|
our $DATE = '2022-11-29'; # DATE |
12
|
|
|
|
|
|
|
our $DIST = 'TableData'; # DIST |
13
|
|
|
|
|
|
|
our $VERSION = '0.2.2'; # 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
|
113
|
my $class = shift; |
24
|
1
|
|
|
|
|
21
|
bless {pos=>0}, $class; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _rows { |
28
|
0
|
|
|
0
|
|
0
|
$rows; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub reset_iterator { |
32
|
9
|
|
|
9
|
0
|
8135
|
my $self = shift; |
33
|
9
|
|
|
|
|
21
|
$self->{pos} = 0; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub get_iterator_pos { |
37
|
1
|
|
|
1
|
0
|
5
|
my $self = shift; |
38
|
1
|
|
|
|
|
6
|
$self->{pos}; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub has_next_item { |
42
|
32
|
|
|
32
|
0
|
1134
|
my $self = shift; |
43
|
32
|
|
|
|
|
85
|
$self->{pos} < @$rows; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub get_next_item { |
47
|
18
|
|
|
18
|
0
|
46
|
my $self = shift; |
48
|
18
|
50
|
|
|
|
41
|
die "StopIteration" if $self->{pos} >= @$rows; |
49
|
18
|
|
|
|
|
39
|
my $row_hashref = $rows->[ $self->{pos}++ ]; |
50
|
18
|
|
|
|
|
61
|
[map {$row_hashref->{$_}} @$columns]; |
|
36
|
|
|
|
|
100
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub get_next_row_hashref { |
54
|
8
|
|
|
8
|
0
|
57
|
my $self = shift; |
55
|
8
|
100
|
|
|
|
27
|
die "StopIteration" if $self->{pos} >= @$rows; |
56
|
7
|
|
|
|
|
23
|
$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
|
2382
|
my $self = shift; |
67
|
1
|
|
|
|
|
2
|
scalar(keys %{$rows->[0]}); |
|
1
|
|
|
|
|
5
|
|
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub get_column_names { |
71
|
2
|
|
|
2
|
0
|
2458
|
my $self = shift; |
72
|
2
|
|
|
|
|
4
|
my @names = sort keys %{$rows->[0]}; |
|
2
|
|
|
|
|
11
|
|
73
|
2
|
50
|
|
|
|
21
|
wantarray ? @names : \@names; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# ABSTRACT: A test table data |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__END__ |