line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
4
|
|
|
4
|
|
3206019
|
use strict; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
173
|
|
2
|
4
|
|
|
4
|
|
21
|
use warnings; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
281
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package App::Embra::Plugin::GatherDir; |
5
|
|
|
|
|
|
|
$App::Embra::Plugin::GatherDir::VERSION = '0.001'; # TRIAL |
6
|
|
|
|
|
|
|
# ABSTRACT: gather all the files in a directory |
7
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
2253
|
use Path::Class::Dir; |
|
4
|
|
|
|
|
711180
|
|
|
4
|
|
|
|
|
165
|
|
9
|
4
|
|
|
4
|
|
38
|
use List::MoreUtils qw< any >; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
43
|
|
10
|
4
|
|
|
4
|
|
1292
|
use Method::Signatures; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
46
|
|
11
|
|
|
|
|
|
|
|
12
|
4
|
|
|
4
|
|
3477
|
use App::Embra::File; |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
155
|
|
13
|
4
|
|
|
4
|
|
33
|
use Moo; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
25
|
|
14
|
|
|
|
|
|
|
|
15
|
4
|
50
|
|
4
|
|
12096
|
method mvp_multivalue_args() { qw< exclude_match >; } |
|
4
|
|
|
4
|
|
686
|
|
|
4
|
|
|
|
|
21
|
|
|
4
|
|
|
|
|
117
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has 'from' => ( |
20
|
|
|
|
|
|
|
is => 'ro', |
21
|
|
|
|
|
|
|
required => 1, |
22
|
|
|
|
|
|
|
default => sub { '.' }, |
23
|
|
|
|
|
|
|
coerce => sub { Path::Class::Dir->new( $_[0] )->absolute }, |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has 'include_dotfiles' => ( |
28
|
|
|
|
|
|
|
is => 'ro', |
29
|
|
|
|
|
|
|
default => sub { !1 }, |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
has 'exclude_match' => ( |
34
|
|
|
|
|
|
|
is => 'ro', |
35
|
|
|
|
|
|
|
coerce => sub { [ map { qr{$_} } @{ $_[0] } ] }, |
36
|
|
|
|
|
|
|
default => sub { [] }, |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
4
|
50
|
|
4
|
|
2908
|
method gather_files { |
|
4
|
|
|
4
|
|
192
|
|
|
4
|
|
|
|
|
17
|
|
40
|
4
|
|
|
|
|
36
|
$self->debug( 'looking in '.$self->from ); |
41
|
35
|
50
|
|
35
|
|
7955
|
$self->from->recurse( callback => func( $file ) { |
|
35
|
50
|
|
|
|
38
|
|
|
35
|
|
|
|
|
72
|
|
42
|
35
|
100
|
|
|
|
119
|
return if $file eq $self->from; |
43
|
31
|
|
100
|
|
|
957
|
my $skip = $file->basename =~ m/ \A [.] /xms && not $self->include_dotfiles; |
44
|
31
|
|
|
|
|
266
|
my $exclude = any { $file =~ $_ } @{ $self->exclude_match }; |
|
11
|
|
|
|
|
105
|
|
|
31
|
|
|
|
|
101
|
|
45
|
31
|
100
|
100
|
|
|
195
|
return $file->PRUNE if $file->is_dir and $skip || $exclude; |
|
|
|
66
|
|
|
|
|
46
|
26
|
100
|
|
|
|
152
|
return if $file->is_dir; |
47
|
15
|
|
|
|
|
62
|
$self->debug( "considering $file" ); |
48
|
15
|
100
|
66
|
|
|
816
|
return if $skip or $exclude; |
49
|
12
|
|
|
|
|
37
|
my $embra_file = App::Embra::File->new( name => $file->stringify ); |
50
|
12
|
|
|
|
|
106
|
$embra_file->name( $file->relative( $self->from )->stringify ); |
51
|
12
|
|
|
|
|
2137
|
$self->add_file( $embra_file ); |
52
|
4
|
|
|
|
|
215
|
} ); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
with 'App::Embra::Role::FileGatherer'; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__END__ |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=pod |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=encoding UTF-8 |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 NAME |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
App::Embra::Plugin::GatherDir - gather all the files in a directory |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 VERSION |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
version 0.001 |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 DESCRIPTION |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
This plugin recursively add all files in a directory to the site. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 from |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
The directory to gather files from. Defaults to F<.> (the current directory). |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 include_dotfiles |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Whether to consider files and directories beginning with C<.> (dot) when gathering files. Defaults to false. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 exclude_match |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
A regular expression to match files which should not be gathered. May be used multiple times to specify multiple patterns to exclude. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 AUTHOR |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Daniel Holz <dgholz@gmail.com> |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Daniel Holz. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
100
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |