line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package System::Introspector::Probe::LibDirs::Perl; |
2
|
1
|
|
|
1
|
|
52340
|
use Moo; |
|
1
|
|
|
|
|
17292
|
|
|
1
|
|
|
|
|
7
|
|
3
|
1
|
|
|
1
|
|
2942
|
use Module::Metadata; |
|
1
|
|
|
|
|
22390
|
|
|
1
|
|
|
|
|
44
|
|
4
|
1
|
|
|
1
|
|
1041
|
use Digest::SHA; |
|
1
|
|
|
|
|
5907
|
|
|
1
|
|
|
|
|
115
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
|
|
630
|
use System::Introspector::Util qw( |
7
|
|
|
|
|
|
|
handle_from_command |
8
|
|
|
|
|
|
|
transform_exceptions |
9
|
1
|
|
|
1
|
|
957
|
); |
|
1
|
|
|
|
|
5
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has root => ( |
12
|
|
|
|
|
|
|
is => 'ro', |
13
|
|
|
|
|
|
|
default => sub { '/' }, |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub gather { |
17
|
1
|
|
|
1
|
0
|
1171
|
my ($self) = @_; |
18
|
|
|
|
|
|
|
return transform_exceptions { |
19
|
1
|
|
|
1
|
|
4
|
my $pipe = $self->_open_locate_libdirs_pipe; |
20
|
1
|
|
|
|
|
1295
|
my %libdir; |
21
|
1
|
|
|
|
|
24
|
while (defined( my $line = <$pipe> )) { |
22
|
1
|
|
|
|
|
3
|
chomp $line; |
23
|
|
|
|
|
|
|
$libdir{ $line } = transform_exceptions { |
24
|
1
|
|
|
|
|
5
|
return { modules => $self->_gather_libdir_info($line) }; |
25
|
1
|
|
|
|
|
10
|
}; |
26
|
|
|
|
|
|
|
} |
27
|
1
|
|
|
|
|
16
|
return { libdirs_perl => \%libdir }; |
28
|
1
|
|
|
|
|
13
|
}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _gather_libdir_info { |
32
|
1
|
|
|
1
|
|
4
|
my ($self, $libdir) = @_; |
33
|
1
|
|
|
|
|
2
|
my %module; |
34
|
1
|
|
|
|
|
23
|
my $pipe = $self->_open_locate_pm_pipe($libdir); |
35
|
1
|
|
|
|
|
20
|
while (defined( my $line = <$pipe> )) { |
36
|
1
|
|
|
|
|
4
|
chomp $line; |
37
|
1
|
|
|
|
|
31
|
my $metadata = Module::Metadata->new_from_file($line); |
38
|
1
|
50
|
|
|
|
1704
|
next unless $metadata->name; |
39
|
1
|
|
|
|
|
26
|
my $sha = Digest::SHA->new(256); |
40
|
1
|
|
|
|
|
53
|
$sha->addfile($line); |
41
|
1
|
|
|
|
|
306
|
my $version = $metadata->version; |
42
|
1
|
50
|
50
|
|
|
14
|
push @{ $module{ $metadata->name } //= [] }, { |
|
1
|
|
|
|
|
7
|
|
43
|
|
|
|
|
|
|
file => $line, |
44
|
|
|
|
|
|
|
version => ( |
45
|
|
|
|
|
|
|
defined($version) |
46
|
|
|
|
|
|
|
? sprintf('%s', $version) |
47
|
|
|
|
|
|
|
: undef |
48
|
|
|
|
|
|
|
), |
49
|
|
|
|
|
|
|
size => scalar(-s $line), |
50
|
|
|
|
|
|
|
sha256_hex => $sha->hexdigest, |
51
|
|
|
|
|
|
|
}; |
52
|
|
|
|
|
|
|
} |
53
|
1
|
|
|
|
|
153
|
return \%module; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _open_locate_pm_pipe { |
57
|
1
|
|
|
1
|
|
3
|
my ($self, $libdir) = @_; |
58
|
1
|
|
|
|
|
7
|
return handle_from_command |
59
|
|
|
|
|
|
|
sprintf q{find %s -name '*.pm'}, $libdir; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub _open_locate_libdirs_pipe { |
63
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
64
|
0
|
|
|
|
|
|
my $root = $self->root; |
65
|
0
|
0
|
|
|
|
|
$root .= '/' |
66
|
|
|
|
|
|
|
unless $root =~ m{/$}; |
67
|
0
|
|
|
|
|
|
return handle_from_command sprintf |
68
|
|
|
|
|
|
|
q{locate --regex '^%s.*lib/perl5$'}, $root; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
__END__ |