line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Directory::Scanner::StreamBuilder::Ignoring; |
2
|
|
|
|
|
|
|
# ABSTRACT: Ignoring files in the streaming directory iterator |
3
|
|
|
|
|
|
|
|
4
|
8
|
|
|
8
|
|
43
|
use strict; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
192
|
|
5
|
8
|
|
|
8
|
|
37
|
use warnings; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
158
|
|
6
|
|
|
|
|
|
|
|
7
|
8
|
|
|
8
|
|
33
|
use Carp (); |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
102
|
|
8
|
8
|
|
|
8
|
|
35
|
use Scalar::Util (); |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
136
|
|
9
|
|
|
|
|
|
|
|
10
|
8
|
|
|
8
|
|
37
|
use UNIVERSAL::Object; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
156
|
|
11
|
8
|
|
|
8
|
|
40
|
use Directory::Scanner::API::Stream; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
398
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
14
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:STEVAN'; |
15
|
|
|
|
|
|
|
|
16
|
8
|
|
50
|
8
|
|
43
|
use constant DEBUG => $ENV{DIR_SCANNER_STREAM_IGNORING_DEBUG} // 0; |
|
8
|
|
|
|
|
30
|
|
|
8
|
|
|
|
|
538
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
## ... |
19
|
|
|
|
|
|
|
|
20
|
8
|
|
|
8
|
|
442
|
our @ISA; BEGIN { @ISA = ('UNIVERSAL::Object', 'Directory::Scanner::API::Stream') } |
21
|
|
|
|
|
|
|
our %HAS; BEGIN { |
22
|
|
|
|
|
|
|
%HAS = ( |
23
|
|
|
|
|
|
|
stream => sub {}, |
24
|
|
|
|
|
|
|
filter => sub {}, |
25
|
|
|
|
|
|
|
) |
26
|
8
|
|
|
8
|
|
2102
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
## ... |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub BUILD { |
31
|
11
|
|
|
11
|
1
|
717
|
my $self = $_[0]; |
32
|
11
|
|
|
|
|
19
|
my $stream = $self->{stream}; |
33
|
11
|
|
|
|
|
15
|
my $filter = $self->{filter}; |
34
|
|
|
|
|
|
|
|
35
|
11
|
50
|
33
|
|
|
92
|
(Scalar::Util::blessed($stream) && $stream->DOES('Directory::Scanner::API::Stream')) |
36
|
|
|
|
|
|
|
|| Carp::confess 'You must supply a directory stream'; |
37
|
|
|
|
|
|
|
|
38
|
11
|
50
|
|
|
|
28
|
(defined $filter) |
39
|
|
|
|
|
|
|
|| Carp::confess 'You must supply a filter'; |
40
|
|
|
|
|
|
|
|
41
|
11
|
50
|
|
|
|
34
|
(ref $filter eq 'CODE') |
42
|
|
|
|
|
|
|
|| Carp::confess 'The filter supplied must be a CODE reference'; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub clone { |
46
|
8
|
|
|
8
|
1
|
17
|
my ($self, $dir) = @_; |
47
|
|
|
|
|
|
|
return $self->new( |
48
|
|
|
|
|
|
|
stream => $self->{stream}->clone( $dir ), |
49
|
|
|
|
|
|
|
filter => $self->{filter} |
50
|
8
|
|
|
|
|
25
|
); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
## delegate |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
0
|
1
|
0
|
sub head { $_[0]->{stream}->head } |
56
|
0
|
|
|
0
|
1
|
0
|
sub is_done { $_[0]->{stream}->is_done } |
57
|
11
|
|
|
11
|
1
|
33
|
sub is_closed { $_[0]->{stream}->is_closed } |
58
|
11
|
|
|
11
|
1
|
25
|
sub close { $_[0]->{stream}->close } |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub next { |
61
|
19
|
|
|
19
|
1
|
28
|
my $self = $_[0]; |
62
|
|
|
|
|
|
|
|
63
|
19
|
|
|
|
|
27
|
my $next; |
64
|
19
|
|
|
|
|
27
|
while (1) { |
65
|
31
|
|
|
|
|
144
|
undef $next; # clear any previous values, just cause ... |
66
|
31
|
|
|
|
|
38
|
$self->_log('Entering loop ... ') if DEBUG; |
67
|
|
|
|
|
|
|
|
68
|
31
|
|
|
|
|
94
|
$next = $self->{stream}->next; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# this means the stream is likely |
71
|
|
|
|
|
|
|
# exhausted, so jump out of the loop |
72
|
31
|
100
|
|
|
|
68
|
last unless defined $next; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# now try to filter the value |
75
|
|
|
|
|
|
|
# and redo the loop if it does |
76
|
|
|
|
|
|
|
# not pass |
77
|
20
|
|
|
|
|
31
|
local $_ = $next; |
78
|
20
|
100
|
|
|
|
44
|
next if $self->{filter}->( $next ); |
79
|
|
|
|
|
|
|
|
80
|
8
|
|
|
|
|
92
|
$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
|
|
|
|
|
12
|
last; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
19
|
|
|
|
|
54
|
return $next; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__END__ |