TableData/Test/Spec/Basic.pm

filter: Statementstmt 90.9% 40 / 44 Branchbran 62.5% 5 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 84.6% 11 / 13 Podpod 0.0% 0 / 9 totaltotal 75.6% 56 / 74 CC 5 SCAR 6.9
CC
5
Cov
87%
get_row_hashref
6.0
get_next_item
2.0
_rows
2.0
CRAP 2.0
↑ Summary TableDataRole/Spec/Basic.pm »
1 package TableData::Test::Spec::Basic;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use Role::Tiny::With;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 with 'TableDataRole::Spec::Basic';
9  
10 2 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
11 2 our $DATE = '2023-11-25'; # DATE
12 2 our $DIST = 'TableData'; # DIST
13 2 our $VERSION = '0.2.6'; # VERSION
14  
15 2 my $rows = [
16 {a=>1, b=>2},
17 {a=>3, b=>4},
18 {a=>"5 2", b=>"6,2"},
19 ];
20 2 my $columns = [qw/a b/];
21  
22 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
23 1 my $class = shift;
24 1 bless {pos=>0}, $class;
25 }
26  
27 0 ▶sub _rows {
Subroutine _rows: not called CC=1 SCAR=6.9
28 0 $rows;
29 }
30  
31 9 ▶sub reset_iterator {
Subroutine reset_iterator: called CC=1 SCAR=0.0
Pod undocumented
32 9 my $self = shift;
33 9 $self->{pos} = 0;
34 }
35  
36 1 ▶sub get_iterator_pos {
Subroutine get_iterator_pos: called CC=1 SCAR=0.0
Pod undocumented
37 1 my $self = shift;
38 1 $self->{pos};
39 }
40  
41 32 ▶sub has_next_item {
Subroutine has_next_item: called CC=1 SCAR=0.0
Pod undocumented
42 32 my $self = shift;
43 32 $self->{pos} < @$rows;
44 }
45  
46 18 ▶sub get_next_item {
Subroutine get_next_item: called CC=2 SCAR=7.0
Pod undocumented
47 18 my $self = shift;
48 18 ▶ die "StopIteration" if $self->{pos} >= @$rows;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"pos"} >= @$rows 0 18 18
49 18 my $row_hashref = $rows->[ $self->{pos}++ ];
50 18 [map {$row_hashref->{$_}} @$columns];
51 }
52  
53 8 ▶sub get_next_row_hashref {
Subroutine get_next_row_hashref: called CC=2 SCAR=6.9
Pod undocumented
54 8 my $self = shift;
55 8 ▶ die "StopIteration" if $self->{pos} >= @$rows;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"pos"} >= @$rows 1 7 8
56 7 $rows->[ $self->{pos}++ ];
57 }
58  
59 0 ▶sub get_row_hashref {
Subroutine get_row_hashref: not called CC=2 SCAR=17.9
Pod undocumented
60 0 my $self = shift;
61 0 ▶ return unless $rows->[ $self->{index} ];
Branch: 1 branch
BranchTrueFalseTotal
unless $$rows[$self->{"index"}] 0 0 0
62 0 $rows->[ $self->{index}++ ];
63 }
64  
65 1 ▶sub get_column_count {
Subroutine get_column_count: called CC=1 SCAR=0.0
Pod undocumented
66 1 my $self = shift;
67 1 scalar(keys %{$rows->[0]});
68 }
69  
70 4 ▶sub get_column_names {
Subroutine get_column_names: called CC=2 SCAR=6.9
Pod undocumented
71 4 my $self = shift;
72 4 my @names = sort keys %{$rows->[0]};
73 4 ▶ wantarray ? @names : \@names;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 2 2 4
74 }
75  
76 2 1;
77  
78 # ABSTRACT: A test table data
79  
80 __END__
↑ Summary TableDataRole/Spec/Basic.pm »