| 1 | package System::Introspector::Probe::LibDirs::Perl; | ||||||||||||||||||||
| 2 | 1 | ▶ | use Moo; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 1 | ▶ | use Module::Metadata; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 1 | ▶ | use Digest::SHA; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 1 | ▶ | use System::Introspector::Util qw( | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | handle_from_command | ||||||||||||||||||||
| 8 | transform_exceptions | ||||||||||||||||||||
| 9 | 1 | ); | |||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | has root => ( | ||||||||||||||||||||
| 12 | is => 'ro', | ||||||||||||||||||||
| 13 | 0 | ▶ | default => sub { '/' }, | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 14 | 1 | ); | |||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 1 | ▶ | sub gather { | ||||||||||||||||||
|
Subroutine
gather: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 17 | 1 | my ($self) = @_; | |||||||||||||||||||
| 18 | 1 | ▶ | return transform_exceptions { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||
| 19 | 1 | my $pipe = $self->_open_locate_libdirs_pipe; | |||||||||||||||||||
| 20 | 1 | my %libdir; | |||||||||||||||||||
| 21 | 1 | ▶ | while (defined( my $line = <$pipe> )) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 22 | 1 | chomp $line; | |||||||||||||||||||
| 23 | 1 | ▶ | $libdir{ $line } = transform_exceptions { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 24 | 1 | return { modules => $self->_gather_libdir_info($line) }; | |||||||||||||||||||
| 25 | 1 | }; | |||||||||||||||||||
| 26 | } | ||||||||||||||||||||
| 27 | 1 | return { libdirs_perl => \%libdir }; | |||||||||||||||||||
| 28 | 1 | }; | |||||||||||||||||||
| 29 | } | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 1 | ▶ | sub _gather_libdir_info { | ||||||||||||||||||
|
Subroutine
_gather_libdir_info: called CC=5 SCAR=16.2
| |||||||||||||||||||||
| 32 | 1 | my ($self, $libdir) = @_; | |||||||||||||||||||
| 33 | 1 | my %module; | |||||||||||||||||||
| 34 | 1 | my $pipe = $self->_open_locate_pm_pipe($libdir); | |||||||||||||||||||
| 35 | 1 | ▶ | while (defined( my $line = <$pipe> )) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 36 | 1 | chomp $line; | |||||||||||||||||||
| 37 | 1 | my $metadata = Module::Metadata->new_from_file($line); | |||||||||||||||||||
| 38 | 1 | ▶ | next unless $metadata->name; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 39 | 1 | my $sha = Digest::SHA->new(256); | |||||||||||||||||||
| 40 | 1 | $sha->addfile($line); | |||||||||||||||||||
| 41 | 1 | my $version = $metadata->version; | |||||||||||||||||||
| 42 | 1 | ▶ | push @{ $module{ $metadata->name } //= [] }, { | ||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$module{$metadata->name} //= []
MC/DC0%0/1
$module{$metadata->name} //= []
$module{$metadata->name}
Truth table50%1/2
A
A= $module{$metadata->name}
| |||||||||||||||||||||
| 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 | return \%module; | |||||||||||||||||||
| 54 | } | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | 1 | ▶ | sub _open_locate_pm_pipe { | ||||||||||||||||||
|
Subroutine
_open_locate_pm_pipe: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 57 | 1 | my ($self, $libdir) = @_; | |||||||||||||||||||
| 58 | 1 | return handle_from_command | |||||||||||||||||||
| 59 | sprintf q{find %s -name '*.pm'}, $libdir; | ||||||||||||||||||||
| 60 | } | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 0 | ▶ | sub _open_locate_libdirs_pipe { | ||||||||||||||||||
|
Subroutine
_open_locate_libdirs_pipe: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 63 | 0 | my ($self) = @_; | |||||||||||||||||||
| 64 | 0 | my $root = $self->root; | |||||||||||||||||||
| 65 | 0 | ▶ | $root .= '/' | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 66 | unless $root =~ m{/$}; | ||||||||||||||||||||
| 67 | 0 | return handle_from_command sprintf | |||||||||||||||||||
| 68 | q{locate --regex '^%s.*lib/perl5$'}, $root; | ||||||||||||||||||||
| 69 | } | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | 1 | 1; | |||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | __END__ | ||||||||||||||||||||