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