Scanner/StreamBuilder/Ignoring.pm

filter: Statementstmt 96.1% 50 / 52 Branchbran 70.0% 7 / 10 Conditioncond 40.0% 2 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 77.7% 14 / 18 Podpod 14.2% 1 / 7 totaltotal 77.8% 74 / 95 SCAR 20.9
CC
8
Cov
88%
BUILD
5.9
next
3.0
BEGIN
2.0
CRAP 8.1
« Scanner/StreamBuilder/Transformer.pm ↑ Summary Scanner/StreamBuilder/Matching.pm »
1 package Directory::Scanner::StreamBuilder::Ignoring;
2 # ABSTRACT: Ignoring files in the streaming directory iterator
3  
4 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 8 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 8 ▶use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 8 ▶use UNIVERSAL::Object;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 8 ▶use Directory::Scanner::API::Stream;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 8 our $VERSION = '0.01';
14 8 our $AUTHORITY = 'cpan:STEVAN';
15  
16 8 ▶use constant DEBUG => $ENV{DIR_SCANNER_STREAM_IGNORING_DEBUG} // 0;
Subroutine BEGIN: called CC=2 SCAR=7.1
Condition50%1/2
$ENV{"DIR_SCANNER_STREAM_IGNORING_DEBUG"} // 0
l!l
08
MC/DC0%0/1
$ENV{"DIR_SCANNER_STREAM_IGNORING_DEBUG"} // 0
$ENV{"DIR_SCANNER_STREAM_IGNORING_DEBUG"}
Truth table50%1/2
A
A= $ENV{"DIR_SCANNER_STREAM_IGNORING_DEBUG"}
Aresult
11
00
17  
18 ## ...
19  
20 8 ▶our @ISA; BEGIN { @ISA = ('UNIVERSAL::Object', 'Directory::Scanner::API::Stream') }
Subroutine BEGIN: called CC=1 SCAR=0.0
21 8 our %HAS; BEGIN {
22 %HAS = (
23 ▶ stream => sub {},
Subroutine __ANON__: not called CC=1 SCAR=0.0
24 ▶ filter => sub {},
Subroutine __ANON__: not called CC=1 SCAR=0.0
25 )
26 8 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 ## ...
29  
30 sub BUILD {
31 11 ▶ my $self = $_[0];
Subroutine BUILD: called CC=5 SCAR=17.8
Pod documented
32 11 my $stream = $self->{stream};
33 11 my $filter = $self->{filter};
34  
35 11 ▶ (Scalar::Util::blessed($stream) && $stream->DOES('Directory::Scanner::API::Stream'))
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($stream) and $stream->DOES("Directory::Scanner::API::Stream") or Carp::confess("You must supply a directory stream") 0 11 11
Condition33%1/3
builtin::blessed($stream) and $stream->DOES("Directory::Scanner::API::Stream")
!ll&&!rl&&r
0011
MC/DC0%0/2
builtin::blessed($stream) and $stream->DOES("Directory::Scanner::API::Stream")
builtin::blessed($stream) $stream->DOES("Directory::Scanner::API::Stream")
Truth table33%1/3
A and B
A= builtin::blessed($stream)B= $stream->DOES("Directory::Scanner::API::Stream")
ABresult
0X0
100
111
36 || Carp::confess 'You must supply a directory stream';
37  
38 11 ▶ (defined $filter)
Branch: 1 branch
BranchTrueFalseTotal
defined $filter or Carp::confess("You must supply a filter") 0 11 11
39 || Carp::confess 'You must supply a filter';
40  
41 11 ▶ (ref $filter eq 'CODE')
Branch: 1 branch
BranchTrueFalseTotal
ref $filter eq "CODE" or Carp::confess("The filter supplied must be a CODE reference") 0 11 11
42 || Carp::confess 'The filter supplied must be a CODE reference';
43 }
44  
45 sub clone {
46 8 ▶ my ($self, $dir) = @_;
Subroutine clone: called CC=1 SCAR=0.0
Pod undocumented
47 return $self->new(
48 stream => $self->{stream}->clone( $dir ),
49 filter => $self->{filter}
50 8 );
51 }
52  
53 ## delegate
54  
55 0 ▶sub head { $_[0]->{stream}->head }
Subroutine head: not called CC=1 SCAR=6.9
Pod undocumented
56 0 ▶sub is_done { $_[0]->{stream}->is_done }
Subroutine is_done: not called CC=1 SCAR=6.9
Pod undocumented
57 11 ▶sub is_closed { $_[0]->{stream}->is_closed }
Subroutine is_closed: called CC=1 SCAR=0.0
Pod undocumented
58 11 ▶sub close { $_[0]->{stream}->close }
Subroutine close: called CC=1 SCAR=0.0
Pod undocumented
59  
60 sub next {
61 19 ▶ my $self = $_[0];
Subroutine next: called CC=3 SCAR=11.0
Pod undocumented
62  
63 19 my $next;
64 19 while (1) {
65 31 undef $next; # clear any previous values, just cause ...
66 31 $self->_log('Entering loop ... ') if DEBUG;
67  
68 31 $next = $self->{stream}->next;
69  
70 # this means the stream is likely
71 # exhausted, so jump out of the loop
72 31 ▶ last unless defined $next;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $next 11 20 31
73  
74 # now try to filter the value
75 # and redo the loop if it does
76 # not pass
77 20 local $_ = $next;
78 20 ▶ next if $self->{filter}->( $next );
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"filter"}->($next) 12 8 20
79  
80 8 $self->_log('Exiting loop ... ') if DEBUG;
81  
82 # if we have gotten to this
83 # point, we have a value and
84 # want to return it
85 8 last;
86 }
87  
88 19 return $next;
89 }
90  
91 8 1;
92  
93 __END__
« Scanner/StreamBuilder/Transformer.pm ↑ Summary Scanner/StreamBuilder/Matching.pm »