| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test2::Util::DistFiles; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Gather a list of files in a distribution |
|
4
|
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
236354
|
use v5.14; |
|
|
1
|
|
|
|
|
3
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
63
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use Carp qw( croak ); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
50
|
|
|
9
|
1
|
|
|
1
|
|
442
|
use Cwd::Guard qw( cwd_guard ); |
|
|
1
|
|
|
|
|
1428
|
|
|
|
1
|
|
|
|
|
102
|
|
|
10
|
1
|
|
|
1
|
|
9
|
use Exporter 5.57 qw( import ); |
|
|
1
|
|
|
|
|
86
|
|
|
|
1
|
|
|
|
|
58
|
|
|
11
|
1
|
|
|
1
|
|
557
|
use ExtUtils::Manifest 1.68 qw( manifind maniread maniskip ); |
|
|
1
|
|
|
|
|
9331
|
|
|
|
1
|
|
|
|
|
90
|
|
|
12
|
1
|
|
|
1
|
|
10
|
use File::Basename qw( basename ); |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
39
|
|
|
13
|
1
|
|
|
1
|
|
4
|
use File::Spec; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
12
|
|
|
14
|
1
|
|
|
1
|
|
483
|
use IO::File; |
|
|
1
|
|
|
|
|
8376
|
|
|
|
1
|
|
|
|
|
103
|
|
|
15
|
1
|
|
|
1
|
|
484
|
use Ref::Util qw( is_plain_hashref ); |
|
|
1
|
|
|
|
|
2262
|
|
|
|
1
|
|
|
|
|
729
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# RECOMMEND PREREQ: Ref::Util::XS |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our @EXPORT_OK = qw( manifest_files is_perl_file ); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $VERSION = 'v0.2.1'; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub manifest_files { |
|
25
|
|
|
|
|
|
|
|
|
26
|
2
|
|
|
2
|
1
|
200638
|
my $options = {}; |
|
27
|
2
|
50
|
|
|
|
12
|
$options = shift if is_plain_hashref( $_[0] ); |
|
28
|
|
|
|
|
|
|
|
|
29
|
2
|
|
|
36
|
|
8
|
state $nop = sub { 1 }; |
|
|
36
|
|
|
|
|
90
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
2
|
|
66
|
|
|
9
|
my $filter = shift || $nop; |
|
32
|
|
|
|
|
|
|
|
|
33
|
2
|
|
|
|
|
7
|
my $guard; |
|
34
|
2
|
50
|
|
|
|
7
|
if ( my $dir = $options->{dir} ) { |
|
35
|
0
|
0
|
|
|
|
0
|
$guard = cwd_guard($dir) or croak "Cannot chdir to ${dir}: $Cwd::Guard::Error"; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
2
|
|
50
|
|
|
13
|
$options->{use_default} //= 1; |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $default = $options->{use_default} |
|
41
|
|
|
|
|
|
|
? sub { |
|
42
|
72
|
|
|
72
|
|
3549
|
my ($file) = @_; |
|
43
|
72
|
|
|
|
|
1220
|
my $name = basename($file); |
|
44
|
|
|
|
|
|
|
return |
|
45
|
72
|
50
|
33
|
|
|
814
|
if $file =~ m{^\.\w+/} # .git, .svn, .build, .mite ... |
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|| $file =~ m{^blib/} # |
|
47
|
|
|
|
|
|
|
|| $file =~ m{^local/} # Carton |
|
48
|
|
|
|
|
|
|
|| $name =~ m{^\.} # |
|
49
|
|
|
|
|
|
|
|| $name =~ m{~$} |
|
50
|
|
|
|
|
|
|
|| $name =~ m{^#.*#$} # |
|
51
|
|
|
|
|
|
|
|| $name =~ m{\.(?:old|bak|backup)$}i |
|
52
|
|
|
|
|
|
|
|| $file eq "Build"; |
|
53
|
72
|
|
|
|
|
240
|
return 1; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
2
|
50
|
|
|
|
13
|
: $nop; |
|
56
|
|
|
|
|
|
|
|
|
57
|
2
|
|
|
|
|
4
|
my $found; |
|
58
|
|
|
|
|
|
|
|
|
59
|
2
|
|
|
|
|
11
|
my $mfile = $ExtUtils::Manifest::MANIFEST; |
|
60
|
2
|
50
|
|
|
|
48
|
if ( -e $mfile ) { |
|
61
|
2
|
|
|
|
|
12
|
$found = maniread($mfile); |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
else { |
|
64
|
0
|
|
|
|
|
0
|
$found = manifind; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
2
|
|
|
|
|
1079
|
my $skip = maniskip; |
|
68
|
|
|
|
|
|
|
|
|
69
|
2
|
|
|
|
|
2666
|
$guard = undef; |
|
70
|
|
|
|
|
|
|
|
|
71
|
2
|
50
|
33
|
|
|
15
|
my @files = grep { !$skip->($_) && $default->($_) && $filter->($_) } sort keys %{$found}; |
|
|
72
|
|
|
|
|
137
|
|
|
|
2
|
|
|
|
|
37
|
|
|
72
|
2
|
|
|
|
|
86
|
return File::Spec->no_upwards(@files); |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub is_perl_file { |
|
77
|
36
|
|
|
36
|
1
|
53
|
my ($file) = @_; |
|
78
|
36
|
|
|
|
|
520
|
my $name = basename($file); |
|
79
|
36
|
50
|
|
|
|
79
|
return if $file =~ m{^(inc|local)/}; |
|
80
|
36
|
100
|
|
|
|
122
|
return 1 if $name =~ /\.(?:PL|p[lm]|psgi|t)$/; |
|
81
|
15
|
100
|
66
|
|
|
67
|
return if $name =~ /\.\w+$/ && $name !~ /\.bat$/; |
|
82
|
6
|
50
|
|
|
|
31
|
my $fh = IO::File->new( $file, "r" ) or return; |
|
83
|
6
|
|
|
|
|
717
|
my $first = $fh->getline; |
|
84
|
6
|
50
|
33
|
|
|
45
|
return 1 if $first && ( $first =~ /^#!.*perl\b/ || $first =~ /--[*]-Perl-[*]--/ ); |
|
|
|
|
33
|
|
|
|
|
|
85
|
6
|
|
|
|
|
82
|
return; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
__END__ |