lib/Module/Install/Share.pm

filter: Statementstmt 84.6% 44 / 52 Branchbran 60.0% 18 / 30 Conditioncond 41.6% 5 / 12 MC/DCmcdc 14.2% 1 / 7 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 1 totaltotal 69.0% 76 / 110 CC 20 SCAR 27.6
CC
20
Cov
71%
install_share
25.5
__ANON__
6.0
BEGIN
1.0
CRAP 15.7
« lib/Module/Install/Admin/Include.pm ↑ Summary lib/Module/Install/WriteAll.pm »
1 package Module::Install::Share;
2  
3 46 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 46 ▶use Module::Install::Base ();
Subroutine BEGIN: called CC=1 SCAR=0.0
5 46 ▶use File::Find ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6 46 ▶use ExtUtils::Manifest ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 46 ▶use vars qw{$VERSION @ISA $ISCORE};
Subroutine BEGIN: called CC=1 SCAR=0.0
9 46 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
10 46 $VERSION = '1.21';
11 46 @ISA = 'Module::Install::Base';
12 46 $ISCORE = 1;
13 }
14  
15 4 ▶sub install_share {
Subroutine install_share: called CC=15 SCAR=32.4
Pod undocumented
16 4 my $self = shift;
17 4 ▶ my $dir = @_ ? pop : 'share';
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 1 3 4
18 4 ▶ my $type = @_ ? shift : 'dist';
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 4 4
19 4 ▶ unless ( defined $type and $type eq 'module' or $type eq 'dist' ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $type and $type eq "module" or $type eq "dist") 0 4 4
Condition33%2/6
defined $type and $type eq "module" or $type eq "dist"
l!l&&r!l&&!r
040
defined $type and $type eq "module"
!ll&&!rl&&r
040
MC/DC0%0/3
defined $type and $type eq "module" or $type eq "dist"
defined $type $type eq "module" $type eq "dist"
Truth table20%1/5
A and B or C
A= defined $typeB= $type eq "module"C= $type eq "dist"
ABCresult
11X1
0X11
1011
0X00
1000
20 0 die "Illegal or invalid share dir type '$type'";
21 }
22 4 ▶ unless ( defined $dir and -d $dir ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $dir and -d $dir) 0 4 4
Condition33%1/3
defined $dir and -d $dir
!ll&&!rl&&r
004
MC/DC0%0/2
defined $dir and -d $dir
defined $dir -d $dir
Truth table33%1/3
A and B
A= defined $dirB= -d $dir
ABresult
0X0
100
111
23 0 require Carp;
24 0 Carp::croak("Illegal or missing directory install_share param: '$dir'");
25 }
26  
27 # Split by type
28 4 ▶ my $S = ($^O eq 'MSWin32') ? "\\" : "\/";
Branch: 1 branch
BranchTrueFalseTotal
$^O eq 'MSWin32' ? : 0 4 4
29  
30 4 my $root;
31 4 ▶ if ( $type eq 'dist' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq 'dist') { } 4 0 4
32 4 ▶ die "Too many parameters to install_share" if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 4 4
33  
34 # Set up the install
35 4 $root = "\$(INST_LIB)${S}auto${S}share${S}dist${S}\$(DISTNAME)";
36 } else {
37 0 my $module = Module::Install::_CLASS($_[0]);
38 0 ▶ unless ( defined $module ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $module) 0 0 0
39 0 die "Missing or invalid module name '$_[0]'";
40 }
41 0 $module =~ s/::/-/g;
42  
43 0 $root = "\$(INST_LIB)${S}auto${S}share${S}module${S}$module";
44 }
45  
46 4 ▶ my $manifest = -r 'MANIFEST' ? ExtUtils::Manifest::maniread() : undef;
Branch: 1 branch
BranchTrueFalseTotal
-r 'MANIFEST' ? : 4 0 4
47 4 ▶ my $skip_checker = $ExtUtils::Manifest::VERSION >= 1.54
Branch: 1 branch
BranchTrueFalseTotal
$ExtUtils::Manifest::VERSION >= 1.54 ? : 4 0 4
48 ? ExtUtils::Manifest::maniskip()
49 : ExtUtils::Manifest::_maniskip();
50 4 my $postamble = '';
51 4 ▶ my $perm_dir = eval($ExtUtils::MakeMaker::VERSION) >= 6.52 ? '$(PERM_DIR)' : 755;
Branch: 1 branch
BranchTrueFalseTotal
eval $ExtUtils::MakeMaker::VERSION >= 6.52 ? : 4 0 4
52 File::Find::find({
53 no_chdir => 1,
54 8 ▶ wanted => sub {
Subroutine __ANON__: called CC=6 SCAR=18.0
55 8 my $path = File::Spec->abs2rel($_, $dir);
56 8 ▶ if (-d $_) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $_) { } 4 4 8
57 4 ▶ return if $skip_checker->($File::Find::name);
Branch: 1 branch
BranchTrueFalseTotal
if &$skip_checker($File::Find::name) 0 4 4
58 4 $postamble .=<<"END";
59 \t\$(NOECHO) \$(MKPATH) "$root${S}$path"
60 \t\$(NOECHO) \$(CHMOD) $perm_dir "$root${S}$path"
61 END
62 }
63 else {
64 return if ref $manifest
65 4 ▶ && !exists $manifest->{$File::Find::name};
Branch: 1 branch
BranchTrueFalseTotal
if ref $manifest and not exists $manifest->{$File::Find::name} 2 2 4
Condition66%2/3
ref $manifest and not exists $manifest->{$File::Find::name}
!ll&&!rl&&r
022
MC/DC50%1/2
ref $manifest and not exists $manifest->{$File::Find::name}
ref $manifest not exists $manifest->{$File::Find::name}
Truth table66%2/3
A and not(B)
A= ref $manifestB= not exists $manifest->{$File::Find::name}
ABresult
0X0
100
111
66 2 ▶ return if $skip_checker->($File::Find::name);
Branch: 1 branch
BranchTrueFalseTotal
if &$skip_checker($File::Find::name) 1 1 2
67 1 $postamble .=<<"END";
68 \t\$(NOECHO) \$(CP) "$dir${S}$path" "$root${S}$path"
69 END
70 }
71 },
72 4 }, $dir);
73  
74 # Set up the install
75 4 $self->postamble(<<"END_MAKEFILE");
76 config ::
77 $postamble
78  
79 END_MAKEFILE
80  
81 # The above appears to behave incorrectly when used with old versions
82 # of ExtUtils::Install (known-bad on RHEL 3, with 5.8.0)
83 # So when we need to install a share directory, make sure we add a
84 # dependency on a moderately new version of ExtUtils::MakeMaker.
85 4 $self->build_requires( 'ExtUtils::MakeMaker' => '6.11' );
86  
87 # 99% of the time we don't want to index a shared dir
88 4 $self->no_index( directory => $dir );
89 }
90  
91 46 1;
92  
93 __END__
« lib/Module/Install/Admin/Include.pm ↑ Summary lib/Module/Install/WriteAll.pm »