line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::Collect; |
2
|
7
|
|
|
7
|
|
183403
|
use 5.006_002; |
|
7
|
|
|
|
|
29
|
|
|
7
|
|
|
|
|
362
|
|
3
|
7
|
|
|
7
|
|
54
|
use strict; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
218
|
|
4
|
7
|
|
|
7
|
|
33
|
use warnings; |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
391
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
6
|
|
|
|
|
|
|
|
7
|
7
|
|
|
7
|
|
8523
|
use Text::Glob qw(glob_to_regex); |
|
7
|
|
|
|
|
6304
|
|
|
7
|
|
|
|
|
450
|
|
8
|
|
|
|
|
|
|
|
9
|
7
|
|
|
7
|
|
46
|
use Carp; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
503
|
|
10
|
7
|
|
|
7
|
|
36
|
use File::Find; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
429
|
|
11
|
7
|
|
|
7
|
|
37
|
use File::Spec; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
140
|
|
12
|
7
|
|
|
7
|
|
5064
|
use Module::Collect::Package; |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
4771
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
7
|
|
|
7
|
0
|
585
|
my($class, %args) = @_; |
16
|
|
|
|
|
|
|
|
17
|
7
|
|
|
|
|
22
|
$args{modules} = []; |
18
|
7
|
|
100
|
|
|
55
|
$args{pattern} ||= '*.pm'; |
19
|
|
|
|
|
|
|
|
20
|
7
|
100
|
|
|
|
21
|
if($args{prefix}){ |
21
|
1
|
|
|
|
|
4
|
$args{prefix} .= '::'; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
else{ |
24
|
6
|
|
|
|
|
21
|
$args{prefix} = ''; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
7
|
|
|
|
|
37
|
my $self = bless { %args }, $class; |
28
|
7
|
|
|
|
|
34
|
$self->_find_modules; |
29
|
|
|
|
|
|
|
|
30
|
7
|
|
|
|
|
48
|
$self; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _find_modules { |
34
|
7
|
|
|
7
|
|
12
|
my $self = shift; |
35
|
|
|
|
|
|
|
|
36
|
7
|
|
50
|
|
|
51
|
my $path = $self->{path} || return; |
37
|
|
|
|
|
|
|
|
38
|
7
|
|
|
|
|
43
|
my $pattern = glob_to_regex($self->{pattern}); |
39
|
|
|
|
|
|
|
|
40
|
7
|
|
|
|
|
763
|
my @modules; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $wanted = sub{ |
43
|
41
|
100
|
|
41
|
|
1450
|
return unless -f; |
44
|
29
|
100
|
|
|
|
287
|
return unless /$pattern/; |
45
|
21
|
|
|
|
|
508
|
push @modules, File::Spec->canonpath($File::Find::name); |
46
|
7
|
|
|
|
|
37
|
}; |
47
|
|
|
|
|
|
|
|
48
|
7
|
100
|
|
|
|
30
|
for my $dir(ref($path) eq 'ARRAY' ? @{$path} : $path){ |
|
4
|
|
|
|
|
10
|
|
49
|
9
|
50
|
|
|
|
184
|
next unless -d $dir; |
50
|
9
|
|
|
|
|
772
|
find($wanted, $dir); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
7
|
|
|
|
|
19
|
for my $modulefile(@modules){ |
54
|
21
|
|
|
|
|
80
|
$self->_add_module($modulefile); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub _add_module { |
59
|
21
|
|
|
21
|
|
42
|
my($self, $modulefile) = @_; |
60
|
21
|
|
|
|
|
65
|
my @packages = $self->_extract_package($modulefile); |
61
|
21
|
100
|
|
|
|
89
|
return unless @packages; |
62
|
15
|
|
|
|
|
41
|
for (@packages) { |
63
|
17
|
|
|
|
|
27
|
push @{ $self->{modules} }, Module::Collect::Package->new( |
|
17
|
|
|
|
|
203
|
|
64
|
|
|
|
|
|
|
package => $_, |
65
|
|
|
|
|
|
|
path => $modulefile, |
66
|
|
|
|
|
|
|
); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub _extract_package { |
71
|
21
|
|
|
21
|
|
82
|
my($self, $modulefile) = @_; |
72
|
|
|
|
|
|
|
|
73
|
21
|
50
|
|
|
|
1253
|
open my $fh, '<', $modulefile or croak "$modulefile: $!"; |
74
|
21
|
|
|
|
|
54
|
my $prefix = $self->{prefix}; |
75
|
|
|
|
|
|
|
|
76
|
21
|
|
|
|
|
36
|
my $multiple = $self->{multiple}; |
77
|
21
|
|
|
|
|
27
|
my @packages; |
78
|
|
|
|
|
|
|
|
79
|
21
|
|
|
|
|
7691
|
while (<$fh>) { |
80
|
60
|
100
|
|
|
|
461
|
next if /\A =\w/xms .. /\A =cut \b/xms; # skip pod sections |
81
|
|
|
|
|
|
|
|
82
|
40
|
100
|
|
|
|
836
|
if(/\A \s* package \s+ ($prefix \S*) \s* ;/xms){ |
83
|
17
|
|
|
|
|
74
|
push @packages, $1; |
84
|
|
|
|
|
|
|
|
85
|
17
|
100
|
|
|
|
70
|
last unless $multiple; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
} |
88
|
21
|
|
|
|
|
561
|
return @packages; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub modules { |
93
|
22
|
|
|
22
|
0
|
6327
|
my $self = shift; |
94
|
22
|
|
|
|
|
139
|
$self->{modules}; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |
98
|
|
|
|
|
|
|
__END__ |