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