Install/Payload.pm

filter: Statementstmt 74.5% 41 / 55 Branchbran 53.1% 17 / 32 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 81.8% 9 / 11 Podpod 14.2% 1 / 7 totaltotal 60.1% 68 / 113 CC 20 SCAR 17.9
CC
20
Cov
63%
loaded_module_version
12.6
payload_dir
12.0
binary_module_info
6.5
CRAP 6.0
« Install/CMake.pm ↑ Summary Install/FrozenShit/Typemaps/Type.pm »
1 package XS::Install::Payload;
2 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use Cwd();
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 11 my (%module_info, %vcache);
7  
8 133 ▶sub data_dir {
Subroutine data_dir: called CC=5 SCAR=16.2
Pod undocumented
9 133 my $module = pop;
10 133 $module =~ s/::/\//g;
11
12 # first try search in loaded module's dir
13 133 ▶ if (my $path = $INC{"$module.pm"}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $path = $INC{"$module.pm"}) 102 31 133
14 102 $path =~ s/\.pm$//;
15 102 my $pldir = "$path.x";
16 102 ▶ return Cwd::realpath($pldir) if -d $pldir;
Branch: 1 branch
BranchTrueFalseTotal
if -d $pldir 102 0 102
17 }
18
19 31 foreach my $inc (@INC) {
20 248 my $pldir = "$inc/$module.x";
21 248 ▶ return Cwd::realpath($pldir) if -d $pldir;
Branch: 1 branch
BranchTrueFalseTotal
if -d $pldir 0 248 248
22 }
23
24 31 return undef;
25 }
26  
27 0 ▶sub payload_dir {
Subroutine payload_dir: not called CC=3 SCAR=24.8
Pod documented
28 0 ▶ my $data_dir = data_dir(@_) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $data_dir = data_dir(@_) or return undef 0 0 0
29 0 my $dir = "$data_dir/payload";
30 0 ▶ return $dir if -d $dir;
Branch: 1 branch
BranchTrueFalseTotal
if -d $dir 0 0 0
31 0 return undef;
32 }
33  
34 31 ▶sub include_dir {
Subroutine include_dir: called CC=3 SCAR=12.5
Pod undocumented
35 31 ▶ my $data_dir = data_dir(@_) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $data_dir = data_dir(@_) or return undef 31 0 31
36 31 my $dir = "$data_dir/i";
37 31 ▶ return $dir if -d $dir;
Branch: 1 branch
BranchTrueFalseTotal
if -d $dir 31 0 31
38 0 return undef;
39 }
40  
41 31 ▶sub typemap_dir {
Subroutine typemap_dir: called CC=3 SCAR=12.5
Pod undocumented
42 31 ▶ my $data_dir = data_dir(@_) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $data_dir = data_dir(@_) or return undef 31 0 31
43 31 my $dir = "$data_dir/tm";
44 31 ▶ return $dir if -d $dir;
Branch: 1 branch
BranchTrueFalseTotal
if -d $dir 31 0 31
45 0 return undef;
46 }
47  
48 40 ▶sub binary_module_info_file {
Subroutine binary_module_info_file: called CC=2 SCAR=6.9
Pod undocumented
49 40 ▶ my $data_dir = data_dir(@_) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $data_dir = data_dir(@_) or return undef 9 31 40
50 9 return "$data_dir/info";
51 }
52  
53 62 ▶sub binary_module_info {
Subroutine binary_module_info: called CC=6 SCAR=18.7
Pod undocumented
54 62 my $module = shift;
55 62 my $info = $module_info{$module};
56 62 ▶ unless ($info) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($info) 40 22 62
57 40 ▶ my $file = binary_module_info_file($module) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $file = binary_module_info_file($module) or return undef 9 31 40
58 9 ▶ return undef unless -f $file;
Branch: 1 branch
BranchTrueFalseTotal
unless -f $file 0 9 9
59 9 ▶ $info = do($file) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
$info = do $file or return undef 9 0 9
60 9 ▶ unless (ref($info) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $info eq "HASH") 0 9 9
61 0 warn "bad module info file: $file";
62 0 return undef;
63 }
64 9 $module_info{$module} = $info;
65 }
66 31 return $info;
67 }
68  
69 0 ▶sub loaded_module_version {
Subroutine loaded_module_version: not called CC=4 SCAR=25.3
Pod undocumented
70 0 my $module = shift;
71 11 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
72 0 my $version = ${"${module}::VERSION"};
73 0 ▶ if (!$version and my $vsub = $module->can('VERSION')) { $version = $module->VERSION }
Branch: 1 branch
BranchTrueFalseTotal
if (not $version and my $vsub = $module->can("VERSION")) 0 0 0
Condition0%0/3
not $version and my $vsub = $module->can("VERSION")
!ll&&!rl&&r
000
MC/DC0%0/2
not $version and my $vsub = $module->can("VERSION")
not $version my $vsub = $module->can("VERSION")
Truth table0%0/3
not(A) and B
A= not $versionB= my $vsub = $module->can("VERSION")
ABresult
0X0
100
111
74 0 ▶ return $version || 0;
Condition0%0/2
$version || 0
l!l
00
MC/DC0%0/1
$version || 0
$version
Truth table0%0/2
A
A= $version
Aresult
11
00
75 }
76  
77 11 1;
« Install/CMake.pm ↑ Summary Install/FrozenShit/Typemaps/Type.pm »