line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
## no critic: TestingAndDebugging::RequireUseStrict |
2
|
|
|
|
|
|
|
package TableDataRole::Spec::Basic; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
445
|
use Role::Tiny; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
7
|
|
|
|
|
|
|
our $DATE = '2023-04-19'; # DATE |
8
|
|
|
|
|
|
|
our $DIST = 'TableData'; # DIST |
9
|
|
|
|
|
|
|
our $VERSION = '0.2.3'; # VERSION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# constructor |
12
|
|
|
|
|
|
|
requires 'new'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# mixin |
15
|
|
|
|
|
|
|
with 'Role::TinyCommons::Iterator::Resettable'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# additional method names to return hashref |
18
|
|
|
|
|
|
|
requires 'get_next_row_hashref'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# column information |
21
|
|
|
|
|
|
|
requires 'get_column_count'; |
22
|
|
|
|
|
|
|
requires 'get_column_names'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
### |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# aliases, for convenience and clarity |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub has_next_row { |
29
|
3
|
|
|
3
|
1
|
6
|
my $self = shift; |
30
|
3
|
|
|
|
|
9
|
$self->has_next_item(@_); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub get_next_row_arrayref { |
34
|
2
|
|
|
2
|
1
|
4
|
my $self = shift; |
35
|
2
|
|
|
|
|
6
|
$self->get_next_item(@_); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub get_row_count { |
39
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
40
|
1
|
|
|
|
|
6
|
$self->get_item_count(@_); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub get_all_rows_arrayref { |
44
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
45
|
1
|
|
|
|
|
3
|
$self->get_all_items(@_); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub get_all_rows_hashref { |
49
|
1
|
|
|
1
|
1
|
2367
|
my $self = shift; |
50
|
|
|
|
|
|
|
|
51
|
1
|
|
|
|
|
3
|
my @items; |
52
|
1
|
|
|
|
|
4
|
$self->reset_iterator; |
53
|
1
|
|
|
|
|
7
|
while ($self->has_next_item) { |
54
|
3
|
|
|
|
|
7
|
my $row = $self->get_next_row_hashref; |
55
|
3
|
|
|
|
|
7
|
push @items, $row; |
56
|
|
|
|
|
|
|
} |
57
|
1
|
|
|
|
|
7
|
@items; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub each_row_arrayref { |
61
|
1
|
|
|
1
|
1
|
486
|
my $self = shift; |
62
|
1
|
|
|
|
|
5
|
$self->each_item(@_); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub each_row_hashref { |
66
|
1
|
|
|
1
|
1
|
1942
|
my ($self, $coderef) = @_; |
67
|
|
|
|
|
|
|
|
68
|
1
|
|
|
|
|
4
|
$self->reset_iterator; |
69
|
1
|
|
|
|
|
2
|
my $index = 0; |
70
|
1
|
|
|
|
|
4
|
while ($self->has_next_item) { |
71
|
3
|
|
|
|
|
7
|
my $row = $self->get_next_row_hashref; |
72
|
3
|
|
|
|
|
6
|
my $res = $coderef->($row, $self, $index); |
73
|
3
|
50
|
|
|
|
11
|
return 0 unless $res; |
74
|
3
|
|
|
|
|
6
|
$index++; |
75
|
|
|
|
|
|
|
} |
76
|
1
|
|
|
|
|
3
|
return 1; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
# ABSTRACT: Basic interface for all TableData::* modules |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__END__ |