Debora.pm

filter: Statementstmt 31.4% 38 / 121 Branchbran 0.0% 0 / 24 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 66.6% 10 / 15 Podpod 100% 5 / 5 totaltotal 30.4% 53 / 174 CC 16 SCAR 41.9
CC
16
Cov
25%
create
156.0
prepare
20.0
install
6.0
CRAP 65.9
↑ Summary Debora/Util.pm »
1 package CPANPLUS::Dist::Debora;
2  
3 # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later
4  
5 2 ▶use 5.016;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 our $VERSION = '0.019';
10  
11 2 ▶use parent qw(CPANPLUS::Dist::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 2 ▶use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶use English qw(-no_match_vars);
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 use Module::Pluggable
17 2 ▶ search_path => 'CPANPLUS::Dist::Debora::Package',
Subroutine BEGIN: called CC=1 SCAR=0.0
18 sub_name => '_formats',
19 2 require => 1;
20  
21 2 ▶use CPANPLUS::Dist::Debora::Util qw(run);
Subroutine BEGIN: called CC=1 SCAR=0.0
22 2 ▶use CPANPLUS::Error qw(error msg);
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 2 my @available_formats = do {
25 ##no critic (ClassHierarchies::ProhibitOneArgBless)
26 2 my @formats = bless({})->_formats;
27  
28 # Sort the formats by priority.
29 2 my %p = map { $_ => $_->format_priority } @formats;
30 2 grep { $p{$_} > 0 } reverse sort { $p{$a} <=> $p{$b} } @formats;
31 };
32  
33 0 ▶sub format_available {
Subroutine format_available: not called CC=1 SCAR=6.9
Pod documented
34 0 my $class = shift;
35  
36 0 return @available_formats > 0;
37 }
38  
39 0 ▶sub init {
Subroutine init: not called CC=1 SCAR=6.9
Pod documented
40 0 my $self = shift;
41  
42 0 my $status = $self->status;
43  
44 0 $status->mk_accessors(qw(_package));
45  
46 0 return 1;
47 }
48  
49 0 ▶sub prepare {
Subroutine prepare: not called CC=4 SCAR=30.0
Pod documented
50 0 my ($self, %params) = @_;
51  
52 0 my $status = $self->status;
53 0 my $module = $self->parent;
54 0 my $format = $available_formats[0];
55  
56 my $package = $format->new(
57 module => $module,
58 installdirs => $ENV{INSTALLDIRS} // 'vendor',
59 0 ▶ build_number => $ENV{BUILD} // 1,
Condition0%0/4
$ENV{"INSTALLDIRS"} // "vendor"
l!l
00
$ENV{"BUILD"} // 1
l!l
00
MC/DC0%0/1
$ENV{"INSTALLDIRS"} // "vendor"
$ENV{"INSTALLDIRS"}
MC/DC0%0/1
$ENV{"BUILD"} // 1
$ENV{"BUILD"}
Truth table0%0/2
A
A= $ENV{"INSTALLDIRS"}
Aresult
11
00
Truth table0%0/2
A
A= $ENV{"BUILD"}
Aresult
11
00
60 );
61  
62 0 $status->_package($package);
63  
64 0 umask oct '022';
65  
66 # Run Makefile.PL or Build.PL.
67 0 my $ok = do {
68 0 my $dist_name = $package->dist_name;
69  
70 # We use PERL_MM_OPT since CPANPLUS::Dist:MM does not accept multiple
71 # options in makemakerflags. PERL_MB_OPT requires Module::Build 0.36.
72 0 local $ENV{PERL_MM_OPT} = $package->mm_opt;
73 0 local $ENV{PERL_MB_OPT} = $package->mb_opt;
74 0 local $ENV{MODULEBUILDRC} = 'NONE';
75 0 $params{buildflags} = q{};
76 0 $params{makemakerflags} = q{};
77  
78 # There are old distributions that expect "." to be in @INC.
79 0 local $ENV{PERL_USE_UNSAFE_INC} = 1;
80  
81 # Avoid an interactive prompt.
82 0 ▶ if ($dist_name eq 'Data-Dump-Streamer') {
Branch: 1 branch
BranchTrueFalseTotal
if ($dist_name eq "Data-Dump-Streamer") 0 0 0
83 0 $params{buildflags} = 'DDS';
84 }
85  
86 # We are not allowed to write to XML/SAX/ParserDetails.ini.
87 0 local $ENV{SKIP_SAX_INSTALL} = 1;
88  
89 0 $self->SUPER::prepare(%params);
90 };
91  
92 0 return $status->prepared($ok);
93 }
94  
95 0 ▶sub create {
Subroutine create: not called CC=12 SCAR=50.5
Pod documented
96 0 my ($self, %params) = @_;
97  
98 0 my $module = $self->parent;
99 0 my $backend = $module->parent;
100 0 my $config = $backend->configure_object;
101 0 my $status = $self->status;
102 0 my $package = $status->_package;
103 0 my $verbose = $params{verbose};
104  
105 0 ▶ my $make = $config->get_program('make') // 'make';
Condition0%0/2
$config->get_program("make") // "make"
l!l
00
MC/DC0%0/1
$config->get_program("make") // "make"
$config->get_program("make")
Truth table0%0/2
A
A= $config->get_program("make")
Aresult
11
00
106 0 my $perl = $EXECUTABLE_NAME;
107  
108 # Build and test the Perl distribution.
109 0 my $ok = do {
110 0 my $dist_name = $package->dist_name;
111  
112 # Some tests fail if PERL_MM_OPT and PERL_MB_OPT are set.
113 0 delete local $ENV{PERL_MM_OPT};
114 0 delete local $ENV{PERL_MB_OPT};
115 0 local $ENV{MODULEBUILDRC} = 'NONE';
116 0 $params{buildflags} = q{};
117 0 $params{makemakerflags} = q{};
118  
119 # There are old distributions that expect "." to be in @INC.
120 0 local $ENV{PERL_USE_UNSAFE_INC} = 1;
121  
122 # Required by Term::ReadLine::Gnu if the history-size is set in
123 # ~/.inputrc.
124 0 local $ENV{INPUTRC} = File::Spec->devnull;
125  
126 # Dist::Zilla and Pinto require Perl 5.20.
127 0 ▶ if ($PERL_VERSION < 5.020) {
Branch: 1 branch
BranchTrueFalseTotal
if ($CPANPLUS::Dist::Debora::PERL_VERSION < "5.02") 0 0 0
128 0 my $prereqs = $module->status->prereqs;
129 0 ▶ if (defined $prereqs) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $prereqs) 0 0 0
130 0 ▶ if ($dist_name =~ m{\A Task-Kensho}xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dist_name =~ /\A Task-Kensho/msux) 0 0 0
131 0 delete $prereqs->{'Dist::Zilla'};
132 0 delete $prereqs->{'Pinto'};
133 }
134 }
135 }
136  
137 0 $self->SUPER::create(%params);
138 };
139  
140 0 ▶ if ($ok) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ok) 0 0 0
141 0 $status->created(0);
142  
143 # Install the Perl distribution in a staging directory.
144 0 my $stagingdir = $package->stagingdir;
145  
146 0 my @install_cmd;
147 0 my $installer_type = $module->status->installer_type;
148 0 ▶ if ($installer_type eq 'CPANPLUS::Dist::MM') {
Branch: 2 branches
BranchTrueFalseTotal
if ($installer_type eq 'CPANPLUS::Dist::MM') { } 0 0 0
elsif ($installer_type eq 'CPANPLUS::Dist::Build') { } 0 0 0
149 0 @install_cmd = ($make, 'install', "DESTDIR=$stagingdir");
150 }
151 elsif ($installer_type eq 'CPANPLUS::Dist::Build') {
152 0 @install_cmd = (
153 $perl, '-MCPANPLUS::Internals::Utils::Autoflush',
154 'Build', 'install',
155 '--destdir', $stagingdir,
156 split q{ }, $package->mb_opt,
157 );
158 }
159 else {
160 0 error("Unknown installer type $installer_type");
161 0 $ok = 0;
162 }
163  
164 0 ▶ if ($ok) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ok) 0 0 0
165 0 $ok = run(
166 command => \@install_cmd,
167 dir => $package->builddir,
168 verbose => $verbose,
169 );
170 0 ▶ if ($ok) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ok) 0 0 0
171 0 $ok = $package->sanitize_stagingdir;
172 }
173 }
174  
175 # Create a package.
176 0 ▶ if ($ok) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ok) 0 0 0
177 0 my $outputname = $package->outputname;
178 0 msg("Creating '$outputname'");
179 0 $status->dist($outputname);
180 0 $ok = $package->create(verbose => $verbose);
181 }
182  
183 0 ▶ $package->remove_stagingdir or $ok = 0;
Branch: 1 branch
BranchTrueFalseTotal
$package->remove_stagingdir or $ok = 0 0 0 0
184 }
185  
186 0 return $status->created($ok);
187 }
188  
189 0 ▶sub install {
Subroutine install: not called CC=2 SCAR=17.9
Pod documented
190 0 my ($self, %params) = @_;
191  
192 0 my $status = $self->status;
193 0 my $package = $status->_package;
194 0 my $verbose = $params{verbose};
195  
196 0 my $ok = 0;
197  
198 0 my $outputname = $package->outputname;
199 0 ▶ if (-f $outputname) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $outputname) { } 0 0 0
200 0 msg("Installing '$outputname'");
201 0 $ok = $package->install(verbose => $verbose);
202 }
203 else {
204 0 error("File not found '$outputname'");
205 }
206  
207 0 return $status->installed($ok);
208 }
209  
210 2 1;
211 __END__
↑ Summary Debora/Util.pm »