blib/lib/Iterator/Flex/Grep.pm

filter: Statementstmt 97.9% 47 / 48 Branchbran 66.6% 8 / 12 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 13 / 13 Podpod 50.0% 1 / 2 totaltotal 87.5% 70 / 80 CC 9 SCAR 10.9
CC
9
Cov
89%
__ANON__
6.5
new
3.1
construct
2.0
CRAP 3.0
« blib/lib/Iterator/Flex/Cat.pm ↑ Summary blib/lib/Iterator/Flex/Map.pm »
1 package Iterator::Flex::Grep;
2  
3 # ABSTRACT: Grep Iterator Class
4  
5 5 ▶use v5.28;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use experimental 'signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 5 our $VERSION = '0.33';
11  
12 5 ▶use Iterator::Flex::Factory 'to_iterator';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 5 ▶use Iterator::Flex::Utils qw[ THROW STATE EXHAUSTION :IterAttrs :IterStates ];
Subroutine BEGIN: called CC=1 SCAR=0.0
14 5 ▶use Ref::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 5 ▶use parent 'Iterator::Flex::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 5 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46 7 ▶sub new ( $class, $code, $iterable, $pars = {} ) {
Subroutine new: called CC=3 SCAR=11.2
Pod documented
47 7 ▶ throw_failure( parameter => q{'code' parameter is not a coderef} )
Branch: 1 branch
BranchTrueFalseTotal
unless Ref::Util::XS::is_coderef($code) 0 7 7
48 unless Ref::Util::is_coderef( $code );
49  
50 7 $class->SUPER::new( { code => $code, src => $iterable }, $pars );
51 }
52  
53  
54 ▶sub construct ( $class, $state ) {
Subroutine construct: called CC=2 SCAR=7.1
Pod undocumented
55  
56 7 ▶ throw_failure( parameter => q{'state' parameter must be a HASH reference} )
Branch: 1 branch
BranchTrueFalseTotal
unless Ref::Util::XS::is_hashref($state) 0 7 7
57 unless Ref::Util::is_hashref( $state );
58  
59 7 my ( $code, $src ) = @{$state}{qw[ code src ]};
60  
61 7 $src
62 = to_iterator( $src, { ( +EXHAUSTION ) => THROW } );
63  
64 7 my $self;
65 my $iterator_state;
66  
67 return {
68 ( +_NAME ) => 'igrep',
69  
70 ( +_SELF ) => \$self,
71  
72 ( +STATE ) => \$iterator_state,
73  
74 ( +NEXT ) => sub {
75 24 ▶ return $self->signal_exhaustion
Subroutine __ANON__: called CC=6 SCAR=18.7
Branch: 1 branch
BranchTrueFalseTotal
if $iterator_state == 1 0 24 24
76 if $iterator_state == IterState_EXHAUSTED;
77  
78 my $ret = eval {
79 24 while ( 1 ) {
80 35 my $rv = $src->();
81 28 local $_ = $rv;
82 28 ▶ return $rv if $code->();
Branch: 1 branch
BranchTrueFalseTotal
if &$code() 17 11 28
83 }
84 0 1;
85 24 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
my $ret = eval { do { while (1) { my $rv = &$src(); local $_ = $rv; return $rv if &$code(); } ; 1 } } or do { die $@ unless Ref::Util::XS::is_blessed_ref($@) and $@->isa("Iterator::Flex::Failure::Exhausted"); return $self->signal_exhaustion } 7 17 24
86 7 ▶ die $@
Branch: 1 branch
BranchTrueFalseTotal
unless Ref::Util::XS::is_blessed_ref($@) and $@->isa("Iterator::Flex::Failure::Exhausted") 0 7 7
Condition33%1/3
Ref::Util::XS::is_blessed_ref($@) and $@->isa("Iterator::Flex::Failure::Exhausted")
!ll&&!rl&&r
007
MC/DC0%0/2
Ref::Util::XS::is_blessed_ref($@) and $@->isa("Iterator::Flex::Failure::Exhausted")
Ref::Util::XS::is_blessed_ref($@) $@->isa("Iterator::Flex::Failure::Exhausted")
Truth table33%1/3
A and B
A= Ref::Util::XS::is_blessed_ref($@)B= $@->isa("Iterator::Flex::Failure::Exhausted")
ABresult
0X0
100
111
87 unless Ref::Util::is_blessed_ref( $@ )
88 && $@->isa( 'Iterator::Flex::Failure::Exhausted' );
89 7 return $self->signal_exhaustion;
90 };
91 17 return $ret;
92 },
93 ▶ ( +RESET ) => sub { },
Subroutine __ANON__: called CC=1 SCAR=0.0
94 7 ( +_DEPENDS ) => $src,
95 };
96 }
97  
98 5 __PACKAGE__->_add_roles( qw[
99 State::Closure
100 Next::ClosedSelf
101 Rewind::Closure
102 Reset::Closure
103 Current::Closure
104 ] );
105  
106 5 1;
107  
108 #
109 # This file is part of Iterator-Flex
110 #
111 # This software is Copyright (c) 2018 by Smithsonian Astrophysical Observatory.
112 #
113 # This is free software, licensed under:
114 #
115 # The GNU General Public License, Version 3, June 2007
116 #
117  
118 __END__
« blib/lib/Iterator/Flex/Cat.pm ↑ Summary blib/lib/Iterator/Flex/Map.pm »