Introspector/Probe/Perls.pm

filter: Statementstmt 82.0% 32 / 39 Branchbran 72.2% 13 / 18 Conditioncond 33.3% 4 / 12 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 75.0% 6 / 8 Podpod 0.0% 0 / 1 totaltotal 64.7% 55 / 85 CC 15 SCAR 19.9
CC
15
Cov
71%
_gather_info
10.9
__ANON__
7.3
__ANON__
2.0
CRAP 7.3
« Introspector/Gatherer.pm ↑ Summary Introspector/State.pm »
1 package System::Introspector::Probe::Perls;
2 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 1 ▶use System::Introspector::Util qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
5 transform_exceptions
6 handle_from_command
7 fail
8 1 );
9  
10 has root => (
11 is => 'ro',
12 0 ▶ default => sub { '/' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
13 1 );
14  
15 1 ▶sub gather {
Subroutine gather: called CC=1 SCAR=0.3
Pod undocumented
16 1 my ($self) = @_;
17 1 ▶ return transform_exceptions {
Subroutine __ANON__: called CC=6 SCAR=19.9
18 1 my @configs = $self->_find_possible_perl_configs;
19 1 my %found;
20 my %seen;
21 1 for my $config (@configs) {
22 2 ▶ my $info = transform_exceptions {
Subroutine __ANON__: called CC=1 SCAR=0.0
23 2 return $self->_gather_info($config);
24 2 };
25 next if $info
26 and $info->{config}{sitelibexp}
27 2 ▶ and $seen{$info->{config}{sitelibexp}}++;
Branch: 1 branch
BranchTrueFalseTotal
if $info and $info->{"config"}{"sitelibexp"} and $seen{$info->{"config"}{"sitelibexp"}}++ 0 2 2
Condition33%2/6
$info and $info->{"config"}{"sitelibexp"} and $seen{$info->{"config"}{"sitelibexp"}}++
!ll&&!rl&&r
020
$info and $info->{"config"}{"sitelibexp"}
!ll&&!rl&&r
002
MC/DC0%0/3
$info and $info->{"config"}{"sitelibexp"} and $seen{$info->{"config"}{"sitelibexp"}}++
$info $info->{"config"}{"sitelibexp"} $seen{$info->{"config"}{"sitelibexp"}}++
Truth table25%1/4
A and B and C
A= $infoB= $info->{"config"}{"sitelibexp"}C= $seen{$info->{"config"}{"sitelibexp"}}++
ABCresult
0XX0
10X0
1100
1111
28 2 ▶ $found{$config} = $info
Branch: 1 branch
BranchTrueFalseTotal
if defined $info 2 0 2
29 if defined $info;
30 }
31 1 return { perls => \%found };
32 1 };
33 }
34  
35 2 ▶sub _gather_info {
Subroutine _gather_info: called CC=10 SCAR=23.9
36 2 my ($self, $config) = @_;
37 2 ▶ open my $fh, '<', $config
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $config or fail("Unable to determine '${config}': $!") 2 0 2
38 or fail "Unable to determine '$config': $!";
39 2 my $first_line = <$fh>;
40 return undef
41 2 ▶ unless defined $first_line and $first_line =~ m{^#.+configpm};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $first_line and $first_line =~ /^#.+configpm/ 0 2 2
Condition33%1/3
defined $first_line and $first_line =~ /^#.+configpm/
!ll&&!rl&&r
002
MC/DC0%0/2
defined $first_line and $first_line =~ /^#.+configpm/
defined $first_line $first_line =~ /^#.+configpm/
Truth table33%1/3
A and B
A= defined $first_lineB= $first_line =~ /^#.+configpm/
ABresult
0X0
100
111
42 2 my %info;
43 my $is_info;
44 LINE:
45 2 ▶ while (defined( my $line = <$fh> )) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $fh)) 202 2 204
46 202 ▶ if ($line =~ m{tie\s+\%Config}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /tie\s+\%Config/) 2 200 202
47 2 $is_info++;
48 2 next LINE;
49 }
50 200 chomp $line;
51 200 ▶ if ($line =~ m{^\s*([a-z0-9_]+)\s*=>\s*'(.*)',\s*$}i) {
Branch: 2 branches
BranchTrueFalseTotal
if ($line =~ /^\s*([a-z0-9_]+)\s*=>\s*'(.*)',\s*$/i) { } 42 158 200
elsif ($line =~ /^\s*([a-z0-9_]+)\s*=>\s*undef,$/i) { } 4 154 158
52 42 $info{$1} = $2;
53 }
54 elsif ($line =~ m{^\s*([a-z0-9_]+)\s*=>\s*undef,$}i) {
55 4 $info{$1} = undef;
56 }
57 }
58 return {
59 (defined $info{scriptdir} and $info{version})
60 2 ▶ ? (executable => join('/', $info{scriptdir}, 'perl' . $info{version}))
Branch: 1 branch
BranchTrueFalseTotal
defined $info{'scriptdir'} && $info{'version'} ? : 2 0 2
Condition33%1/3
defined $info{"scriptdir"} and $info{"version"}
!ll&&!rl&&r
002
MC/DC0%0/2
defined $info{"scriptdir"} and $info{"version"}
defined $info{"scriptdir"} $info{"version"}
Truth table33%1/3
A and B
A= defined $info{"scriptdir"}B= $info{"version"}
ABresult
0X0
100
111
61 : (),
62 config => \%info,
63 };
64 }
65  
66 0 ▶sub _find_possible_perl_configs {
Subroutine _find_possible_perl_configs: not called CC=1 SCAR=6.9
67 0 my ($self) = @_;
68 0 (my $root = $self->root) =~ s{/$}{};
69 0 my $handle = handle_from_command sprintf
70 q{locate --regex '^%s/.*/Config.pm$'}, $root;
71 0 my @lines = <$handle>;
72 0 chomp @lines;
73 0 return @lines;
74 }
75  
76 1 1;
77  
78 __END__
« Introspector/Gatherer.pm ↑ Summary Introspector/State.pm »