| 1 | package File::KDBX::Iterator; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: KDBX database iterator | ||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | 12 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 12 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 12 | ▶ | use File::KDBX::Error; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 12 | ▶ | use File::KDBX::Util qw(:class :load :search); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 12 | ▶ | use Iterator::Simple; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 12 | ▶ | use Module::Loaded; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 12 | ▶ | use Ref::Util qw(is_arrayref is_coderef is_ref is_scalarref); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 12 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 12 | ▶ | BEGIN { mark_as_loaded('Iterator::Simple::Iterator') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 12 | extends 'Iterator::Simple::Iterator'; | |||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 12 | our $VERSION = '0.905'; # VERSION | |||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | sub new { | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 818 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 818 | ▶ | my $code = is_coderef($_[0]) ? shift : sub { undef }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 818 | ▶ | my $items = @_ == 1 && is_arrayref($_[0]) ? $_[0] : \@_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ == 1 and Ref::Util::XS::is_arrayref($_[0])
MC/DC0%0/2
@_ == 1 and Ref::Util::XS::is_arrayref($_[0])
@_ == 1
Ref::Util::XS::is_arrayref($_[0])
Truth table33%1/3
A and B
A= @_ == 1B= Ref::Util::XS::is_arrayref($_[0])
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | return $class->SUPER::new(sub { | ||||||||||||||||||||||||||||||||||||||||||
| 26 | 1983 | ▶ | if (@_) { # put back | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.1
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 25 | ▶ | if (@_ == 1 && is_arrayref($_[0])) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@_ == 1 and Ref::Util::XS::is_arrayref($_[0])
MC/DC100%2/2
@_ == 1 and Ref::Util::XS::is_arrayref($_[0])
@_ == 1
Ref::Util::XS::is_arrayref($_[0])
Truth table100%3/3
A and B
A= @_ == 1B= Ref::Util::XS::is_arrayref($_[0])
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 22 | $items = $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||
| 30 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 3 | unshift @$items, @_; | |||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 25 | return; | |||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||
| 35 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 36 | 1958 | my $next = shift @$items; | |||||||||||||||||||||||||||||||||||||||||
| 37 | 1958 | ▶ | return $next if defined $next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 1859 | return $code->(); | |||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||
| 40 | 818 | }); | |||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | sub next { | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 1167 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
next: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 1167 | ▶ | my $code = shift or return $self->(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 329 | $code = query_any($code, @_); | |||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 329 | ▶ | while (defined (local $_ = $self->())) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 331 | ▶ | return $_ if $code->($_); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 311 | return; | |||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | sub peek { | ||||||||||||||||||||||||||||||||||||||||||
| 58 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
peek: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | 2 | my $next = $self->(); | |||||||||||||||||||||||||||||||||||||||||
| 61 | 2 | ▶ | $self->($next) if defined $next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 2 | return $next; | |||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | sub unget { | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 1 | ▶ | my $self = shift; # Must shift in a statement before calling. | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unget: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 1 | $self->(@_); | |||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | sub each { | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 27 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
each: called CC=6 SCAR=19.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 27 | ▶ | my $cb = shift or return @{$self->to_array}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 23 | ▶ | if (is_coderef($cb)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 23 | my $count = 0; | |||||||||||||||||||||||||||||||||||||||||
| 78 | 23 | ▶ | $cb->($_, $count++, @_) while defined (local $_ = $self->()); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | elsif (!is_ref($cb)) { | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | $_->$cb(@_) while defined (local $_ = $self->()); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | 23 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | 2 | ▶ | sub where { shift->grep(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
where: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | sub grep { | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 30 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
grep: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | 30 | my $code = query_any(@_); | |||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | ref($self)->new(sub { | ||||||||||||||||||||||||||||||||||||||||||
| 94 | 35 | ▶ | while (defined (local $_ = $self->())) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 54 | ▶ | return $_ if $code->($_); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 7 | return; | |||||||||||||||||||||||||||||||||||||||||
| 98 | 30 | }); | |||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | sub map { | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 21 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
map: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 21 | my $code = shift; | |||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | ref($self)->new(sub { | ||||||||||||||||||||||||||||||||||||||||||
| 107 | 112 | ▶ | local $_ = $self->(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 112 | ▶ | return if !defined $_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 93 | return $code->(); | |||||||||||||||||||||||||||||||||||||||||
| 110 | 21 | }); | |||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | sub order_by { | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 5 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
order_by: called CC=17 SCAR=30.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 5 | my $field = shift; | |||||||||||||||||||||||||||||||||||||||||
| 117 | 5 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 5 | ▶ | my $ascending = delete $args{ascending} // !delete $args{descending} // 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition60%3/5
(delete $args{"ascending"} // !delete $args{"descending"}) // 1
delete $args{"ascending"} // !delete $args{"descending"}
MC/DC0%0/2
(delete $args{"ascending"} // !delete $args{"descending"}) // 1
delete $args{"ascending"}
!delete $args{"descending"}
Truth table66%2/3
A // not(B)
A= delete $args{"ascending"}B= !delete $args{"descending"}
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | 5 | ▶ | my $case = delete $args{case} // !delete $args{no_case} // 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition60%3/5
(delete $args{"case"} // !delete $args{"no_case"}) // 1
delete $args{"case"} // !delete $args{"no_case"}
MC/DC0%0/2
(delete $args{"case"} // !delete $args{"no_case"}) // 1
delete $args{"case"}
!delete $args{"no_case"}
Truth table66%2/3
A // not(B)
A= delete $args{"case"}B= !delete $args{"no_case"}
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | 5 | ▶ | my $collate = (delete $args{collate} // !delete $args{no_collate} // 1) | ||||||||||||||||||||||||||||||||||||||||
|
Condition62%5/8
((delete $args{'collate'} // !delete $args{'no_collate'}) // 1) && try_load_optional('Unicode::Collate')
(delete $args{"collate"} // !delete $args{"no_collate"}) // 1
delete $args{"collate"} // !delete $args{"no_collate"}
MC/DC0%0/3
((delete $args{'collate'} // !delete $args{'no_collate'}) // 1) && try_load_optional('Unicode::Collate')
delete $args{"collate"}
!delete $args{"no_collate"}
try_load_optional('Unicode::Collate')
Truth table20%1/5
A // not(B) && C
A= delete $args{"collate"}B= !delete $args{"no_collate"}C= try_load_optional('Unicode::Collate')
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | && try_load_optional('Unicode::Collate'); | ||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | 5 | ▶ | if ($collate && !$case) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$collate and not $case
MC/DC50%1/2
$collate and not $case
$collate
not $case
Truth table66%2/3
A and not(B)
A= $collateB= not $case
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 1 | $case = 1; | |||||||||||||||||||||||||||||||||||||||||
| 126 | # use a proper Unicode::Collate level to ignore case | ||||||||||||||||||||||||||||||||||||||||||
| 127 | 1 | ▶ | $args{level} //= 2; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{"level"} //= 2
MC/DC0%0/1
$args{"level"} //= 2
$args{"level"}
Truth table50%1/2
A
A= $args{"level"}
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 5 | ▶ | $args{upper_before_lower} //= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{"upper_before_lower"} //= 1
MC/DC0%0/1
$args{"upper_before_lower"} //= 1
$args{"upper_before_lower"}
Truth table50%1/2
A
A= $args{"upper_before_lower"}
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 5 | my $value = $field; | |||||||||||||||||||||||||||||||||||||||||
| 132 | 5 | ▶ | $value = $case ? sub { $_[0]->$field // '' } : sub { uc($_[0]->$field) // '' } if !is_coderef($value); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.3
Branch: 2 branches
Condition50%2/4
$_[0]->$field // ""
uc $_[0]->$field // ""
MC/DC0%0/1
$_[0]->$field // ""
$_[0]->$field
MC/DC0%0/1
uc $_[0]->$field // ""
uc $_[0]->$field
Truth table50%1/2
A
A= $_[0]->$field
Truth table50%1/2
A
A= uc $_[0]->$field
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | 5 | my @all = CORE::map { [$_, $value->($_)] } @{$self->to_array}; | |||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 5 | ▶ | if ($collate) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | 1 | my $c = Unicode::Collate->new(%args); | |||||||||||||||||||||||||||||||||||||||||
| 137 | 1 | ▶ | if ($ascending) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 1 | @all = CORE::map { $_->[0] } CORE::sort { $c->cmp($a->[1], $b->[1]) } @all; | |||||||||||||||||||||||||||||||||||||||||
| 139 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | @all = CORE::map { $_->[0] } CORE::sort { $c->cmp($b->[1], $a->[1]) } @all; | |||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||
| 142 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 143 | 4 | ▶ | if ($ascending) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | 2 | @all = CORE::map { $_->[0] } CORE::sort { $a->[1] cmp $b->[1] } @all; | |||||||||||||||||||||||||||||||||||||||||
| 145 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 2 | @all = CORE::map { $_->[0] } CORE::sort { $b->[1] cmp $a->[1] } @all; | |||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 5 | $self->(\@all); | |||||||||||||||||||||||||||||||||||||||||
| 151 | 5 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | 5 | ▶ | sub sort_by { shift->order_by(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sort_by: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | sub norder_by { | ||||||||||||||||||||||||||||||||||||||||||
| 159 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
norder_by: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | 2 | my $field = shift; | |||||||||||||||||||||||||||||||||||||||||
| 161 | 2 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | 2 | ▶ | my $ascending = $args{ascending} // !$args{descending} // 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition60%3/5
($args{"ascending"} // !$args{"descending"}) // 1
$args{"ascending"} // !$args{"descending"}
MC/DC0%0/2
($args{"ascending"} // !$args{"descending"}) // 1
$args{"ascending"}
!$args{"descending"}
Truth table66%2/3
A // not(B)
A= $args{"ascending"}B= !$args{"descending"}
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 2 | my $value = $field; | |||||||||||||||||||||||||||||||||||||||||
| 166 | 2 | ▶ | $value = sub { $_[0]->$field // 0 } if !is_coderef($value); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
Condition50%1/2
$_[0]->$field // 0
MC/DC0%0/1
$_[0]->$field // 0
$_[0]->$field
Truth table50%1/2
A
A= $_[0]->$field
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | 2 | my @all = CORE::map { [$_, $value->($_)] } @{$self->to_array}; | |||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | 2 | ▶ | if ($ascending) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | 1 | @all = CORE::map { $_->[0] } CORE::sort { $a->[1] <=> $b->[1] } @all; | |||||||||||||||||||||||||||||||||||||||||
| 171 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 172 | 1 | @all = CORE::map { $_->[0] } CORE::sort { $b->[1] <=> $a->[1] } @all; | |||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | 2 | $self->(\@all); | |||||||||||||||||||||||||||||||||||||||||
| 176 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 2 | ▶ | sub nsort_by { shift->norder_by(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nsort_by: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | 1 | ▶ | sub limit { shift->head(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
limit: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | sub to_array { | ||||||||||||||||||||||||||||||||||||||||||
| 187 | 45 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_array: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | 45 | my @all; | |||||||||||||||||||||||||||||||||||||||||
| 190 | 45 | ▶ | push @all, $_ while defined (local $_ = $self->()); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | 45 | return \@all; | |||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | sub count { | ||||||||||||||||||||||||||||||||||||||||||
| 196 | 14 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
count: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | 14 | my $items = $self->to_array; | |||||||||||||||||||||||||||||||||||||||||
| 199 | 14 | $self->($items); | |||||||||||||||||||||||||||||||||||||||||
| 200 | 14 | return scalar @$items; | |||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | 10 | ▶ | sub size { shift->count } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
size: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | sub TO_JSON { $_[0]->to_array } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TO_JSON: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | 12 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | __END__ | ||||||||||||||||||||||||||||||||||||||||||