line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Directory::Scanner; |
2
|
|
|
|
|
|
|
# ABSTRACT: Streaming directory scanner |
3
|
|
|
|
|
|
|
|
4
|
8
|
|
|
8
|
|
452090
|
use strict; |
|
8
|
|
|
|
|
82
|
|
|
8
|
|
|
|
|
207
|
|
5
|
8
|
|
|
8
|
|
38
|
use warnings; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
159
|
|
6
|
|
|
|
|
|
|
|
7
|
8
|
|
|
8
|
|
36
|
use Carp (); |
|
8
|
|
|
|
|
10
|
|
|
8
|
|
|
|
|
92
|
|
8
|
8
|
|
|
8
|
|
31
|
use Scalar::Util (); |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
124
|
|
9
|
|
|
|
|
|
|
|
10
|
8
|
|
|
8
|
|
1928
|
use Directory::Scanner::API::Stream; |
|
8
|
|
|
|
|
21
|
|
|
8
|
|
|
|
|
217
|
|
11
|
|
|
|
|
|
|
|
12
|
8
|
|
|
8
|
|
1937
|
use Directory::Scanner::Stream; |
|
8
|
|
|
|
|
20
|
|
|
8
|
|
|
|
|
211
|
|
13
|
|
|
|
|
|
|
|
14
|
8
|
|
|
8
|
|
2198
|
use Directory::Scanner::StreamBuilder::Concat; |
|
8
|
|
|
|
|
19
|
|
|
8
|
|
|
|
|
202
|
|
15
|
8
|
|
|
8
|
|
2088
|
use Directory::Scanner::StreamBuilder::Recursive; |
|
8
|
|
|
|
|
18
|
|
|
8
|
|
|
|
|
203
|
|
16
|
8
|
|
|
8
|
|
2079
|
use Directory::Scanner::StreamBuilder::Matching; |
|
8
|
|
|
|
|
20
|
|
|
8
|
|
|
|
|
226
|
|
17
|
8
|
|
|
8
|
|
2018
|
use Directory::Scanner::StreamBuilder::Ignoring; |
|
8
|
|
|
|
|
20
|
|
|
8
|
|
|
|
|
190
|
|
18
|
8
|
|
|
8
|
|
2058
|
use Directory::Scanner::StreamBuilder::Application; |
|
8
|
|
|
|
|
19
|
|
|
8
|
|
|
|
|
168
|
|
19
|
8
|
|
|
8
|
|
1943
|
use Directory::Scanner::StreamBuilder::Transformer; |
|
8
|
|
|
|
|
18
|
|
|
8
|
|
|
|
|
2874
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
22
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:STEVAN'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
## static builder constructors |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub for { |
27
|
15
|
|
|
15
|
0
|
25924
|
my (undef, $dir) = @_; |
28
|
15
|
|
|
|
|
81
|
return bless [ $dir ] => __PACKAGE__; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub concat { |
32
|
1
|
|
|
1
|
0
|
4
|
my (undef, @streams) = @_; |
33
|
|
|
|
|
|
|
|
34
|
1
|
50
|
|
|
|
4
|
Carp::confess 'You provide at least two streams to concat' |
35
|
|
|
|
|
|
|
if scalar @streams < 2; |
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
|
|
12
|
return Directory::Scanner::StreamBuilder::Concat->new( streams => [ @streams ] ); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
## builder instance methods |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub recurse { |
43
|
12
|
|
|
12
|
0
|
27
|
my ($builder) = @_; |
44
|
12
|
|
|
|
|
49
|
push @$builder => [ 'Directory::Scanner::StreamBuilder::Recursive' ]; |
45
|
12
|
|
|
|
|
71
|
return $builder; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub ignore { |
49
|
3
|
|
|
3
|
0
|
11
|
my ($builder, $filter) = @_; |
50
|
|
|
|
|
|
|
# XXX - should this support using at .gitignore files? |
51
|
3
|
|
|
|
|
14
|
push @$builder => [ 'Directory::Scanner::StreamBuilder::Ignoring', filter => $filter ]; |
52
|
3
|
|
|
|
|
15
|
return $builder; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub match { |
56
|
6
|
|
|
6
|
0
|
16
|
my ($builder, $predicate) = @_; |
57
|
6
|
|
|
|
|
26
|
push @$builder => [ 'Directory::Scanner::StreamBuilder::Matching', predicate => $predicate ]; |
58
|
6
|
|
|
|
|
24
|
return $builder; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub apply { |
62
|
2
|
|
|
2
|
0
|
5
|
my ($builder, $function) = @_; |
63
|
2
|
|
|
|
|
6
|
push @$builder => [ 'Directory::Scanner::StreamBuilder::Application', function => $function ]; |
64
|
2
|
|
|
|
|
5
|
return $builder; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub transform { |
68
|
2
|
|
|
2
|
0
|
5
|
my ($builder, $transformer) = @_; |
69
|
2
|
|
|
|
|
5
|
push @$builder => [ 'Directory::Scanner::StreamBuilder::Transformer', transformer => $transformer ]; |
70
|
2
|
|
|
|
|
6
|
return $builder; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
## builder method |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub stream { |
76
|
15
|
|
|
15
|
0
|
36
|
my ($builder) = @_; |
77
|
|
|
|
|
|
|
|
78
|
15
|
50
|
|
|
|
55
|
if ( my $dir = shift @$builder ) { |
79
|
15
|
|
|
|
|
116
|
my $stream = Directory::Scanner::Stream->new( origin => $dir ); |
80
|
|
|
|
|
|
|
|
81
|
15
|
|
|
|
|
103
|
foreach my $layer ( @$builder ) { |
82
|
25
|
|
|
|
|
119
|
my ($class, %args) = @$layer; |
83
|
25
|
|
|
|
|
293
|
$stream = $class->new( stream => $stream, %args ); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
15
|
|
|
|
|
95
|
return $stream; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
else { |
89
|
0
|
|
|
|
|
|
Carp::confess 'Nothing to construct a stream on'; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
__END__ |