line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
## no critic: TestingAndDebugging::RequireUseStrict |
2
|
|
|
|
|
|
|
package TableDataRole::Spec::Basic; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
496
|
use Role::Tiny; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
5
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
7
|
|
|
|
|
|
|
our $DATE = '2022-11-29'; # DATE |
8
|
|
|
|
|
|
|
our $DIST = 'TableData'; # DIST |
9
|
|
|
|
|
|
|
our $VERSION = '0.2.2'; # 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
|
|
|
|
|
29
|
$self->has_next_item(@_); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub get_next_row_arrayref { |
34
|
2
|
|
|
2
|
1
|
9
|
my $self = shift; |
35
|
2
|
|
|
|
|
7
|
$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
|
2
|
my $self = shift; |
45
|
1
|
|
|
|
|
5
|
$self->get_all_items(@_); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub get_all_rows_hashref { |
49
|
1
|
|
|
1
|
1
|
2896
|
my $self = shift; |
50
|
|
|
|
|
|
|
|
51
|
1
|
|
|
|
|
2
|
my @items; |
52
|
1
|
|
|
|
|
3
|
$self->reset_iterator; |
53
|
1
|
|
|
|
|
8
|
while ($self->has_next_item) { |
54
|
3
|
|
|
|
|
10
|
my $row = $self->get_next_row_hashref; |
55
|
3
|
|
|
|
|
8
|
push @items, $row; |
56
|
|
|
|
|
|
|
} |
57
|
1
|
|
|
|
|
14
|
@items; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub each_row_arrayref { |
61
|
1
|
|
|
1
|
1
|
579
|
my $self = shift; |
62
|
1
|
|
|
|
|
6
|
$self->each_item(@_); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub each_row_hashref { |
66
|
1
|
|
|
1
|
1
|
2398
|
my ($self, $coderef) = @_; |
67
|
|
|
|
|
|
|
|
68
|
1
|
|
|
|
|
4
|
$self->reset_iterator; |
69
|
1
|
|
|
|
|
4
|
my $index = 0; |
70
|
1
|
|
|
|
|
9
|
while ($self->has_next_item) { |
71
|
3
|
|
|
|
|
7
|
my $row = $self->get_next_row_hashref; |
72
|
3
|
|
|
|
|
9
|
my $res = $coderef->($row, $self, $index); |
73
|
3
|
50
|
|
|
|
12
|
return 0 unless $res; |
74
|
3
|
|
|
|
|
7
|
$index++; |
75
|
|
|
|
|
|
|
} |
76
|
1
|
|
|
|
|
3
|
return 1; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
# ABSTRACT: Basic interface for all TableData::* modules |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__END__ |