ModuleBuildTiny.pm

filter: Statementstmt 15.3% 66 / 431 Branchbran 0.0% 0 / 198 Conditioncond 0.0% 0 / 81 MC/DCmcdc 0.0% 0 / 44 Subroutinesub 34.6% 18 / 52 Podpod 4.7% 1 / 21 totaltotal 10.2% 85 / 827 CC 151 SCAR 53.7
CC
151
Cov
9%
__ANON__
702.0
__ANON__
600.0
regenerate_files
210.0
CRAP 215.0
« ModuleBuildTiny/Dist.pm ↑ Summary
1 package App::ModuleBuildTiny;
2  
3 1 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 our $VERSION = '0.051';
6  
7 1 ▶use Exporter 5.57 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 our @EXPORT = qw/modulebuildtiny/;
9  
10 1 ▶use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use CPAN::Meta;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Data::Section::Simple 'get_data_section';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Encode qw/encode_utf8 decode_utf8/;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use ExtUtils::Manifest 1.75 qw/manifind maniskip maniread/;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use File::Basename qw/dirname/;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use File::Path qw/mkpath/;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use File::Slurper qw/write_text write_binary read_binary/;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use File::Spec::Functions qw/catfile rel2abs/;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use Getopt::Long 2.36 'GetOptionsFromArray';
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use JSON::MaybeXS qw/decode_json/;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use Module::Runtime 'require_module';
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use Text::Template;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 1 ▶use App::ModuleBuildTiny::Dist;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 1 ▶use Env qw/$AUTHOR_TESTING $RELEASE_TESTING $AUTOMATED_TESTING $EXTENDED_TESTING $NONINTERACTIVE_TESTING $SHELL $HOME $USERPROFILE/;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 1 Getopt::Long::Configure(qw/require_order gnu_compat bundling/);
29  
30 0 ▶sub prompt {
Subroutine prompt: not called CC=5 SCAR=34.0
Pod undocumented
31 0 my($mess, $def) = @_;
32  
33 0 ▶ my $dispdef = defined $def ? " [$def]" : "";
Branch: 1 branch
BranchTrueFalseTotal
defined $def ? : 0 0 0
34  
35 0 local $|=1;
36 0 local $\;
37 0 print "$mess$dispdef ";
38  
39 0 ▶ my $ans = <STDIN> // '';
Condition0%0/2
readline STDIN // ""
l!l
00
MC/DC0%0/1
readline STDIN // ""
readline STDIN
Truth table0%0/2
A
A= readline STDIN
Aresult
11
00
40 0 chomp $ans;
41 0 ▶ return $ans ne '' ? decode_utf8($ans) : $def // '';
Branch: 1 branch
BranchTrueFalseTotal
$ans ne '' ? : 0 0 0
Condition0%0/2
$def // ""
l!l
00
MC/DC0%0/1
$def // ""
$def
Truth table0%0/2
A
A= $def
Aresult
11
00
42 }
43  
44 0 ▶sub prompt_yn {
Subroutine prompt_yn: not called CC=4 SCAR=30.0
Pod undocumented
45 0 my ($description, $default) = @_;
46 0 my $result;
47 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
length $result and not $result =~ /^(y|n|-)/iu and do { do { $result = prompt("$description [y/n]", $default ? "y" : "n") } } 0 0 0
Condition0%0/3
length $result and not $result =~ /^(y|n|-)/iu
!ll&&!rl&&r
000
MC/DC0%0/2
length $result and not $result =~ /^(y|n|-)/iu
length $result not $result =~ /^(y|n|-)/iu
Truth table0%0/3
A and not(B)
A= length $resultB= not $result =~ /^(y|n|-)/iu
ABresult
0X0
100
111
48 0 ▶ $result = prompt("$description [y/n]", $default ? 'y' : 'n');
Branch: 1 branch
BranchTrueFalseTotal
$default ? : 0 0 0
49 } while (length $result and $result !~ /^(y|n|-)/i);
50 0 return lc(substr $result, 0 , 1) eq 'y';
51 }
52  
53 0 ▶sub create_license_for {
Subroutine create_license_for: not called CC=1 SCAR=6.9
Pod undocumented
54 0 my ($license_name, $author) = @_;
55 0 my $module = "Software::License::$license_name";
56 0 require_module($module);
57 0 return $module->new({ holder => $author });
58 }
59  
60 0 ▶sub fill_in {
Subroutine fill_in: not called CC=1 SCAR=6.9
Pod undocumented
61 0 my ($template, $hash) = @_;
62 0 return Text::Template->new(TYPE => 'STRING', SOURCE => $template)->fill_in(HASH => $hash);
63 }
64  
65 0 ▶sub write_module {
Subroutine write_module: not called CC=1 SCAR=6.9
Pod undocumented
66 0 my %opts = @_;
67 0 my $template = get_data_section('Module.pm') =~ s/ ^ % (\w+) /=$1/gxmsr;
68 0 my $filename = catfile('lib', split /::/, $opts{module_name}) . '.pm';
69 0 my $content = fill_in($template, \%opts);
70 0 mkpath(dirname($filename));
71 0 write_text($filename, $content);
72 0 return $filename;
73 }
74  
75 0 ▶sub write_changes {
Subroutine write_changes: not called CC=1 SCAR=6.9
Pod undocumented
76 0 my %opts = @_;
77 0 my $template = get_data_section('Changes');
78 0 my $content = fill_in($template, \%opts);
79 0 write_text('Changes', $content);
80 }
81  
82 0 ▶sub write_maniskip {
Subroutine write_maniskip: not called CC=1 SCAR=6.9
Pod undocumented
83 0 my $distname = shift;
84 0 write_text('MANIFEST.SKIP', "#!include_default\n$distname-.*\nREADME.pod\n");
85 }
86  
87 0 ▶sub write_readme {
Subroutine write_readme: not called CC=1 SCAR=6.9
Pod undocumented
88 0 my %opts = @_;
89 0 my $template = get_data_section('README');
90 0 write_text('README', fill_in($template, \%opts));
91 }
92  
93 0 ▶sub read_json {
Subroutine read_json: not called CC=2 SCAR=17.9
Pod undocumented
94 0 my $filename = shift;
95 0 ▶ -f $filename or return;
Branch: 1 branch
BranchTrueFalseTotal
-f $filename or return 0 0 0
96 0 return decode_json(read_binary($filename));
97 }
98  
99 0 ▶sub write_json {
Subroutine write_json: not called CC=2 SCAR=17.9
Pod undocumented
100 0 my ($filename, $content) = @_;
101 0 my $dirname = dirname($filename);
102 0 ▶ mkdir $dirname if not -d $dirname;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $dirname 0 0 0
103 0 my $json = JSON::MaybeXS->new->utf8->pretty->canonical->encode($content);
104 0 return write_binary($filename, $json);
105 }
106  
107 0 ▶sub bump_versions {
Subroutine bump_versions: not called CC=2 SCAR=17.9
Pod undocumented
108 0 my (%opts) = @_;
109 0 require App::RewriteVersion;
110 0 my $app = App::RewriteVersion->new(%opts);
111 0 my $trial = delete $opts{trial};
112 0 ▶ my $new_version = defined $opts{version} ? delete $opts{version} : $app->bump_version($app->current_version);
Branch: 1 branch
BranchTrueFalseTotal
defined $opts{'version'} ? : 0 0 0
113 0 $app->rewrite_versions($new_version, is_trial => $trial);
114 }
115  
116 0 ▶sub insert_options {
Subroutine insert_options: not called CC=1 SCAR=6.9
Pod undocumented
117 0 my ($opts, $config) = @_;
118 0 $opts->{add_repository} = !!$config->{auto_repo};
119 0 $opts->{add_bugtracker} = !!$config->{auto_tracker};
120 }
121  
122 0 ▶sub regenerate {
Subroutine regenerate: not called CC=11 SCAR=48.8
Pod undocumented
123 0 my ($files, $config, %opts) = @_;
124 0 my %files = map { $_ => 1 } @{$files};
125 0 my @dirty = @{$files};
126  
127 0 ▶ if ($opts{bump}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{"bump"}) 0 0 0
128 0 bump_versions(%opts);
129 0 $files{'Changes'}++;
130 0 push @dirty, 'Changes';
131 }
132  
133 0 insert_options(\%opts, $config);
134 0 my $dist = App::ModuleBuildTiny::Dist->new(%opts, regenerate => \%files);
135 0 my @generated = grep { $files{$_} } $dist->files;
136 0 for my $filename (@generated) {
137 0 ▶ say "Updating $filename" if $opts{verbose};
Branch: 1 branch
BranchTrueFalseTotal
if $opts{"verbose"} 0 0 0
138 0 ▶ write_binary($filename, $dist->get_file($filename)) if !$opts{dry_run};
Branch: 1 branch
BranchTrueFalseTotal
unless $opts{"dry_run"} 0 0 0
139 }
140  
141 0 ▶ if ($opts{commit}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{"commit"}) 0 0 0
142 0 require Git::Wrapper;
143 0 my $git = Git::Wrapper->new('.');
144 0 ▶ if ($opts{bump}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{"bump"}) 0 0 0
145 0 push @dirty, 'lib';
146 0 ▶ push @dirty, 'script' if -d 'script';
Branch: 1 branch
BranchTrueFalseTotal
if -d "script" 0 0 0
147 }
148 0 my $allowed = join '|', map qr{^\Q$_\E$}, @dirty;
149 0 my @modified = grep /$allowed/, $git->ls_files({ modified => 1 });
150  
151 0 ▶ if (@modified) {
Branch: 1 branch
BranchTrueFalseTotal
if (@modified) { } 0 0 0
152 0 my @changes = $dist->get_changes;
153 0 my $version = 'v' . $dist->version;
154 0 ▶ my $message = $opts{message} || ($opts{bump} ? join '', $version, "\n\n", @changes : 'Regenerate');
Branch: 1 branch
BranchTrueFalseTotal
$opts{'bump'} ? : 0 0 0
Condition0%0/3
$opts{'message'} || ($opts{'bump'} ? join('', $version, "\n\n", @changes) : 'Regenerate')
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts{'message'} || ($opts{'bump'} ? join('', $version, "\n\n", @changes) : 'Regenerate')
$opts{'message'} ($opts{'bump'} ? join('', $version, "\n\n", @changes) : 'Regenerate')
Truth table0%0/3
A || B
A= $opts{'message'}B= ($opts{'bump'} ? join('', $version, "\n\n", @changes) : 'Regenerate')
ABresult
1X1
011
000
155 0 $git->commit({ m => $message }, @dirty);
156 } else {
157 0 say "No modifications to commit";
158 }
159 }
160 }
161  
162 1 my %prompt_for = (
163 open => \&prompt,
164 yn => \&prompt_yn,
165 );
166  
167 1 my @config_items = (
168 [ 'author' , 'What is the author\'s name?', 'open' ],
169 [ 'email' , 'What is the author\'s email?', 'open', ],
170 [ 'license' , 'What license do you want to use?', 'open', 'Perl_5' ],
171  
172 [ 'write_buildpl' , 'Do you want to write your Build.PL file to your filesystem?', 'yn', !!1],
173 [ 'write_meta' , 'Do you want to write your meta files to your filesystem?', 'yn', !!1],
174 [ 'write_manifest', 'Do you want to write your manifest files to your filesystem?', 'yn', !!1],
175 [ 'write_license' , 'Do you want to write your LICENSE file to your filesystem?', 'yn', !!1],
176 [ 'write_readme' , 'Do you want to write your README file to your filesystem?', 'yn', !!1],
177  
178 [ 'auto_git' , 'Do you want mbtiny to automatically handle git for you?', 'yn', !!1 ],
179 [ 'auto_bump' , 'Do you want mbtiny to automatically bump on regenerate for you?', 'yn', !!1 ],
180 [ 'auto_scan' , 'Do you want mbtiny to automatically scan dependencies for you?', 'yn', !!1 ],
181 [ 'auto_repo' , 'Do you want mbtiny to automatically add a repository link to the metadata', 'yn', !!1 ],
182 [ 'auto_tracker' , 'Do you want mbtiny to automatically add a bugtracker link to the metadata', 'yn', !!1 ],
183 );
184  
185 1 my %fallback_config = (
186 'write_buildpl' => 'write_build',
187 'write_meta' => 'write_build',
188 'write_manifest' => 'write_build',
189 );
190  
191 1 my @delete_config = qw/write_build/;
192  
193 0 ▶sub ask {
Subroutine ask: not called CC=5 SCAR=34.0
Pod undocumented
194 0 my ($config, $item, $local_default) = @_;
195 0 my ($key, $description, $type, $global_default) = @{$item};
196 0 ▶ my $value = $prompt_for{$type}->($description, $local_default // $global_default);
Condition0%0/3
$local_default // $global_default
l!l&&r!l&&!r
000
MC/DC0%0/2
$local_default // $global_default
$local_default $global_default
Truth table0%0/3
A // B
A= $local_defaultB= $global_default
ABresult
1X1
011
000
197  
198 0 ▶ if ($value ne '-') {
Branch: 1 branch
BranchTrueFalseTotal
if ($value ne '-') { } 0 0 0
199 0 ▶ $config->{$key} = $type eq 'open' ? $value : $value ? JSON::MaybeXS::true : JSON::MaybeXS::false;
Branch: 2 branches
BranchTrueFalseTotal
$type eq 'open' ? : 0 0 0
$value ? : 0 0 0
200 }
201 else {
202 0 delete $config->{$key};
203 }
204 }
205  
206 0 ▶sub show_item {
Subroutine show_item: not called CC=4 SCAR=30.0
Pod undocumented
207 0 my ($config, $key, $type) = @_;
208 0 ▶ return defined $config->{$key} ? $type eq 'open' ? $config->{$key} : $config->{$key} ? 'true' : 'false' : '(undefined)';
Branch: 3 branches
BranchTrueFalseTotal
defined $config->{$key} ? : 0 0 0
$type eq 'open' ? : 0 0 0
$config->{$key} ? : 0 0 0
209 }
210  
211 0 ▶sub get_settings_file {
Subroutine get_settings_file: not called CC=2 SCAR=17.9
Pod undocumented
212 0 ▶ local $HOME = $USERPROFILE if $^O eq 'MSWin32';
Branch: 1 branch
BranchTrueFalseTotal
if $^O eq "MSWin32" 0 0 0
213 0 return catfile(glob('~'), qw/.mbtiny conf/);
214 }
215  
216 1 my %default_settings = (
217 auto_bump => 1,
218 auto_git => 1,
219 auto_scan => 1,
220  
221 write_build => 1,
222 write_license => 1,
223 write_readme => 1,
224 );
225  
226 0 ▶sub get_settings {
Subroutine get_settings: not called CC=6 SCAR=37.4
Pod undocumented
227 0 ▶ my $default = shift // {};
Condition0%0/2
shift() // {}
l!l
00
MC/DC0%0/1
shift() // {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
228 0 my $settings_file = get_settings_file;
229 0 ▶ my $settings = -f $settings_file ? read_json($settings_file) : $default;
Branch: 1 branch
BranchTrueFalseTotal
-f $settings_file ? : 0 0 0
230 0 for my $item (@config_items) {
231 0 my ($key, $description, $type, $default) = @{$item};
232 0 ▶ next unless exists $settings->{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $settings->{$key} 0 0 0
233 0 ▶ next unless $type eq 'yn';
Branch: 1 branch
BranchTrueFalseTotal
unless $type eq "yn" 0 0 0
234 0 $settings->{$key} = !!$settings->{$key};
235 }
236 0 return $settings;
237 }
238  
239 1 my $config_file = 'dist.json';
240  
241 0 ▶sub get_config {
Subroutine get_config: not called CC=5 SCAR=34.0
Pod undocumented
242 0 ▶ my $config = -f $config_file ? read_json($config_file) : {};
Branch: 1 branch
BranchTrueFalseTotal
-f $config_file ? : 0 0 0
243 0 for my $item (@config_items) {
244 0 my ($key, $description, $type, $default) = @{$item};
245 0 ▶ next unless exists $config->{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $config->{$key} 0 0 0
246 0 ▶ next unless $type eq 'yn';
Branch: 1 branch
BranchTrueFalseTotal
unless $type eq "yn" 0 0 0
247 0 $config->{$key} = !!$config->{$key};
248 }
249 0 return $config;
250 }
251  
252 0 ▶sub extra_tests {
Subroutine extra_tests: not called CC=4 SCAR=30.0
Pod undocumented
253 0 my @dirs;
254 0 ▶ if ($AUTHOR_TESTING) {
Branch: 1 branch
BranchTrueFalseTotal
if ($App::ModuleBuildTiny::AUTHOR_TESTING) 0 0 0
255 0 push @dirs, 'xt/author';
256 0 push @dirs, glob 'xt/*.t';
257 }
258 0 ▶ push @dirs, 'xt/release' if $RELEASE_TESTING;
Branch: 1 branch
BranchTrueFalseTotal
if $App::ModuleBuildTiny::RELEASE_TESTING 0 0 0
259 0 ▶ push @dirs, 'xt/extended' if $EXTENDED_TESTING;
Branch: 1 branch
BranchTrueFalseTotal
if $App::ModuleBuildTiny::EXTENDED_TESTING 0 0 0
260 0 return grep -e, @dirs;
261 }
262  
263 1 my @meta_files = qw/META.json META.yml/;
264  
265 0 ▶sub regenerate_files {
Subroutine regenerate_files: not called CC=14 SCAR=53.5
Pod undocumented
266 0 my $config = shift;
267 0 my @result;
268 0 ▶ push @result, 'Build.PL' if $config->{write_buildpl} // $config->{write_build} // 1;
Branch: 1 branch
BranchTrueFalseTotal
if ($config->{"write_buildpl"} // $config->{"write_build"}) // 1 0 0 0
Condition0%0/5
($config->{"write_buildpl"} // $config->{"write_build"}) // 1
l!l
00
$config->{"write_buildpl"} // $config->{"write_build"}
l!l&&r!l&&!r
000
MC/DC0%0/2
($config->{"write_buildpl"} // $config->{"write_build"}) // 1
$config->{"write_buildpl"} $config->{"write_build"}
Truth table0%0/3
A // B
A= $config->{"write_buildpl"}B= $config->{"write_build"}
ABresult
1X1
011
000
269 0 ▶ push @result, @meta_files if $config->{write_meta} // $config->{write_build} // 1;
Branch: 1 branch
BranchTrueFalseTotal
if ($config->{"write_meta"} // $config->{"write_build"}) // 1 0 0 0
Condition0%0/5
($config->{"write_meta"} // $config->{"write_build"}) // 1
l!l
00
$config->{"write_meta"} // $config->{"write_build"}
l!l&&r!l&&!r
000
MC/DC0%0/2
($config->{"write_meta"} // $config->{"write_build"}) // 1
$config->{"write_meta"} $config->{"write_build"}
Truth table0%0/3
A // B
A= $config->{"write_meta"}B= $config->{"write_build"}
ABresult
1X1
011
000
270 0 ▶ push @result, 'MANIFEST' if $config->{write_manifest} // $config->{write_build} // 1;
Branch: 1 branch
BranchTrueFalseTotal
if ($config->{"write_manifest"} // $config->{"write_build"}) // 1 0 0 0
Condition0%0/5
($config->{"write_manifest"} // $config->{"write_build"}) // 1
l!l
00
$config->{"write_manifest"} // $config->{"write_build"}
l!l&&r!l&&!r
000
MC/DC0%0/2
($config->{"write_manifest"} // $config->{"write_build"}) // 1
$config->{"write_manifest"} $config->{"write_build"}
Truth table0%0/3
A // B
A= $config->{"write_manifest"}B= $config->{"write_build"}
ABresult
1X1
011
000
271 0 ▶ push @result, 'LICENSE' if $config->{write_license} // 1;
Branch: 1 branch
BranchTrueFalseTotal
if $config->{"write_license"} // 1 0 0 0
Condition0%0/2
$config->{"write_license"} // 1
l!l
00
MC/DC0%0/1
$config->{"write_license"} // 1
$config->{"write_license"}
Truth table0%0/2
A
A= $config->{"write_license"}
Aresult
11
00
272 0 ▶ push @result, 'README' if $config->{write_readme} // 1;
Branch: 1 branch
BranchTrueFalseTotal
if $config->{"write_readme"} // 1 0 0 0
Condition0%0/2
$config->{"write_readme"} // 1
l!l
00
MC/DC0%0/1
$config->{"write_readme"} // 1
$config->{"write_readme"}
Truth table0%0/2
A
A= $config->{"write_readme"}
Aresult
11
00
273 0 return @result;
274 }
275  
276 1 my %boolean = (
277 true => !!1,
278 false => !!0,
279 );
280  
281 my %actions = (
282 0 ▶ dist => sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
283 0 my @arguments = @_;
284 0 ▶ GetOptionsFromArray(\@arguments, \my %opts, qw/trial verbose!/) or return 2;
Branch: 1 branch
BranchTrueFalseTotal
&GetOptionsFromArray(\@arguments, \my %opts, ("trial", "verbose!")) or return 2 0 0 0
285 0 my $dist = App::ModuleBuildTiny::Dist->new(%opts);
286 0 insert_options(\%opts, get_config);
287 0 ▶ die "Trial mismatch" if $opts{trial} && $dist->release_status ne 'testing';
Branch: 1 branch
BranchTrueFalseTotal
if $opts{"trial"} and $dist->release_status ne "testing" 0 0 0
Condition0%0/3
$opts{"trial"} and $dist->release_status ne "testing"
!ll&&!rl&&r
000
MC/DC0%0/2
$opts{"trial"} and $dist->release_status ne "testing"
$opts{"trial"} $dist->release_status ne "testing"
Truth table0%0/3
A and B
A= $opts{"trial"}B= $dist->release_status ne "testing"
ABresult
0X0
100
111
288 0 $dist->preflight_check(%opts);
289 0 my $filename = $dist->archivename;
290 0 ▶ printf "tar czf %s %s\n", $filename, join ' ', $dist->files if $opts{verbose};
Branch: 1 branch
BranchTrueFalseTotal
if $opts{"verbose"} 0 0 0
291 0 $dist->write_tarball($filename);
292 0 return 0;
293 },
294 0 ▶ distdir => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
295 0 my @arguments = @_;
296 0 ▶ GetOptionsFromArray(\@arguments, \my %opts, qw/trial verbose!/) or return 2;
Branch: 1 branch
BranchTrueFalseTotal
&GetOptionsFromArray(\@arguments, \my %opts, ("trial", "verbose!")) or return 2 0 0 0
297 0 insert_options(\%opts, get_config);
298 0 my $dist = App::ModuleBuildTiny::Dist->new(%opts);
299 0 $dist->write_dir($dist->fullname, $opts{verbose});
300 0 return 0;
301 },
302 0 ▶ test => sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
303 0 my @arguments = @_;
304 0 $AUTHOR_TESTING = 1;
305 0 ▶ GetOptionsFromArray(\@arguments, 'release!' => \$RELEASE_TESTING, 'author!' => \$AUTHOR_TESTING, 'automated!' => \$AUTOMATED_TESTING,
Branch: 1 branch
BranchTrueFalseTotal
&GetOptionsFromArray(\@arguments, "release!", \$App::ModuleBuildTiny::RELEASE_TESTING, "author!", \$App::ModuleBuildTiny::AUTHOR_TESTING, "automated!", \$App::ModuleBuildTiny::AUTOMATED_TESTING, "extended!", \$App::ModuleBuildTiny::EXTENDED_TESTING, "non-interactive!", \$App::ModuleBuildTiny::NONINTERACTIVE_TESTING, "jobs|j=i", \my $jobs, "inc|I=s\@", \my @inc) or return 2 0 0 0
306 'extended!' => \$EXTENDED_TESTING, 'non-interactive!' => \$NONINTERACTIVE_TESTING, 'jobs|j=i' => \my $jobs, 'inc|I=s@' => \my @inc)
307 or return 2;
308 0 insert_options(\my %opts, get_config);
309 0 my $dist = App::ModuleBuildTiny::Dist->new(%opts);
310 0 my @args;
311 0 ▶ push @args, '-j', $jobs if defined $jobs;
Branch: 1 branch
BranchTrueFalseTotal
if defined $jobs 0 0 0
312 0 push @args, map {; '-I', rel2abs($_) } @inc;
313 0 ▶ push @args, 't' if -e 't';
Branch: 1 branch
BranchTrueFalseTotal
if -e "t" 0 0 0
314 0 push @args, extra_tests();
315 0 return $dist->run(commands => [ [ 'prove', '-br', @args ] ], build => 1, verbose => 1);
316 },
317 0 ▶ upload => sub {
Subroutine __ANON__: not called CC=12 SCAR=50.5
318 0 my @arguments = @_;
319 0 my $config = get_config;
320 0 ▶ my %opts = $config->{auto_git} ? (tag => 1, push => '') : ();
Branch: 1 branch
BranchTrueFalseTotal
$config->{'auto_git'} ? : 0 0 0
321 0 ▶ GetOptionsFromArray(\@arguments, \%opts, qw/trial config=s silent tag! push:s nopush|no-push/) or return 2;
Branch: 1 branch
BranchTrueFalseTotal
&GetOptionsFromArray(\@arguments, \%opts, ("trial", "config=s", "silent", "tag!", "push:s", "nopush|no-push")) or return 2 0 0 0
322 0 insert_options(\%opts, get_config);
323  
324 0 my $dist = App::ModuleBuildTiny::Dist->new;
325 0 $dist->preflight_check(%opts);
326 0 local ($AUTHOR_TESTING, $RELEASE_TESTING) = (1, 1);
327 0 my @commands = ([ './Build', 'test' ]);
328 0 my @extra_tests = extra_tests;
329 0 ▶ push @commands, [ 'prove', '-br', @extra_tests ] if @extra_tests;
Branch: 1 branch
BranchTrueFalseTotal
if @extra_tests 0 0 0
330 0 ▶ $dist->run(commands => \@commands, build => 1, verbose => !$opts{silent}) or return 1;
Branch: 1 branch
BranchTrueFalseTotal
$dist->run("commands", \@commands, "build", 1, "verbose", !$opts{"silent"}) or return 1 0 0 0
331  
332 0 my $sure = prompt_yn('Do you want to continue the release process?', !!0);
333 0 ▶ if ($sure) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sure) 0 0 0
334 0 my $file = $dist->write_tarball($dist->archivename);
335 0 require CPAN::Upload::Tiny;
336 0 CPAN::Upload::Tiny->VERSION('0.009');
337 0 my $uploader = CPAN::Upload::Tiny->new_from_config_or_stdin($opts{config});
338 0 $uploader->upload_file($file);
339 0 ▶ print "Successfully uploaded $file\n" if not $opts{silent};
Branch: 1 branch
BranchTrueFalseTotal
unless $opts{"silent"} 0 0 0
340  
341 0 ▶ if ($opts{tag}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{"tag"}) 0 0 0
342 0 require Git::Wrapper;
343 0 my $git = Git::Wrapper->new('.');
344 0 my $version = 'v' . $dist->version;
345 0 $git->tag('-m' => $version, $version);
346 }
347  
348 0 ▶ if (defined $opts{push} and not $opts{nopush}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opts{"push"} and not $opts{"nopush"}) 0 0 0
Condition0%0/3
defined $opts{"push"} and not $opts{"nopush"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $opts{"push"} and not $opts{"nopush"}
defined $opts{"push"} not $opts{"nopush"}
Truth table0%0/3
A and not(B)
A= defined $opts{"push"}B= not $opts{"nopush"}
ABresult
0X0
100
111
349 0 require Git::Wrapper;
350 0 my $git = Git::Wrapper->new('.');
351  
352 0 ▶ my @remote = length $opts{push} ? $opts{push} : ();
Branch: 1 branch
BranchTrueFalseTotal
length $opts{'push'} ? : 0 0 0
353 0 $git->push(@remote);
354 0 ▶ $git->push({ tags => 1 }, @remote) if $opts{tag};
Branch: 1 branch
BranchTrueFalseTotal
if $opts{"tag"} 0 0 0
355 }
356 }
357 0 return 0;
358 },
359 0 ▶ run => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
360 0 my @arguments = @_;
361 0 ▶ die "No arguments given to run\n" if not @arguments;
Branch: 1 branch
BranchTrueFalseTotal
unless @arguments 0 0 0
362 0 ▶ GetOptionsFromArray(\@arguments, 'build!' => \(my $build = 1), 'allow_failure|allow-failure!' => \my $allow_failure) or return 2;
Branch: 1 branch
BranchTrueFalseTotal
&GetOptionsFromArray(\@arguments, "build!", \(my $build = 1), "allow_failure|allow-failure!", \my $allow_failure) or return 2 0 0 0
363 0 insert_options(\my %opts, get_config);
364 0 my $dist = App::ModuleBuildTiny::Dist->new(%opts);
365 0 return $dist->run(commands => [ [ $SHELL ] ], build => $build, verbose => 0, allow_failure => $allow_failure);
366 },
367 0 ▶ shell => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
368 0 my @arguments = @_;
369 0 ▶ GetOptionsFromArray(\@arguments, 'build!' => \my $build, 'allow_failure|allow-failure!' => \my $allow_failure) or return 2;
Branch: 1 branch
BranchTrueFalseTotal
&GetOptionsFromArray(\@arguments, "build!", \my $build, "allow_failure|allow-failure!", \my $allow_failure) or return 2 0 0 0
370 0 insert_options(\my %opts, get_config);
371 0 my $dist = App::ModuleBuildTiny::Dist->new(%opts);
372 0 return $dist->run(commands => [ [ $SHELL ] ], build => $build, verbose => 0, allow_failure => $allow_failure);
373 },
374 0 ▶ listdeps => sub {
Subroutine __ANON__: not called CC=7 SCAR=40.3
375 0 my @arguments = @_;
376 0 ▶ GetOptionsFromArray(\@arguments, \my %opts, qw/json only_missing|only-missing|missing omit_core|omit-core=s author versions/) or return 2;
Branch: 1 branch
BranchTrueFalseTotal
&GetOptionsFromArray(\@arguments, \my %opts, ("json", "only_missing|only-missing|missing", "omit_core|omit-core=s", "author", "versions")) or return 2 0 0 0
377 0 insert_options(\%opts, get_config);
378 0 my $dist = App::ModuleBuildTiny::Dist->new(%opts);
379  
380 0 require CPAN::Meta::Prereqs::Filter;
381 0 my $prereqs = CPAN::Meta::Prereqs::Filter::filter_prereqs($dist->meta->effective_prereqs, %opts);
382  
383 0 ▶ if (!$opts{json}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $opts{'json'}) { } 0 0 0
384 0 my @phases = qw/build test configure runtime/;
385 0 ▶ push @phases, 'develop' if $opts{author};
Branch: 1 branch
BranchTrueFalseTotal
if $opts{"author"} 0 0 0
386  
387 0 my $reqs = $prereqs->merged_requirements(\@phases);
388 0 $reqs->clear_requirement('perl');
389  
390 0 my @modules = sort { lc $a cmp lc $b } $reqs->required_modules;
391 0 ▶ if ($opts{versions}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{'versions'}) { } 0 0 0
392 0 say "$_ = ", $reqs->requirements_for_module($_) for @modules;
393 }
394 else {
395 0 say for @modules;
396 }
397 }
398 else {
399 0 print JSON::MaybeXS->new->ascii->canonical->pretty->encode($prereqs->as_string_hash);
400 }
401 0 return 0;
402 },
403 0 ▶ regenerate => sub {
Subroutine __ANON__: not called CC=7 SCAR=40.3
404 0 my @arguments = @_;
405 0 my $config = get_config;
406 0 my %opts;
407 0 ▶ GetOptionsFromArray(\@arguments, \%opts, qw/trial bump! version=s verbose dry_run|dry-run commit! scan! message=s/) or return 2;
Branch: 1 branch
BranchTrueFalseTotal
&GetOptionsFromArray(\@arguments, \%opts, ("trial", "bump!", "version=s", "verbose", "dry_run|dry-run", "commit!", "scan!", "message=s")) or return 2 0 0 0
408 0 ▶ my @files = @arguments ? @arguments : regenerate_files($config);
Branch: 1 branch
BranchTrueFalseTotal
@arguments ? : 0 0 0
409 0 ▶ if (!@arguments) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@arguments) 0 0 0
410 0 ▶ $opts{bump} //= $config->{auto_bump};
Condition0%0/3
$opts{"bump"} //= $config->{"auto_bump"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts{"bump"} //= $config->{"auto_bump"}
$opts{"bump"} $config->{"auto_bump"}
Truth table0%0/3
A //= B
A= $opts{"bump"}B= $config->{"auto_bump"}
ABresult
1X1
011
000
411 0 ▶ $opts{commit} //= $config->{auto_git};
Condition0%0/3
$opts{"commit"} //= $config->{"auto_git"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts{"commit"} //= $config->{"auto_git"}
$opts{"commit"} $config->{"auto_git"}
Truth table0%0/3
A //= B
A= $opts{"commit"}B= $config->{"auto_git"}
ABresult
1X1
011
000
412 0 ▶ $opts{scan} //= $config->{auto_scan};
Condition0%0/3
$opts{"scan"} //= $config->{"auto_scan"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts{"scan"} //= $config->{"auto_scan"}
$opts{"scan"} $config->{"auto_scan"}
Truth table0%0/3
A //= B
A= $opts{"scan"}B= $config->{"auto_scan"}
ABresult
1X1
011
000
413 }
414  
415 0 regenerate(\@files, $config, %opts);
416  
417 0 return 0;
418 },
419 0 ▶ scan => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
420 0 my @arguments = @_;
421 0 my %opts = (sanitize => 1);
422 0 ▶ GetOptionsFromArray(\@arguments, \%opts, qw/omit_core|omit-core=s sanitize! omit=s@/) or return 2;
Branch: 1 branch
BranchTrueFalseTotal
&GetOptionsFromArray(\@arguments, \%opts, ("omit_core|omit-core=s", "sanitize!", "omit=s\@")) or return 2 0 0 0
423 0 insert_options(\%opts, get_config);
424 0 my $dist = App::ModuleBuildTiny::Dist->new(%opts, regenerate => { 'META.json' => 1 });
425 0 my $prereqs = $dist->scan_prereqs(%opts);
426 0 write_json('prereqs.json', $prereqs->as_string_hash);
427 0 return 0;
428 },
429 0 ▶ setup => sub {
Subroutine __ANON__: not called CC=26 SCAR=65.5
430 0 my @arguments = @_;
431 0 my $config_file = get_settings_file();
432 0 ▶ my $config = -f $config_file ? read_json($config_file) : {};
Branch: 1 branch
BranchTrueFalseTotal
-f $config_file ? : 0 0 0
433  
434 0 ▶ my $mode = @arguments ? shift @arguments : 'upgrade';
Branch: 1 branch
BranchTrueFalseTotal
@arguments ? : 0 0 0
435  
436 0 ▶ if ($mode eq 'upgrade') {
Branch: 7 branches
BranchTrueFalseTotal
if ($mode eq 'upgrade') { } 0 0 0
elsif ($mode eq 'minimal') { } 0 0 0
elsif ($mode eq 'all') { } 0 0 0
elsif ($mode eq 'get') { } 0 0 0
elsif ($mode eq 'set') { } 0 0 0
elsif ($mode eq 'list') { } 0 0 0
elsif ($mode eq 'reset') { } 0 0 0
437 0 for my $item (@config_items) {
438 0 ▶ next if defined $config->{ $item->[0] };
Branch: 1 branch
BranchTrueFalseTotal
if defined $$config{$item->[0]} 0 0 0
439 0 ▶ my $default = $config->{ $fallback_config{ $item->[0] } // '' };
Condition0%0/2
$fallback_config{$item->[0]} // ""
l!l
00
MC/DC0%0/1
$fallback_config{$item->[0]} // ""
$fallback_config{$item->[0]}
Truth table0%0/2
A
A= $fallback_config{$item->[0]}
Aresult
11
00
440 0 ask($config, $item, $default);
441 }
442 # delete $config->{$_} for @delete_config;
443 0 write_json($config_file, $config);
444 }
445 elsif ($mode eq 'minimal') {
446 0 for my $item (@config_items) {
447 0 ▶ next if defined $config->{ $item->[0] };
Branch: 1 branch
BranchTrueFalseTotal
if defined $$config{$item->[0]} 0 0 0
448 0 ▶ if (defined $item->[3]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $item->[3]) { } 0 0 0
449 0 $config->{ $item->[0] } = $item->[3];
450 } else {
451 0 ask($config, $item);
452 }
453 }
454 0 delete $config->{$_} for @delete_config;
455 0 write_json($config_file, $config);
456 }
457 elsif ($mode eq 'all') {
458 0 for my $item (@config_items) {
459 0 ▶ my $default = $config->{ $item->[0] } // $config->{ $fallback_config{ $item->[0] } // '' };
Condition0%0/5
$$config{$item->[0]} // $$config{$fallback_config{$item->[0]} // ""}
l!l&&r!l&&!r
000
$fallback_config{$item->[0]} // ""
l!l
00
MC/DC0%0/2
$$config{$item->[0]} // $$config{$fallback_config{$item->[0]} // ""}
$$config{$item->[0]} $$config{$fallback_config{$item->[0]} // ""}
MC/DC0%0/1
$fallback_config{$item->[0]} // ""
$fallback_config{$item->[0]}
Truth table0%0/3
A // B
A= $$config{$item->[0]}B= $$config{$fallback_config{$item->[0]} // ""}
ABresult
1X1
011
000
Truth table0%0/2
A
A= $fallback_config{$item->[0]}
Aresult
11
00
460 0 ask($config, $item, $default);
461 }
462 0 delete $config->{$_} for @delete_config;
463 0 write_json($config_file, $config);
464 }
465 elsif ($mode eq 'get') {
466 0 my ($key, $value) = @arguments;
467 0 my ($item) = grep { $_->[0] eq $key } @config_items;
468 0 ▶ die "No such known key $key" if not $item;
Branch: 1 branch
BranchTrueFalseTotal
unless $item 0 0 0
469 0 my (undef, $description, $type, $default) = @{$item};
470 0 say show_item($config, $key, $type);
471 }
472 elsif ($mode eq 'set') {
473 0 my ($key, $value) = @arguments;
474 0 my $item = grep { $_->[0] eq lc $key } @config_items;
475 0 ▶ die "No such known key $key" if not $item;
Branch: 1 branch
BranchTrueFalseTotal
unless $item 0 0 0
476 0 ▶ if ($item->[2] eq 'yn') {
Branch: 1 branch
BranchTrueFalseTotal
if ($item->[2] eq 'yn') { } 0 0 0
477 0 ▶ $config->{$key} = $boolean{$value} // die "Unknown boolean value '$value'\n";
Condition0%0/2
$boolean{$value} // die("Unknown boolean value '${value}'\n")
l!l
00
MC/DC0%0/1
$boolean{$value} // die("Unknown boolean value '${value}'\n")
$boolean{$value}
Truth table0%0/2
A
A= $boolean{$value}
Aresult
11
00
478 } else {
479 0 $config->{$key} = $value;
480 }
481 0 write_json($config_file, $config);
482 }
483 elsif ($mode eq 'list') {
484 0 for my $item (@config_items) {
485 0 my ($key, $description, $type, $default) = @{$item};
486 0 say "$key: " . show_item($config, $key, $type);
487 }
488 }
489 elsif ($mode eq 'reset') {
490 0 return not unlink $config_file;
491 }
492 0 return 0;
493 },
494 0 ▶ config => sub {
Subroutine __ANON__: not called CC=24 SCAR=64.0
495 0 my @arguments = @_;
496 0 my $settings = get_settings;
497 0 my $config = get_config;
498  
499 0 ▶ my $mode = @arguments ? shift @arguments : 'upgrade';
Branch: 1 branch
BranchTrueFalseTotal
@arguments ? : 0 0 0
500  
501 0 my @items = grep { $_->[2] ne 'open' } @config_items;
502 0 ▶ if ($mode eq 'upgrade') {
Branch: 7 branches
BranchTrueFalseTotal
if ($mode eq 'upgrade') { } 0 0 0
elsif ($mode eq 'all') { } 0 0 0
elsif ($mode eq 'copy') { } 0 0 0
elsif ($mode eq 'get') { } 0 0 0
elsif ($mode eq 'set') { } 0 0 0
elsif ($mode eq 'list') { } 0 0 0
elsif ($mode eq 'reset') { } 0 0 0
503 0 for my $item (@items) {
504 0 ▶ next if defined $config->{ $item->[0] };
Branch: 1 branch
BranchTrueFalseTotal
if defined $$config{$item->[0]} 0 0 0
505 0 ▶ my $default = $config->{ $fallback_config{ $item->[0] } // '' };
Condition0%0/2
$fallback_config{$item->[0]} // ""
l!l
00
MC/DC0%0/1
$fallback_config{$item->[0]} // ""
$fallback_config{$item->[0]}
Truth table0%0/2
A
A= $fallback_config{$item->[0]}
Aresult
11
00
506 0 ask($config, $item, $default);
507 }
508 0 delete $config->{$_} for @delete_config;
509 0 write_json($config_file, $config);
510 }
511 elsif ($mode eq 'all') {
512 0 for my $item (@items) {
513 0 ▶ my $default = $config->{ $item->[0] } // $config->{ $fallback_config{ $item->[0] } // '' } // $settings->{ $item->[0] };
Condition0%0/8
($$config{$item->[0]} // $$config{$fallback_config{$item->[0]} // ""}) // $$settings{$item->[0]}
l!l&&r!l&&!r
000
$$config{$item->[0]} // $$config{$fallback_config{$item->[0]} // ""}
l!l&&r!l&&!r
000
$fallback_config{$item->[0]} // ""
l!l
00
MC/DC0%0/3
($$config{$item->[0]} // $$config{$fallback_config{$item->[0]} // ""}) // $$settings{$item->[0]}
$$config{$item->[0]} $$config{$fallback_config{$item->[0]} // ""} $$settings{$item->[0]}
MC/DC0%0/1
$fallback_config{$item->[0]} // ""
$fallback_config{$item->[0]}
Truth table0%0/4
A // B // C
A= $$config{$item->[0]}B= $$config{$fallback_config{$item->[0]} // ""}C= $$settings{$item->[0]}
ABCresult
1XX1
01X1
0011
0000
Truth table0%0/2
A
A= $fallback_config{$item->[0]}
Aresult
11
00
514 0 ask($config, $item, $default);
515 }
516 0 delete $config->{$_} for @delete_config;
517 0 write_json($config_file, $config);
518 }
519 elsif ($mode eq 'copy') {
520 0 for my $item (@items) {
521 0 my ($key) = @{$item};
522 0 ▶ $config->{$key} = $settings->{$key} if exists $settings->{$key};
Branch: 1 branch
BranchTrueFalseTotal
if exists $settings->{$key} 0 0 0
523 }
524 0 write_json($config_file, $config);
525 }
526 elsif ($mode eq 'get') {
527 0 my ($key, $value) = @arguments;
528 0 my ($item) = grep { $_->[0] eq $key } @config_items;
529 0 ▶ die "No such known key $key" if not $item;
Branch: 1 branch
BranchTrueFalseTotal
unless $item 0 0 0
530 0 my (undef, $description, $type, $default) = @{$item};
531 0 say show_item($config, $key, $type);
532 }
533 elsif ($mode eq 'set') {
534 0 my ($key, $value) = @arguments;
535 0 my $item = grep { $_->[0] eq lc $key } @config_items;
536 0 ▶ die "No such known key $key" if not $item;
Branch: 1 branch
BranchTrueFalseTotal
unless $item 0 0 0
537 0 ▶ $config->{$key} = $boolean{$value} // die "Unknown boolean value '$value'\n";
Condition0%0/2
$boolean{$value} // die("Unknown boolean value '${value}'\n")
l!l
00
MC/DC0%0/1
$boolean{$value} // die("Unknown boolean value '${value}'\n")
$boolean{$value}
Truth table0%0/2
A
A= $boolean{$value}
Aresult
11
00
538 0 write_json($config_file, $config);
539 }
540 elsif ($mode eq 'list') {
541 0 for my $item (@items) {
542 0 my ($key, $description, $type, $default) = @{$item};
543 0 say "$key: " . show_item($config, $key, $type);
544 }
545 }
546 elsif ($mode eq 'reset') {
547 0 return not unlink $config_file;
548 }
549 0 return 0;
550 },
551 0 ▶ mint => sub {
Subroutine __ANON__: not called CC=13 SCAR=52.0
552 0 my @arguments = @_;
553  
554 0 my $settings = get_settings(\%default_settings);
555  
556 0 ▶ my $distname = decode_utf8(shift @arguments // die "No distribution name given\n") =~ s/::/-/gr;
Condition0%0/2
shift @arguments // die("No distribution name given\n")
l!l
00
MC/DC0%0/1
shift @arguments // die("No distribution name given\n")
shift @arguments
Truth table0%0/2
A
A= shift @arguments
Aresult
11
00
557  
558 my %args = (
559 author => $settings->{author},
560 email => $settings->{email},
561 license => $settings->{license},
562 version => '0.000',
563 dirname => $distname,
564 abstract => 'INSERT YOUR ABSTRACT HERE',
565 init_git => $settings->{auto_git},
566 0 );
567 0 my %config;
568 0 my @options = qw/version=s abstract=s dirname=s init_git|init-git/;
569 0 for my $config_item (@config_items) {
570 0 my $entry = $config_item->[0] =~ s{^(\w+_\w+)\K$}{ '|' . $1 =~ tr/_/-/r }er;
571 0 ▶ push @options, $entry . ($config_item->[2] eq 'yn' ? '!' : '=s');
Branch: 1 branch
BranchTrueFalseTotal
$config_item->[2] eq 'yn' ? : 0 0 0
572 }
573 0 ▶ GetOptionsFromArray(\@arguments, \%args, @options) or return 2;
Branch: 1 branch
BranchTrueFalseTotal
&GetOptionsFromArray(\@arguments, \%args, @options) or return 2 0 0 0
574 0 for my $item (@config_items) {
575 0 my ($key, $description, $type, $default) = @{$item};
576 0 ▶ if ($type eq 'open') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq 'open') { } 0 0 0
577 0 ▶ $args{$key} //= prompt($description, $default);
Condition0%0/3
$args{$key} //= prompt($description, $default)
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{$key} //= prompt($description, $default)
$args{$key} prompt($description, $default)
Truth table0%0/3
A //= B
A= $args{$key}B= prompt($description, $default)
ABresult
1X1
011
000
578 }
579 else {
580 0 ▶ $config{$key} = $args{$key} // $settings->{$key} // prompt_yn($description, $default);
Condition0%0/6
($args{$key} // $settings->{$key}) // prompt_yn($description, $default)
l!l&&r!l&&!r
000
$args{$key} // $settings->{$key}
l!l&&r!l&&!r
000
MC/DC0%0/3
($args{$key} // $settings->{$key}) // prompt_yn($description, $default)
$args{$key} $settings->{$key} prompt_yn($description, $default)
Truth table0%0/4
A // B // C
A= $args{$key}B= $settings->{$key}C= prompt_yn($description, $default)
ABCresult
1XX1
01X1
0011
0000
581 }
582 }
583  
584 0 my $license = create_license_for(delete $args{license}, $args{author});
585  
586 0 ▶ die "Directory $args{dirname} already exists\n" if -e $args{dirname};
Branch: 1 branch
BranchTrueFalseTotal
if -e $args{"dirname"} 0 0 0
587 0 mkdir $args{dirname};
588 0 chdir $args{dirname};
589 0 $args{module_name} = $distname =~ s/-/::/gr;
590  
591 0 my $module_file = write_module(%args, notice => $license->notice);
592 0 write_changes(%args, distname => $distname);
593 0 write_maniskip($distname);
594 0 write_json('dist.json', \%config);
595 0 mkdir 't';
596  
597 0 ▶ write_json('metamerge.json', { name => $distname }) if $distname ne $args{dirname};
Branch: 1 branch
BranchTrueFalseTotal
if $distname ne $args{"dirname"} 0 0 0
598  
599 0 my @regenerate_files = regenerate_files(\%config);
600 0 regenerate(\@regenerate_files, \%args, scan => $config{auto_scan});
601  
602 0 ▶ if ($args{init_git}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"init_git"}) 0 0 0
603 0 my $ignore = join "\n", qw/*.bak *.swp *.swo *.tdy *.tar.gz/, "$distname-*", '';
604 0 write_text('.gitignore', $ignore);
605  
606 0 require Git::Wrapper;
607 0 my $git = Git::Wrapper->new('.');
608 0 $git->init;
609 0 $git->add(@regenerate_files, 'Changes', 'MANIFEST.SKIP', 'dist.json', '.gitignore', $module_file, grep -e, 'metamerge.json');
610 0 $git->commit({ message => 'Initial commit' });
611 }
612  
613 0 return 0;
614 },
615 0 ▶ version => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
616 0 say $VERSION;
617 },
618 1 );
619  
620 0 ▶sub modulebuildtiny {
Subroutine modulebuildtiny: not called CC=3 SCAR=24.8
Pod documented
621 0 my ($action, @arguments) = @_;
622 0 ▶ die "No action given\n" unless defined $action;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $action 0 0 0
623 0 my $call = $actions{$action};
624 0 ▶ die "No such action '$action' known\n" if not $call;
Branch: 1 branch
BranchTrueFalseTotal
unless $call 0 0 0
625 0 return $call->(@arguments);
626 }
627  
628 1 1;
629  
630 =head1 NAME
631  
632 App::ModuleBuildTiny - A standalone authoring tool for Module::Build::Tiny and Dist::Build
633  
634 =head1 DESCRIPTION
635  
636 App::ModuleBuildTiny contains the implementation of the L<mbtiny> tool.
637  
638 =head1 FUNCTIONS
639  
640 =over 4
641  
642 =item * modulebuildtiny($action, @arguments)
643  
644 This function runs a modulebuildtiny command. It expects at least one argument: the action. It may receive additional ARGV style options dependent on the command.
645  
646 The actions are documented in the L<mbtiny> documentation.
647  
648 =back
649  
650 =head1 SEE ALSO
651  
652 =head2 Similar programs
653  
654 =over 4
655  
656 =item * L<Dist::Zilla|Dist::Zilla>
657  
658 An extremely powerful but somewhat heavy authoring tool.
659  
660 =item * L<Minilla|Minilla>
661  
662 A more minimalistic than Dist::Zilla but still somewhat customizable authoring tool.
663  
664 =back
665  
666 =head1 AUTHOR
667  
668 Leon Timmermans <leont@cpan.org>
669  
670 =head1 COPYRIGHT AND LICENSE
671  
672 This software is copyright (c) 2011 by Leon Timmermans.
673  
674 This is free software; you can redistribute it and/or modify it under
675 the same terms as the Perl 5 programming language system itself.
676  
677 =cut
678  
679 __DATA__
« ModuleBuildTiny/Dist.pm ↑ Summary