| 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
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"}
| |||||||||||||||||||||||||||||
| 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
Condition33%1/3
builtin::blessed($stream) and $stream->DOES("Directory::Scanner::API::Stream")
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")
| |||||||||||||||||||||||||||||
| 36 | || Carp::confess 'You must supply a directory stream'; | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 11 | ▶ | (defined $filter) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | || Carp::confess 'You must supply a filter'; | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 11 | ▶ | (ref $filter eq 'CODE') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||