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
« Flex/Cache.pm ↑ Summary 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.34';
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 throw_failure ];
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 8 ▶sub new ( $class, $code, $iterable, $pars = {} ) {
Subroutine new: called CC=3 SCAR=11.2
Pod documented
47 8 ▶ throw_failure( parameter => q{'code' parameter is not a coderef} )
Branch: 1 branch
BranchTrueFalseTotal
unless Ref::Util::XS::is_coderef($code) 0 8 8
48 unless Ref::Util::is_coderef( $code );
49  
50 8 $class->SUPER::new( { code => $code, src => $iterable }, $pars );
51 }
52  
53  
54 8 ▶sub construct ( $class, $state ) {
Subroutine construct: called CC=2 SCAR=7.1
Pod undocumented
55  
56 8 ▶ throw_failure( parameter => q{'state' parameter must be a HASH reference} )
Branch: 1 branch
BranchTrueFalseTotal
unless Ref::Util::XS::is_hashref($state) 0 8 8
57 unless Ref::Util::is_hashref( $state );
58  
59 8 my ( $code, $src ) = @{$state}{qw[ code src ]};
60  
61 8 $src
62 = to_iterator( $src, { ( +EXHAUSTION ) => THROW } );
63  
64 8 my $self;
65 my $iterator_state;
66  
67 return {
68 ( +_NAME ) => 'igrep',
69  
70 ( +_SELF ) => \$self,
71  
72 ( +STATE ) => \$iterator_state,
73  
74 28 ▶ ( +NEXT ) => sub {
Subroutine __ANON__: called CC=6 SCAR=18.7
75 28 ▶ return $self->signal_exhaustion
Branch: 1 branch
BranchTrueFalseTotal
if $iterator_state == 1 0 28 28
76 if $iterator_state == IterState_EXHAUSTED;
77  
78 28 my $rv;
79 eval {
80 28 while ( 1 ) {
81 39 local $_ = $rv = $src->();
82 31 ▶ return !!1 if $code->();
Branch: 1 branch
BranchTrueFalseTotal
if &$code() 20 11 31
83 }
84 0 !!1;
85 28 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
or do { die $@ unless Ref::Util::XS::is_blessed_ref($@) and $@->isa("Iterator::Flex::Failure::Exhausted"); return $self->signal_exhaustion } 20 8 28
86 8 ▶ die $@
Branch: 1 branch
BranchTrueFalseTotal
unless Ref::Util::XS::is_blessed_ref($@) and $@->isa("Iterator::Flex::Failure::Exhausted") 0 8 8
Condition33%1/3
Ref::Util::XS::is_blessed_ref($@) and $@->isa("Iterator::Flex::Failure::Exhausted")
!ll&&!rl&&r
008
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 8 return $self->signal_exhaustion;
90 };
91 20 return $rv;
92 },
93 2 ▶ ( +RESET ) => sub { },
Subroutine __ANON__: called CC=1 SCAR=0.0
94 8 ( +_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__
« Flex/Cache.pm ↑ Summary Flex/Map.pm »