Minilla/Project.pm

filter: Statementstmt 19.7% 96 / 487 Branchbran 0.0% 0 / 208 Conditioncond 0.0% 0 / 63 MC/DCmcdc 0.0% 0 / 39 Subroutinesub 34.1% 27 / 79 Podpod 0.0% 0 / 32 totaltotal 13.5% 123 / 908 CC 137 SCAR 52.7
CC
137
Cov
13%
regenerate_readme_md
992.0
cpan_meta
380.0
static_install
132.0
CRAP 194.2
↑ Summary Minilla/WorkDir.pm »
1 package Minilla::Project;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use TOML 0.92 qw(from_toml);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use File::Basename qw(basename dirname);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use File::Spec::Functions qw(catdir catfile);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use DirHandle;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use File::pushd;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use CPAN::Meta;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Module::CPANfile;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Module::Runtime qw(require_module);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 ▶use Minilla;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use Minilla::Git qw(git_file_modes git_show_toplevel);
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use Minilla::Logger;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use Minilla::Metadata;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use Minilla::WorkDir;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use Minilla::ReleaseTest;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use Minilla::Unsupported;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use Minilla::ModuleMaker::ModuleBuild;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use Minilla::ModuleMaker::ModuleBuildTiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 ▶use Minilla::ModuleMaker::ExtUtilsMakeMaker;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use Minilla::Util qw(slurp_utf8 find_dir cmd spew_raw slurp_raw spew_utf8);
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 ▶use Encode qw(decode_utf8);
Subroutine BEGIN: called CC=1 SCAR=0.0
27 1 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 1 ▶use Term::Encoding qw(term_encoding);
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 1 has dir => (
33 is => 'rw',
34 builder => 1,
35 trigger => 1,
36 required => 1,
37 );
38  
39 has module_maker => (
40 is => 'ro',
41 0 ▶ default => sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
42 0 my $self = shift;
43 0 ▶ if ($self->config && defined($self->config->{module_maker})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->config and defined $self->config->{"module_maker"}) 0 0 0
Condition0%0/3
$self->config and defined $self->config->{"module_maker"}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->config and defined $self->config->{"module_maker"}
$self->config defined $self->config->{"module_maker"}
Truth table0%0/3
A and B
A= $self->configB= defined $self->config->{"module_maker"}
ABresult
0X0
100
111
44 # Automatic require.
45 0 my $klass = $self->config->{module_maker};
46 0 ▶ $klass = $klass =~ s/^\+// ? $klass : "Minilla::ModuleMaker::$klass";
Branch: 1 branch
BranchTrueFalseTotal
$klass =~ s/^\+// ? : 0 0 0
47 0 return $klass->new();
48 }
49 Minilla::ModuleMaker::ModuleBuildTiny->new()
50 0 },
51 1 lazy => 1,
52 );
53  
54 1 has dist_name => (
55 is => 'lazy',
56 );
57  
58 1 has build_class => (
59 is => 'lazy',
60 );
61  
62 1 has main_module_path => (
63 is => 'lazy',
64 );
65  
66 1 has metadata => (
67 is => 'lazy',
68 required => 1,
69 handles => [qw(name perl_version license)],
70 clearer => 1,
71 );
72  
73 1 has contributors => (
74 is => 'lazy',
75 );
76  
77 has skip_prepare => (
78 is => 'ro',
79 0 ▶ default => sub { 0 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
80 1 );
81  
82 1 has work_dir => (
83 is => 'lazy',
84 );
85  
86 1 has files => (
87 is => 'lazy',
88 );
89  
90 1 has file_modes => (
91 is => 'lazy',
92 );
93  
94 1 has release_branch => (
95 is => 'lazy',
96 clearer => 1,
97 );
98  
99 has no_index => (
100 is => 'ro',
101 0 ▶ default => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
102 0 my $self = shift;
103 exists $self->config->{no_index} ?
104 $self->config->{no_index} :
105 {
106 0 ▶ directory => [qw(
Branch: 1 branch
BranchTrueFalseTotal
exists $self->config->{'no_index'} ? : 0 0 0
107 t xt inc share eg examples author builder
108 ) ]
109 };
110 },
111 1 );
112  
113 has script_files => (
114 is => 'ro',
115 0 ▶ default => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
116 0 my $self = shift;
117 my $script_files = exists $self->config->{script_files} ?
118 $self->config->{script_files} :
119 0 ▶ ['script/*', 'bin/*'];
Branch: 1 branch
BranchTrueFalseTotal
exists $self->config->{'script_files'} ? : 0 0 0
120 0 join ', ', map { "glob('$_')" } @$script_files;
121 },
122 1 );
123  
124 1 ▶no Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
125  
126 0 ▶sub allow_pureperl {
Subroutine allow_pureperl: not called CC=2 SCAR=17.9
Pod undocumented
127 0 my $self = shift;
128 0 ▶ $self->config->{allow_pureperl} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->config->{'allow_pureperl'} ? : 0 0 0
129 }
130  
131 0 ▶sub manage_changes {
Subroutine manage_changes: not called CC=4 SCAR=30.0
Pod undocumented
132 0 my $self = shift;
133 0 ▶ return 1 unless exists $self->config->{manage_changes};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->config->{"manage_changes"} 0 0 0
134  
135 0 my $manage_changes = $self->config->{manage_changes};
136 0 ▶ return 0 if !$manage_changes || $manage_changes eq 'false';
Branch: 1 branch
BranchTrueFalseTotal
if not $manage_changes or $manage_changes eq "false" 0 0 0
Condition0%0/3
not $manage_changes or $manage_changes eq "false"
l!l&&r!l&&!r
000
MC/DC0%0/2
not $manage_changes or $manage_changes eq "false"
not $manage_changes $manage_changes eq "false"
Truth table0%0/3
not(A) or B
A= not $manage_changesB= $manage_changes eq "false"
ABresult
1X1
011
000
137 0 return 1;
138 }
139  
140 0 ▶sub version {
Subroutine version: not called CC=3 SCAR=24.8
Pod undocumented
141 0 my $self = shift;
142 0 ▶ my $version = $self->config->{version} || $self->metadata->version;
Condition0%0/3
$self->config->{'version'} || $self->metadata->version
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->config->{'version'} || $self->metadata->version
$self->config->{'version'} $self->metadata->version
Truth table0%0/3
A || B
A= $self->config->{'version'}B= $self->metadata->version
ABresult
1X1
011
000
143 0 ▶ unless (defined $version) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $version) 0 0 0
144 0 errorf("Minilla can't aggregate version number from '" . $self->main_module_path . '"');
145 }
146 0 return $version;
147 }
148  
149 0 ▶sub static_install {
Subroutine static_install: not called CC=11 SCAR=48.8
Pod undocumented
150 0 my $self = shift;
151 0 ▶ my $v = exists $self->config->{static_install} ? $self->config->{static_install} : 'auto';
Branch: 1 branch
BranchTrueFalseTotal
exists $self->config->{'static_install'} ? : 0 0 0
152 0 ▶ return 0+$v if $v =~ /^\d+$/;
Branch: 1 branch
BranchTrueFalseTotal
if $v =~ /^\d+$/ 0 0 0
153 0 ▶ errorf "Found unsupported value '%s' for static_install in minil.toml", $v if $v ne 'auto';
Branch: 1 branch
BranchTrueFalseTotal
if $v ne "auto" 0 0 0
154  
155 0 ▶ return 0 if $self->build_class ne 'Module::Build';
Branch: 1 branch
BranchTrueFalseTotal
if $self->build_class ne "Module::Build" 0 0 0
156 0 ▶ return 0 if $self->requires_external_bin;
Branch: 1 branch
BranchTrueFalseTotal
if $self->requires_external_bin 0 0 0
157 0 my @script_files = eval $self->script_files; # XXX
158 0 ▶ return 0 if grep { !/^script\b/ } @script_files;
Branch: 1 branch
BranchTrueFalseTotal
if grep {not /^script\b/;} @script_files 0 0 0
159 0 ▶ return 0 if %{$self->PL_files} or grep { /^lib\b.*\.PL$/ } @{$self->files};
Branch: 1 branch
BranchTrueFalseTotal
if %{$self->PL_files;} or grep {/^lib\b.*\.PL$/;} @{$self->files;} 0 0 0
Condition0%0/3
%{$self->PL_files;} or grep {/^lib\b.*\.PL$/;} @{$self->files;}
l!l&&r!l&&!r
000
MC/DC0%0/2
%{$self->PL_files;} or grep {/^lib\b.*\.PL$/;} @{$self->files;}
%{$self->PL_files;} grep {/^lib\b.*\.PL$/;} @{$self->files;}
Truth table0%0/3
A or B
A= %{$self->PL_files;}B= grep {/^lib\b.*\.PL$/;} @{$self->files;}
ABresult
1X1
011
000
160 0 ▶ return 0 if grep { /\.xs$/ } @{$self->files};
Branch: 1 branch
BranchTrueFalseTotal
if grep {/\.xs$/;} @{$self->files;} 0 0 0
161 0 ▶ return 0 if @{$self->unsupported->os};
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->unsupported->os;} 0 0 0
162  
163 0 return 1;
164 }
165  
166 0 ▶sub authors {
Subroutine authors: not called CC=3 SCAR=24.8
Pod undocumented
167 0 my $self = shift;
168 0 ▶ if (my $authors_from = $self->config->{authors_from}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $authors_from = $self->config->{"authors_from"}) 0 0 0
169 0 my $meta = Minilla::Metadata->new(
170 source => $authors_from
171 );
172 0 return $meta->authors;
173 }
174 0 ▶ $self->config->{authors} || $self->metadata->authors;
Branch: 1 branch
BranchTrueFalseTotal
$self->config->{"authors"} or $self->metadata->authors 0 0 0
175 }
176  
177 0 ▶sub unsupported {
Subroutine unsupported: not called CC=2 SCAR=17.9
Pod undocumented
178 0 my $self = shift;
179 0 ▶ my $unsupported = $self->config->{unsupported} || {};
Condition0%0/2
$self->config->{'unsupported'} || {}
l!l
00
MC/DC0%0/1
$self->config->{'unsupported'} || {}
$self->config->{'unsupported'}
Truth table0%0/2
A
A= $self->config->{'unsupported'}
Aresult
11
00
180 0 return Minilla::Unsupported->new(%$unsupported);
181 }
182  
183 0 ▶sub abstract {
Subroutine abstract: not called CC=3 SCAR=24.8
Pod undocumented
184 0 my $self = shift;
185 0 ▶ if (my $abstract_from = $self->config->{abstract_from}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $abstract_from = $self->config->{"abstract_from"}) 0 0 0
186 0 my $meta = Minilla::Metadata->new(
187 source => $abstract_from
188 );
189 0 return $meta->abstract;
190 }
191 0 ▶ $self->config->{abstract} || $self->metadata->abstract;
Branch: 1 branch
BranchTrueFalseTotal
$self->config->{"abstract"} or $self->metadata->abstract 0 0 0
192 }
193  
194 0 ▶sub badges {
Subroutine badges: not called CC=2 SCAR=17.9
Pod undocumented
195 0 my $self = shift;
196 0 ▶ $self->config->{badges} || [];
Branch: 1 branch
BranchTrueFalseTotal
$self->config->{"badges"} or [] 0 0 0
197 }
198  
199 0 ▶sub tap_harness_args {
Subroutine tap_harness_args: not called CC=1 SCAR=6.9
Pod undocumented
200 0 my $self = shift;
201 0 $self->config->{tap_harness_args};
202 }
203  
204 0 ▶sub use_xsutil {
Subroutine use_xsutil: not called CC=2 SCAR=17.9
Pod undocumented
205 0 my $self = shift;
206 0 ▶ return defined $self->config->{XSUtil} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $self->config->{'XSUtil'} ? : 0 0 0
207 }
208  
209 0 ▶sub needs_compiler_c99 {
Subroutine needs_compiler_c99: not called CC=3 SCAR=24.8
Pod undocumented
210 0 my $self = shift;
211 0 ▶ if( my $xsutil = $self->config->{XSUtil} ){
Branch: 1 branch
BranchTrueFalseTotal
if (my $xsutil = $self->config->{"XSUtil"}) 0 0 0
212 0 ▶ return $xsutil->{needs_compiler_c99} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$xsutil->{'needs_compiler_c99'} ? : 0 0 0
213 }
214 }
215  
216 0 ▶sub needs_compiler_cpp {
Subroutine needs_compiler_cpp: not called CC=3 SCAR=24.8
Pod undocumented
217 0 my $self = shift;
218 0 ▶ if( my $xsutil = $self->config->{XSUtil} ){
Branch: 1 branch
BranchTrueFalseTotal
if (my $xsutil = $self->config->{"XSUtil"}) 0 0 0
219 0 ▶ return $xsutil->{needs_compiler_cpp} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$xsutil->{'needs_compiler_cpp'} ? : 0 0 0
220 }
221 }
222  
223 0 ▶sub generate_ppport_h {
Subroutine generate_ppport_h: not called CC=3 SCAR=24.8
Pod undocumented
224 0 my $self = shift;
225 0 ▶ if( my $xsutil = $self->config->{XSUtil} ){
Branch: 1 branch
BranchTrueFalseTotal
if (my $xsutil = $self->config->{"XSUtil"}) 0 0 0
226 0 ▶ return $xsutil->{generate_ppport_h} || 0;
Condition0%0/2
$xsutil->{'generate_ppport_h'} || 0
l!l
00
MC/DC0%0/1
$xsutil->{'generate_ppport_h'} || 0
$xsutil->{'generate_ppport_h'}
Truth table0%0/2
A
A= $xsutil->{'generate_ppport_h'}
Aresult
11
00
227 }
228 }
229  
230 0 ▶sub generate_xshelper_h {
Subroutine generate_xshelper_h: not called CC=3 SCAR=24.8
Pod undocumented
231 0 my $self = shift;
232 0 ▶ if( my $xsutil = $self->config->{XSUtil} ){
Branch: 1 branch
BranchTrueFalseTotal
if (my $xsutil = $self->config->{"XSUtil"}) 0 0 0
233 0 ▶ return $xsutil->{generate_xshelper_h} || 0;
Condition0%0/2
$xsutil->{'generate_xshelper_h'} || 0
l!l
00
MC/DC0%0/1
$xsutil->{'generate_xshelper_h'} || 0
$xsutil->{'generate_xshelper_h'}
Truth table0%0/2
A
A= $xsutil->{'generate_xshelper_h'}
Aresult
11
00
234 }
235 }
236  
237 0 ▶sub cc_warnings{
Subroutine cc_warnings: not called CC=3 SCAR=24.8
Pod undocumented
238 0 my $self = shift;
239 0 ▶ if( my $xsutil = $self->config->{XSUtil} ){
Branch: 1 branch
BranchTrueFalseTotal
if (my $xsutil = $self->config->{"XSUtil"}) 0 0 0
240 0 ▶ return $xsutil->{cc_warnings} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$xsutil->{'cc_warnings'} ? : 0 0 0
241 }
242 }
243  
244 0 ▶sub _build_dir {
Subroutine _build_dir: not called CC=1 SCAR=6.9
245 0 my $self = shift;
246 0 return git_show_toplevel();
247 }
248  
249 0 ▶sub _trigger_dir {
Subroutine _trigger_dir: not called CC=2 SCAR=17.9
250 0 my ($self, $dir) = @_;
251 0 ▶ unless (File::Spec->file_name_is_absolute($dir)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ("File::Spec"->file_name_is_absolute($dir)) 0 0 0
252 0 $self->dir(File::Spec->rel2abs($dir));
253 }
254 }
255  
256 0 ▶sub config {
Subroutine config: not called CC=4 SCAR=30.0
Pod undocumented
257 0 my $self = shift;
258  
259 0 my $toml_path = File::Spec->catfile($self->dir, 'minil.toml');
260 0 ▶ if (-f $toml_path) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $toml_path) { } 0 0 0
261 0 my ($conf, $err) = from_toml(slurp_utf8($toml_path));
262 0 ▶ if ($err) {
Branch: 1 branch
BranchTrueFalseTotal
if ($err) 0 0 0
263 0 errorf("TOML error in %s: %s\n", $toml_path, $err);
264 }
265 0 ▶ $self->_patch_config_for_mb($conf) unless $conf->{module_maker};
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"module_maker"} 0 0 0
266 0 $conf;
267 } else {
268 0 +{};
269 }
270 }
271  
272 0 ▶sub _patch_config_for_mb {
Subroutine _patch_config_for_mb: not called CC=4 SCAR=30.0
273 0 my($self, $conf) = @_;
274  
275 0 ▶ if (exists $conf->{build} or exists $conf->{XSUtil}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $conf->{"build"} or exists $conf->{"XSUtil"}) 0 0 0
Condition0%0/3
exists $conf->{"build"} or exists $conf->{"XSUtil"}
l!l&&r!l&&!r
000
MC/DC0%0/2
exists $conf->{"build"} or exists $conf->{"XSUtil"}
exists $conf->{"build"} exists $conf->{"XSUtil"}
Truth table0%0/3
A or B
A= exists $conf->{"build"}B= exists $conf->{"XSUtil"}
ABresult
1X1
011
000
276 0 ▶ warn <<WARN unless $self->{__already_warned}++;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"__already_warned"}++ 0 0 0
277 !
278 ! WARNING:
279 ! module_maker is not set in your Minilla config (minil.toml), but found [build] or [XSUtil] section in it.
280 ! Defaulting to Module::Build, but you're suggested to add the following to your minil.toml:
281 !
282 ! module_maker="ModuleBuild"
283 !
284 ! This friendly warning will go away in the next major release, and Minilla will default to ModuleBuildTiny
285 ! when module_maker is not explicitly set in minil.toml.
286 !
287 WARN
288 0 $conf->{module_maker} = "ModuleBuild";
289 }
290  
291 0 return;
292 }
293  
294 0 ▶sub c_source {
Subroutine c_source: not called CC=2 SCAR=17.9
Pod undocumented
295 0 my $self = shift;
296 0 ▶ $self->config->{c_source} ? join(' ', @{$self->config->{c_source}}) : '';
Branch: 1 branch
BranchTrueFalseTotal
$self->config->{'c_source'} ? : 0 0 0
297 }
298  
299 0 ▶sub _build_dist_name {
Subroutine _build_dist_name: not called CC=7 SCAR=40.3
300 0 my $self = shift;
301  
302 0 my $dist_name;
303 0 ▶ if ($self->config && defined($self->config->{name})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->config and defined $self->config->{"name"}) 0 0 0
Condition0%0/3
$self->config and defined $self->config->{"name"}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->config and defined $self->config->{"name"}
$self->config defined $self->config->{"name"}
Truth table0%0/3
A and B
A= $self->configB= defined $self->config->{"name"}
ABresult
0X0
100
111
304 0 my $conf = $self->config;
305 0 ▶ if ($conf->{name} =~ /::/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{"name"} =~ /::/) 0 0 0
306 0 (my $better_name = $conf->{name}) =~ s/::/-/g;
307 0 Carp::croak(qq(You shouldn't set 'name="$conf->{name}"' in minil.toml. You need to set the value as 'name="$better_name"'.));
308 }
309 0 $dist_name = $conf->{name};
310 }
311 0 ▶ unless (defined $dist_name) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $dist_name) 0 0 0
312 0 infof("Detecting project name from directory name.\n");
313 0 $dist_name = $self->_detect_project_name_from_dir;
314 }
315 0 ▶ if ($dist_name eq '.') { Carp::confess("Heh? " . $self->dir); }
Branch: 1 branch
BranchTrueFalseTotal
if ($dist_name eq ".") 0 0 0
316  
317 0 ▶ unless ($dist_name) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dist_name) 0 0 0
318 0 errorf("Cannot detect distribution name from minil.toml or directory name(cwd: %s, dir:%s)\n", Cwd::getcwd(), $self->dir);
319 }
320  
321 0 return $dist_name;
322 }
323  
324 0 ▶sub _detect_project_name_from_dir {
Subroutine _detect_project_name_from_dir: not called CC=1 SCAR=6.9
325 0 my $self = shift;
326  
327 0 local $_ = basename($self->dir);
328 0 $_ =~ s!--!-!g;
329 0 $_ =~ s!\Ap5-!!;
330 0 return $_;
331 }
332  
333 0 ▶sub _build_build_class {
Subroutine _build_build_class: not called CC=4 SCAR=30.0
334 0 my $self = shift;
335  
336 0 my $build_class;
337 0 ▶ if (my $conf = $self->config) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $conf = $self->config) 0 0 0
338 0 $build_class = $conf->{build}{build_class};
339 }
340  
341 0 ▶ return $build_class if $build_class;
Branch: 1 branch
BranchTrueFalseTotal
if $build_class 0 0 0
342  
343 0 ▶ return $self->use_xsutil ? 'Module::Build::XSUtil' : 'Module::Build';
Branch: 1 branch
BranchTrueFalseTotal
$self->use_xsutil ? : 0 0 0
344 }
345  
346 0 ▶sub _build_main_module_path {
Subroutine _build_main_module_path: not called CC=4 SCAR=30.0
347 0 my $self = shift;
348  
349 0 my $dist_name = $self->dist_name;
350 0 my $source_path = $self->_detect_source_path($dist_name);
351 0 ▶ unless (defined($source_path) && -e $source_path) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $source_path and -e $source_path) 0 0 0
Condition0%0/3
defined $source_path and -e $source_path
!ll&&!rl&&r
000
MC/DC0%0/2
defined $source_path and -e $source_path
defined $source_path -e $source_path
Truth table0%0/3
A and B
A= defined $source_pathB= -e $source_path
ABresult
0X0
100
111
352 0 ▶ errorf("%s not found.\n", $source_path || "main module($dist_name)");
Condition0%0/2
$source_path || "main module($dist_name)"
l!l
00
MC/DC0%0/1
$source_path || "main module($dist_name)"
$source_path
Truth table0%0/2
A
A= $source_path
Aresult
11
00
353 }
354  
355 0 infof("Retrieving meta data from %s.\n", $source_path);
356 0 return $source_path;
357 }
358  
359 0 ▶sub _build_metadata {
Subroutine _build_metadata: not called CC=2 SCAR=17.9
360 0 my $self = shift;
361  
362 0 my $config = +{%{$self->config}};
363 0 ▶ if (my $license = delete $config->{license}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $license = delete $config->{"license"}) 0 0 0
364 0 $config->{_license_name} = $license;
365 }
366  
367 # fill from main_module
368 0 my $metadata = Minilla::Metadata->new(
369 source => $self->main_module_path,
370 %$config,
371 );
372 0 infof("Name: %s\n", $metadata->name);
373 0 infof("Abstract: %s\n", Encode::encode(term_encoding(), $metadata->abstract));
374 0 infof("Version: %s\n", $metadata->version);
375  
376 0 return $metadata;
377 }
378  
379 0 ▶sub _case_insensitive_match {
Subroutine _case_insensitive_match: not called CC=5 SCAR=34.0
380 0 my $path = shift;
381 0 my @path = File::Spec->splitdir($path);
382 0 my $realpath = '.';
383 0 LOOP: for my $part (@path) {
384 my $d = DirHandle->new($realpath)
385 0 ▶ or do {
Branch: 1 branch
BranchTrueFalseTotal
my $d = "DirHandle"->new($realpath) or do { return } 0 0 0
386 # warn "Cannot open dirhandle";
387 0 return;
388 };
389 0 ▶ while (defined($_ = $d->read)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = $d->read)) 0 0 0
390 0 ▶ if (uc($_) eq uc($part)) {
Branch: 1 branch
BranchTrueFalseTotal
if (uc $_ eq uc $part) 0 0 0
391 0 $realpath = catfile($realpath, $_);
392 0 next LOOP;
393 }
394 }
395  
396 # does not match
397 # warn "Does not match: $part in $realpath";
398 0 return undef;
399 }
400 0 return $realpath;
401 }
402  
403 0 ▶sub format_tag {
Subroutine format_tag: not called CC=2 SCAR=17.9
Pod undocumented
404 0 my ($self, $version) = @_;
405 0 ▶ if (defined(my $format = $self->config->{tag_format})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $format = $self->config->{'tag_format'})) { } 0 0 0
406 0 (my $tag = $format) =~ s/%v/$version/;
407 0 $tag;
408 } else {
409 0 $version;
410 }
411 }
412  
413 0 ▶sub _detect_source_path {
Subroutine _detect_source_path: not called CC=4 SCAR=30.0
414 0 my ($self, $dir) = @_;
415  
416 # like cpan-outdated => lib/App/cpanminus.pm
417 0 my $pat2 = "App-" . do {
418 0 local $_ = $dir;
419 0 s!-!!;
420 0 $_;
421 };
422 0 for my $path ("App-$dir", $pat2, $dir) {
423 0 $path =~ s!::!/!g;
424 0 $path =~ s!-!/!g;
425 0 $path = "lib/${path}.pm";
426  
427 0 ▶ return $path if -f $path;
Branch: 1 branch
BranchTrueFalseTotal
if -f $path 0 0 0
428  
429 0 $path = _case_insensitive_match($path);
430 0 ▶ return $path if defined($path);
Branch: 1 branch
BranchTrueFalseTotal
if defined $path 0 0 0
431 }
432  
433 0 return undef;
434 }
435  
436 0 ▶sub load_cpanfile {
Subroutine load_cpanfile: not called CC=1 SCAR=6.9
Pod undocumented
437 0 my $self = shift;
438 0 Module::CPANfile->load(catfile($self->dir, 'cpanfile'));
439 }
440  
441 0 ▶sub cpan_meta {
Subroutine cpan_meta: not called CC=19 SCAR=59.4
Pod undocumented
442 0 my ($self, $release_status) = @_;
443 0 ▶ $release_status ||= ($self->version =~ /_/ ? 'unstable' : 'stable');
Branch: 1 branch
BranchTrueFalseTotal
$self->version =~ /_/ ? : 0 0 0
Condition0%0/3
$release_status ||= $self->version =~ /_/ ? "unstable" : "stable"
l!l&&r!l&&!r
000
MC/DC0%0/2
$release_status ||= $self->version =~ /_/ ? "unstable" : "stable"
$release_status $self->version =~ /_/ ? "unstable" : "stable"
Truth table0%0/3
A ||= B
A= $release_statusB= $self->version =~ /_/ ? "unstable" : "stable"
ABresult
1X1
011
000
444  
445 0 my $cpanfile = $self->load_cpanfile;
446 0 my $merged_prereqs = $cpanfile->prereqs->with_merged_prereqs(
447 CPAN::Meta::Prereqs->new($self->module_maker->prereqs($self))
448 );
449 0 $merged_prereqs = $merged_prereqs->with_merged_prereqs(
450 CPAN::Meta::Prereqs->new(Minilla::ReleaseTest->prereqs)
451 );
452 0 ▶ if ($self->metadata->perl_version) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->metadata->perl_version) 0 0 0
453 0 $merged_prereqs = $merged_prereqs->with_merged_prereqs(
454 CPAN::Meta::Prereqs->new(+{
455 runtime => {
456 requires => {
457 perl => $self->metadata->perl_version,
458 }
459 }
460 })
461 );
462 }
463 0 $merged_prereqs = $merged_prereqs->as_string_hash;
464  
465 0 ▶ my $dat = {
Condition0%0/2
$release_status || 'stable'
l!l
00
MC/DC0%0/1
$release_status || 'stable'
$release_status
Truth table0%0/2
A
A= $release_status
Aresult
11
00
466 "meta-spec" => {
467 "version" => "2",
468 "url" => "http://search.cpan.org/perldoc?CPAN::Meta::Spec"
469 },
470 license => [ $self->license->meta2_name ],
471 abstract => $self->abstract,
472 dynamic_config => 0,
473 version => $self->version,
474 name => $self->dist_name,
475 prereqs => $merged_prereqs,
476 generated_by => "Minilla/$Minilla::VERSION",
477 release_status => $release_status || 'stable',
478 no_index => $self->no_index,
479 x_static_install => $self->static_install,
480 };
481 0 ▶ unless ($dat->{abstract}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dat->{"abstract"}) 0 0 0
482 0 errorf("Cannot retrieve 'abstract' from %s. You need to write POD in your main module.\n", $self->dir);
483 }
484 0 ▶ if ($self->authors) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->authors) { } 0 0 0
485 0 $dat->{author} = $self->authors;
486 } else {
487 0 errorf("Cannot determine 'author' from %s\n", $self->dir);
488 }
489 0 ▶ if ($self->contributors && @{$self->contributors} > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->contributors and @{$self->contributors;} > 0) 0 0 0
Condition0%0/3
$self->contributors and @{$self->contributors;} > 0
!ll&&!rl&&r
000
MC/DC0%0/2
$self->contributors and @{$self->contributors;} > 0
$self->contributors @{$self->contributors;} > 0
Truth table0%0/3
A and B
A= $self->contributorsB= @{$self->contributors;} > 0
ABresult
0X0
100
111
490 0 $dat->{x_contributors} = $self->contributors;
491 }
492 0 ▶ if (my $authority = $self->config->{authority}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $authority = $self->config->{"authority"}) 0 0 0
493 0 $dat->{x_authority} = $authority;
494 }
495 0 ▶ if (my $metadata = $self->config->{Metadata}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $metadata = $self->config->{"Metadata"}) 0 0 0
496 0 $dat->{$_} = $metadata->{$_} for keys %$metadata;
497 }
498  
499 # fill 'provides' section
500 0 ▶ if ($release_status ne 'unstable') {
Branch: 1 branch
BranchTrueFalseTotal
if ($release_status ne "unstable") 0 0 0
501 0 my $provides = Module::Metadata->provides(
502 dir => File::Spec->catdir($self->dir, 'lib'),
503 version => 2
504 );
505 0 ▶ unless (%$provides) {
Branch: 1 branch
BranchTrueFalseTotal
unless (%$provides) 0 0 0
506 0 errorf("%s does not provides any package. Abort.\n", $self->dir);
507 }
508 0 $dat->{provides} = $provides;
509 }
510  
511 # fill repository information
512 0 my $git_info = $self->extract_git_info;
513 0 ▶ if ($git_info->{bugtracker}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($git_info->{"bugtracker"}) 0 0 0
514 0 $dat->{resources}->{bugtracker} = $git_info->{bugtracker};
515 }
516 0 ▶ if ($git_info->{repository}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($git_info->{"repository"}) 0 0 0
517 0 $dat->{resources}->{repository} = $git_info->{repository};
518 }
519 0 ▶ if ($git_info->{homepage}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($git_info->{"homepage"}) 0 0 0
520 0 $dat->{resources}->{homepage} = $git_info->{homepage};
521 }
522  
523 # optional features
524 0 ▶ if ($cpanfile->features) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cpanfile->features) 0 0 0
525 0 my $optional_features = {};
526 0 foreach my $feature ($cpanfile->features) {
527 0 $optional_features->{$feature->identifier} = {
528 description => $feature->description,
529 prereqs => $feature->prereqs->as_string_hash,
530 }
531 }
532 0 $dat->{optional_features} = $optional_features;
533 }
534  
535 0 my $meta = CPAN::Meta->new($dat);
536 0 return $meta;
537 }
538  
539 0 ▶sub finalize_cpan_meta {
Subroutine finalize_cpan_meta: not called CC=2 SCAR=17.9
Pod undocumented
540 0 my ($self, $meta) = @_;
541  
542 0 my $release_dat = $self->cpan_meta->as_struct;
543 0 my $dat = { %{$meta->as_struct} };
544 0 $dat->{release_status} = $release_dat->{release_status};
545 0 ▶ if (exists $release_dat->{provides}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $release_dat->{'provides'}) { } 0 0 0
546 0 $dat->{provides} = $release_dat->{provides};
547 } else {
548 0 delete $dat->{provides};
549 }
550  
551 0 return CPAN::Meta->new($dat);
552 }
553  
554 0 ▶sub extract_git_info {
Subroutine extract_git_info: not called CC=8 SCAR=42.8
Pod undocumented
555 0 my $self = shift;
556  
557 0 my $guard = pushd($self->dir);
558  
559 0 my $bugtracker;
560 my $repository;
561 0 my $homepage;
562 0 ▶ if ( my $registered_url = `git config --get remote.origin.url` ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $registered_url = `git config --get remote.origin.url`) 0 0 0
563 0 $registered_url =~ s/\n//g;
564 # XXX Make it public clone URL, but this only works with github
565 0 ▶ if ($registered_url !~ m{^file://} && $registered_url =~ /(?:github|gitlab)\.com/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $registered_url =~ m[^file://] and $registered_url =~ /(?:github|gitlab)\.com/) { } 0 0 0
Condition0%0/3
not $registered_url =~ m[^file://] and $registered_url =~ /(?:github|gitlab)\.com/
!ll&&!rl&&r
000
MC/DC0%0/2
not $registered_url =~ m[^file://] and $registered_url =~ /(?:github|gitlab)\.com/
not $registered_url =~ m[^file://] $registered_url =~ /(?:github|gitlab)\.com/
Truth table0%0/3
not(A) and B
A= not $registered_url =~ m[^file://]B= $registered_url =~ /(?:github|gitlab)\.com/
ABresult
0X0
100
111
566 0 my ($git_service, $user, $repo) = $registered_url =~ m{
567 (github\.com|gitlab\.com)
568 (?:(?::[0-9]+)?/|:)([^/]+)
569 /
570 (.+?)(?:\.git)?
571 $
572 }ix;
573 0 my $git_url = "https://$git_service/$user/$repo.git";
574 0 my $http_url = "https://$git_service/$user/$repo";
575 0 ▶ unless ($self->config->{no_github_issues}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->config->{"no_github_issues"}) 0 0 0
576 0 $bugtracker = +{
577 web => "$http_url/issues",
578 };
579 }
580 $repository = +{
581 0 type => "git",
582 url => $git_url,
583 web => $http_url,
584 };
585 0 ▶ $homepage = $self->config->{homepage} || $http_url;
Condition0%0/3
$self->config->{'homepage'} || $http_url
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->config->{'homepage'} || $http_url
$self->config->{'homepage'} $http_url
Truth table0%0/3
A || B
A= $self->config->{'homepage'}B= $http_url
ABresult
1X1
011
000
586 } else {
587 0 ▶ if ($registered_url !~ m{^(?:https?|ssh|git)://}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($registered_url =~ m[^(?:https?|ssh|git)://]) 0 0 0
588 # We can't do much more than this, but we need to fix
589 # user@host:path/to/repo.git to git://$host/path/to/repo.git in
590 # order to work with CPAN::Meta
591 0 $registered_url =~ s{
592 \A
593 [^@]+ # user name, which we toss away
594 @
595 ([^:]+) # anything other than a ":"
596 :
597 (.+) # anything, which is the repository
598 \Z
599 }{git://$1/$2}gx;
600 }
601  
602 # normal repository
603 0 ▶ if ($registered_url !~ m{^file://}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($registered_url =~ m[^file://]) 0 0 0
604 0 $repository = +{
605 type => "git",
606 url => $registered_url,
607 };
608 }
609 }
610 }
611  
612 return +{
613 0 bugtracker => $bugtracker,
614 repository => $repository,
615 homepage => $homepage,
616 }
617 }
618  
619 0 ▶sub readme_from {
Subroutine readme_from: not called CC=2 SCAR=17.9
Pod undocumented
620 0 my $self = shift;
621 0 ▶ $self->config->{readme_from} || $self->main_module_path;
Branch: 1 branch
BranchTrueFalseTotal
$self->config->{"readme_from"} or $self->main_module_path 0 0 0
622 }
623  
624 0 ▶sub regenerate_files {
Subroutine regenerate_files: not called CC=2 SCAR=17.9
Pod undocumented
625 0 my $self = shift;
626  
627 0 $self->regenerate_meta_json();
628 0 $self->regenerate_readme_md();
629 0 $self->module_maker->generate($self);
630 0 ▶ if (Cwd::getcwd() ne $self->dir) {
Branch: 1 branch
BranchTrueFalseTotal
if (Cwd::getcwd() ne $self->dir) 0 0 0
631 0 my $guard = pushd($self->dir);
632 0 $self->module_maker->generate($self);
633 }
634 }
635  
636 0 ▶sub regenerate_meta_json {
Subroutine regenerate_meta_json: not called CC=1 SCAR=6.9
Pod undocumented
637 0 my $self = shift;
638  
639 0 my $meta = $self->cpan_meta('unstable');
640 0 $meta->save(File::Spec->catfile($self->dir, 'META.json'), {
641 version => '2'
642 });
643 }
644  
645 0 ▶sub generate_minil_toml {
Subroutine generate_minil_toml: not called CC=3 SCAR=24.8
Pod undocumented
646 0 my ($self, $profile) = @_;
647  
648 0 my $fname = File::Spec->catfile($self->dir, 'minil.toml');
649 0 my $project_name = $self->_detect_project_name_from_dir;
650 0 my $content = join("\n",
651 qq{name = "$project_name"},
652 qq{badges = ["github-actions/test.yml"]},
653 );
654  
655 0 ▶ if ($profile eq 'ModuleBuild') {
Branch: 2 branches
BranchTrueFalseTotal
if ($profile eq 'ModuleBuild') { } 0 0 0
elsif ($profile eq 'ExtUtilsMakeMaker') { } 0 0 0
656 0 $content .= qq{\nmodule_maker="ModuleBuild"\n};
657 } elsif ($profile eq 'ExtUtilsMakeMaker') {
658 0 $content .= qq{\nmodule_maker="ExtUtilsMakeMaker"\n};
659 } else {
660 0 $content .= qq{\nmodule_maker="ModuleBuildTiny"\n};
661 }
662 0 $content .= qq{static_install = "auto"\n};
663  
664 0 spew_raw($fname, $content . "\n");
665 }
666  
667 0 ▶sub regenerate_readme_md {
Subroutine regenerate_readme_md: not called CC=31 SCAR=69.0
Pod undocumented
668 0 my $self = shift;
669  
670 0 ▶ my $markdown_maker = $self->config->{markdown_maker} || 'Pod::Markdown';
Condition0%0/2
$self->config->{'markdown_maker'} || 'Pod::Markdown'
l!l
00
MC/DC0%0/1
$self->config->{'markdown_maker'} || 'Pod::Markdown'
$self->config->{'markdown_maker'}
Truth table0%0/2
A
A= $self->config->{'markdown_maker'}
Aresult
11
00
671 0 require_module($markdown_maker);
672 0 ▶ if ($markdown_maker eq 'Pod::Markdown') {
Branch: 1 branch
BranchTrueFalseTotal
if ($markdown_maker eq "Pod::Markdown") 0 0 0
673 0 $markdown_maker->VERSION('1.322');
674 }
675  
676 0 ▶ my $parser = $markdown_maker->new( %{ $self->config->{markdown_maker_opts} || {} } );;
Condition0%0/2
$self->config->{'markdown_maker_opts'} || {}
l!l
00
MC/DC0%0/1
$self->config->{'markdown_maker_opts'} || {}
$self->config->{'markdown_maker_opts'}
Truth table0%0/2
A
A= $self->config->{'markdown_maker_opts'}
Aresult
11
00
677 0 ▶ if (not $parser->isa('Pod::Markdown')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($parser->isa("Pod::Markdown")) 0 0 0
678 0 errorf("'markdown_maker' config key must be a subclass of Pod::Markdown\n");
679 }
680 0 $parser->parse_from_file($self->readme_from);
681  
682 0 my $fname = File::Spec->catfile($self->dir, 'README.md');
683 0 my $markdown = $parser->as_markdown;
684  
685 0 ▶ if (ref $self->badges eq 'ARRAY' && scalar @{$self->badges} > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->badges eq "ARRAY" and scalar @{$self->badges;} > 0) 0 0 0
Condition0%0/3
ref $self->badges eq "ARRAY" and scalar @{$self->badges;} > 0
!ll&&!rl&&r
000
MC/DC0%0/2
ref $self->badges eq "ARRAY" and scalar @{$self->badges;} > 0
ref $self->badges eq "ARRAY" scalar @{$self->badges;} > 0
Truth table0%0/3
A and B
A= ref $self->badges eq "ARRAY"B= scalar @{$self->badges;} > 0
ABresult
0X0
100
111
686 0 my $user_name;
687 my $repository_name;
688  
689 0 my $git_info = $self->extract_git_info;
690 0 ▶ if (my $web_url = $git_info->{repository}->{web}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $web_url = $git_info->{"repository"}{"web"}) 0 0 0
691 0 ($user_name, $repository_name) = $web_url =~ m!https://.+/(.+)/(.+)!;
692 }
693 0 my $branch = $self->release_branch;
694 0 my @badges;
695 0 ▶ if ($user_name && $repository_name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($user_name and $repository_name) 0 0 0
Condition0%0/3
$user_name and $repository_name
!ll&&!rl&&r
000
MC/DC0%0/2
$user_name and $repository_name
$user_name $repository_name
Truth table0%0/3
A and B
A= $user_nameB= $repository_name
ABresult
0X0
100
111
696 0 for my $badge (@{$self->badges}) {
697 0 my $uri = URI->new( $badge );
698 0 my $service_name = $uri->path;
699 0 ▶ if ($service_name =~ /^travis(?:-ci\.(?:org|com))?$/) {
Branch: 11 branches
BranchTrueFalseTotal
if ($service_name =~ /^travis(?:-ci\.(?:org|com))?$/) { } 0 0 0
elsif ($service_name eq 'appveyor') { } 0 0 0
elsif ($service_name eq 'coveralls') { } 0 0 0
elsif ($service_name eq 'codecov') { } 0 0 0
elsif ($service_name eq 'gitter') { } 0 0 0
elsif ($service_name eq 'circleci') { } 0 0 0
elsif ($service_name eq 'metacpan') { } 0 0 0
elsif ($service_name eq 'kritika') { } 0 0 0
elsif ($service_name =~ m[^github-actions(?:/(.+))?$]) { } 0 0 0
elsif ($service_name eq 'gitlab-pipeline') { } 0 0 0
elsif ($service_name eq 'gitlab-coverage') { } 0 0 0
700 0 my $build_uri = $uri->clone;
701 0 $build_uri->scheme('https');
702 0 $build_uri->path("$user_name/$repository_name");
703 0 $build_uri->query_form({});
704 0 my $image_uri = $uri->clone;
705 0 $image_uri->scheme('https');
706 0 $image_uri->path("$user_name/$repository_name.svg");
707 0 my %image_uri_qs = $image_uri->query_form;
708 0 ▶ $image_uri_qs{branch} = $branch if !defined($image_uri_qs{branch});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $image_uri_qs{"branch"} 0 0 0
709 0 ▶ if ($service_name =~ /^travis(?:-ci\.(?:org|com))$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($service_name =~ /^travis(?:-ci\.(?:org|com))$/) { } 0 0 0
elsif (not defined $image_uri_qs{'token'}) { } 0 0 0
710 0 $_->host($service_name) foreach ($build_uri, $image_uri);
711 } elsif (!defined($image_uri_qs{token})) {
712 0 $_->host("travis-ci.org") foreach ($build_uri, $image_uri);
713 } else {
714 0 $_->host("travis-ci.com") foreach ($build_uri, $image_uri);
715 }
716 # Sort the query params so that the end URL is
717 # deterministic and easier to test.
718 0 $image_uri->query_form( map { ( $_, $image_uri_qs{$_} ) } sort keys %image_uri_qs );
719 0 push @badges, "[![Build Status]($image_uri)]($build_uri)";
720 } elsif ($service_name eq 'appveyor') {
721 0 ( my $appveyor_repository_name = $repository_name ) =~ s/\./-/g;
722 0 push @badges, "[![Build Status](https://img.shields.io/appveyor/ci/$user_name/$appveyor_repository_name/$branch.svg?logo=appveyor)](https://ci.appveyor.com/project/$user_name/$appveyor_repository_name/branch/$branch)";
723 } elsif ($service_name eq 'coveralls') {
724 0 push @badges, "[![Coverage Status](https://img.shields.io/coveralls/$user_name/$repository_name/$branch.svg?style=flat)](https://coveralls.io/r/$user_name/$repository_name?branch=$branch)"
725 } elsif ($service_name eq 'codecov') {
726 0 push @badges, "[![Coverage Status](http://codecov.io/github/$user_name/$repository_name/coverage.svg?branch=$branch)](https://codecov.io/github/$user_name/$repository_name?branch=$branch)";
727 } elsif ($service_name eq 'gitter') {
728 0 push @badges, "[![Gitter chat](https://badges.gitter.im/$user_name/$repository_name.png)](https://gitter.im/$user_name/$repository_name)";
729 } elsif ($service_name eq 'circleci') {
730 0 push @badges, "[![Build Status](https://circleci.com/gh/$user_name/$repository_name.svg)](https://circleci.com/gh/$user_name/$repository_name)";
731 } elsif ($service_name eq 'metacpan') {
732 0 ▶ my $module_name = $self->config->{name} || $repository_name;
Condition0%0/3
$self->config->{'name'} || $repository_name
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->config->{'name'} || $repository_name
$self->config->{'name'} $repository_name
Truth table0%0/3
A || B
A= $self->config->{'name'}B= $repository_name
ABresult
1X1
011
000
733 0 push @badges, "[![MetaCPAN Release](https://badge.fury.io/pl/$module_name.svg)](https://metacpan.org/release/$module_name)";
734 } elsif ($service_name eq 'kritika') {
735 0 my $build_uri = $uri->clone;
736 0 $build_uri->scheme('https');
737 0 $build_uri->host('kritika.io');
738 0 $build_uri->path("/users/$user_name/repos/$user_name+$repository_name");
739 0 $build_uri->query_form({});
740 0 my $image_uri = $uri->clone;
741 0 $image_uri->scheme('https');
742 0 $image_uri->host('kritika.io');
743 0 $image_uri->path("/users/$user_name/repos/$user_name+$repository_name/heads/$branch/status.svg");
744 0 push @badges, "[![Kritika Status]($image_uri)]($build_uri)";
745 } elsif ($service_name =~ m!^github-actions(?:/(.+))?$!) {
746 # ref. https://docs.github.com/en/actions/how-tos/monitor-workflows/add-a-status-badge
747 0 ▶ my $workflow_file = $1 || 'test.yml';
Condition0%0/2
$1 || 'test.yml'
l!l
00
MC/DC0%0/1
$1 || 'test.yml'
$1
Truth table0%0/2
A
A= $1
Aresult
11
00
748 0 ▶ if ($workflow_file !~ /\.(?:yml|yaml)$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($workflow_file =~ /\.(?:yml|yaml)$/) 0 0 0
749 0 $workflow_file .= '.yml';
750 }
751 0 my $workflow_name = $workflow_file;
752 0 $workflow_name =~ s/\.ya?ml$//;
753 0 push @badges, "[![Actions Status](https://github.com/$user_name/$repository_name/actions/workflows/$workflow_file/badge.svg?branch=$branch)](https://github.com/$user_name/$repository_name/actions?workflow=$workflow_name)";
754 } elsif ($service_name eq 'gitlab-pipeline') {
755 0 push @badges, "[![Gitlab pipeline](https://gitlab.com/$user_name/$repository_name/badges/$branch/pipeline.svg)](https://gitlab.com/$user_name/$repository_name/-/commits/$branch)";
756 } elsif ($service_name eq 'gitlab-coverage') {
757 0 push @badges, "[![Gitlab coverage](https://gitlab.com/$user_name/$repository_name/badges/$branch/coverage.svg)](https://gitlab.com/$user_name/$repository_name/-/commits/$branch)";
758 }
759 }
760 }
761  
762 0 $markdown = "\n" . $markdown;
763 0 $markdown = join(' ', @badges) . $markdown
764 }
765  
766 0 spew_utf8($fname, $markdown);
767 }
768  
769 0 ▶sub verify_prereqs {
Subroutine verify_prereqs: not called CC=2 SCAR=17.9
Pod undocumented
770 0 my ($self) = @_;
771  
772 0 ▶ if ($Minilla::AUTO_INSTALL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Minilla::AUTO_INSTALL) 0 0 0
773 0 system('cpanm', '--quiet', '--installdeps', '--with-develop', '.');
774 }
775 }
776  
777 0 ▶sub _build_contributors {
Subroutine _build_contributors: not called CC=2 SCAR=17.9
778 0 my $self = shift;
779  
780 0 ▶ return [] unless (`git show-ref --head`);
Branch: 1 branch
BranchTrueFalseTotal
unless `git show-ref --head` 0 0 0
781  
782 0 ▶ my $normalize = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
783 0 local $_ = shift;
784 0 ▶ if (/<([^>]+)>/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/<([^>]+)>/) { } 0 0 0
785 0 $1;
786 } else {
787 0 $_;
788 }
789 0 };
790 0 my @lines = do {
791 0 my %uniq;
792 0 reverse grep { !$uniq{$normalize->($_)}++ } split /\n/, `git log --format="%aN <%aE>"`
793 };
794 0 my %is_author = map { $normalize->($_) => 1 } @{$self->authors};
795 0 @lines = map { decode_utf8($_) } @lines;
796 0 @lines = grep { !$is_author{$normalize->($_)} } @lines;
797 0 @lines = grep { $_ ne 'Your Name <you@example.com>' } @lines;
798 0 @lines = grep { ! /^\(no author\) <\(no author\)\@[\d\w\-]+>$/ } @lines;
799 0 [sort @lines];
800 }
801  
802 0 ▶sub _build_work_dir {
Subroutine _build_work_dir: not called CC=1 SCAR=6.9
803 0 my $self = shift;
804 0 Minilla::WorkDir->new(
805 project => $self,
806 file_modes => $self->file_modes,
807 skip_prepare => $self->skip_prepare,
808 );
809 }
810  
811 0 ▶sub _build_file_modes {
Subroutine _build_file_modes: not called CC=1 SCAR=6.9
812 0 my $self = shift;
813 0 my $guard = pushd($self->dir);
814 0 return git_file_modes();
815 }
816  
817 0 ▶sub _build_files {
Subroutine _build_files: not called CC=2 SCAR=17.9
818 0 my $self = shift;
819 0 my $conf = $self->config->{'FileGatherer'};
820 my @files = Minilla::FileGatherer->new(
821 exclude_match => $conf->{exclude_match},
822 0 ▶ exists $conf->{include_dotfiles} ? (include_dotfiles => $conf->{include_dotfiles}) : (),
Branch: 1 branch
BranchTrueFalseTotal
exists $conf->{'include_dotfiles'} ? : 0 0 0
823 )->gather_files(
824 $self->dir
825 );
826 0 \@files;
827 }
828  
829 0 ▶sub _build_release_branch {
Subroutine _build_release_branch: not called CC=3 SCAR=24.8
830 0 my $self = shift;
831 0 ▶ if (my $br = $self->config->{release}->{branch}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $br = $self->config->{"release"}{"branch"}) 0 0 0
832 0 return $br;
833 }
834 0 my $show = `git remote show origin`;
835 0 my ($br) = $show =~ /^\s*HEAD branch:\s(\S+)$/m;
836 # For backward compatibility, fallback to 'master' just in case,
837 # but it's unlikely to be used in practice.
838 0 ▶ return $br || 'master';
Condition0%0/2
$br || 'master'
l!l
00
MC/DC0%0/1
$br || 'master'
$br
Truth table0%0/2
A
A= $br
Aresult
11
00
839 }
840  
841 0 ▶sub perl_files {
Subroutine perl_files: not called CC=2 SCAR=17.9
Pod undocumented
842 0 my $self = shift;
843 0 my @files = @{$self->files};
844 grep {
845 0 ▶ $_ =~ /\.(?:pm|pl|t)$/i || slurp_raw($_) =~ m{ ^ \#\! .* perl }ix
Condition0%0/3
$_ =~ /\.(?:pm|pl|t)$/i || slurp_raw($_) =~ / ^ \#\! .* perl /xi
l!l&&r!l&&!r
000
MC/DC0%0/2
$_ =~ /\.(?:pm|pl|t)$/i || slurp_raw($_) =~ / ^ \#\! .* perl /xi
$_ =~ /\.(?:pm|pl|t)$/i slurp_raw($_) =~ / ^ \#\! .* perl /xi
Truth table0%0/3
A || B
A= $_ =~ /\.(?:pm|pl|t)$/iB= slurp_raw($_) =~ / ^ \#\! .* perl /xi
ABresult
1X1
011
000
846 } @files;
847 }
848  
849 0 ▶sub PL_files { shift->config->{PL_files} || +{} }
Subroutine PL_files: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
+(shift())->config->{"PL_files"} or {} 0 0 0
850  
851 0 ▶sub requires_external_bin {
Subroutine requires_external_bin: not called CC=1 SCAR=6.9
Pod undocumented
852 0 my $self = shift;
853 0 return $self->config->{requires_external_bin};
854 }
855  
856 # @return true if the project is valid, false otherwise.
857 0 ▶sub validate {
Subroutine validate: not called CC=2 SCAR=17.9
Pod undocumented
858 0 my $self = shift;
859 0 my $module_maker = $self->module_maker;
860 0 ▶ if ($module_maker->can('validate')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($module_maker->can('validate')) { } 0 0 0
861 0 return $module_maker->validate();
862 } else {
863 0 return 1;
864 }
865 }
866  
867 1 1;
↑ Summary Minilla/WorkDir.pm »