line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Directory::Scanner::API::Stream; |
2
|
|
|
|
|
|
|
# ABSTRACT: Streaming directory iterator abstract interface |
3
|
|
|
|
|
|
|
|
4
|
9
|
|
|
9
|
|
44
|
use strict; |
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
189
|
|
5
|
9
|
|
|
9
|
|
35
|
use warnings; |
|
9
|
|
|
|
|
15
|
|
|
9
|
|
|
|
|
2941
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
8
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:STEVAN'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub head; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub is_done; |
13
|
|
|
|
|
|
|
sub is_closed; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub close; |
16
|
|
|
|
|
|
|
sub next; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub clone; # ( $dir => Path::Tiny ) |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
## ... |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub flatten { |
23
|
6
|
|
|
6
|
1
|
16
|
my ($self) = @_; |
24
|
6
|
|
|
|
|
13
|
my @results; |
25
|
6
|
|
|
|
|
20
|
while ( my $next = $self->next ) { |
26
|
29
|
|
|
|
|
830
|
push @results => $next; |
27
|
|
|
|
|
|
|
} |
28
|
6
|
|
|
|
|
36
|
return @results; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# IMPORTANT NOTE: |
32
|
|
|
|
|
|
|
# We have a bit of a recursive dependency issue here, which |
33
|
|
|
|
|
|
|
# is that these methods are being defined here as calls to |
34
|
|
|
|
|
|
|
# other classes, all of which also `do` this role. This means |
35
|
|
|
|
|
|
|
# that we need to lazy load things here so as to avoid load |
36
|
|
|
|
|
|
|
# ordering issues elsewhere. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub recurse { |
39
|
13
|
|
|
13
|
1
|
100
|
my ($self) = @_; |
40
|
13
|
|
|
|
|
2535
|
require Directory::Scanner::Stream::Recursive; |
41
|
13
|
|
|
|
|
63
|
Directory::Scanner::Stream::Recursive->new( stream => $self ); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub ignore { |
45
|
3
|
|
|
3
|
1
|
33
|
my ($self, $filter) = @_; |
46
|
3
|
|
|
|
|
377
|
require Directory::Scanner::Stream::Ignoring; |
47
|
3
|
|
|
|
|
15
|
Directory::Scanner::Stream::Ignoring->new( stream => $self, filter => $filter ); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub match { |
51
|
7
|
|
|
7
|
1
|
55
|
my ($self, $predicate) = @_; |
52
|
7
|
|
|
|
|
1439
|
require Directory::Scanner::Stream::Matching; |
53
|
7
|
|
|
|
|
33
|
Directory::Scanner::Stream::Matching->new( stream => $self, predicate => $predicate ); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub apply { |
57
|
2
|
|
|
2
|
1
|
13
|
my ($self, $function) = @_; |
58
|
2
|
|
|
|
|
350
|
require Directory::Scanner::Stream::Application; |
59
|
2
|
|
|
|
|
9
|
Directory::Scanner::Stream::Application->new( stream => $self, function => $function ); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub transform { |
63
|
3
|
|
|
3
|
1
|
768
|
my ($self, $transformer) = @_; |
64
|
3
|
|
|
|
|
674
|
require Directory::Scanner::Stream::Transformer; |
65
|
3
|
|
|
|
|
14
|
Directory::Scanner::Stream::Transformer->new( stream => $self, transformer => $transformer ); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
## ... |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# shhh, I shouldn't do this |
71
|
|
|
|
|
|
|
sub _log { |
72
|
0
|
|
|
0
|
|
|
my ($self, @msg) = @_; |
73
|
0
|
|
|
|
|
|
warn( @msg, "\n" ); |
74
|
0
|
|
|
|
|
|
return; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
__END__ |