PluginBundle/Author/VDB.pm

filter: Statementstmt 83.8% 104 / 124 Branchbran 58.7% 27 / 46 Conditioncond 62.5% 15 / 24 MC/DCmcdc 30.7% 4 / 13 Subroutinesub 93.1% 27 / 29 Podpod 50.0% 1 / 2 totaltotal 74.7% 178 / 238 CC 40 SCAR 21.9
CC
40
Cov
75%
prereqs
30.0
configure
18.8
file
12.0
CRAP 8.9
« Role/Author/VDB/ProgramRunner.pm ↑ Summary Plugin/Author/VDB/Hg/Status.pm »
1 # ---------------------------------------------------------------------- copyright and license ---
2 #
3 # file: lib/Dist/Zilla/PluginBundle/Author/VDB.pm
4 #
5 # Copyright © 2015 Van de Bugger
6 #
7 # This file is part of perl-Dist-Zilla-PluginBundle-Author-VDB.
8 #
9 # perl-Dist-Zilla-PluginBundle-Author-VDB is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by the Free Software
11 # Foundation, either version 3 of the License, or (at your option) any later version.
12 #
13 # perl-Dist-Zilla-PluginBundle-Author-VDB is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
15 # PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License along with
18 # perl-Dist-Zilla-PluginBundle-Author-VDB. If not, see <http://www.gnu.org/licenses/>.
19 #
20 # ---------------------------------------------------------------------- copyright and license ---
21  
22 #pod =head1 DESCRIPTION
23 #pod
24 #pod It is unlikely that someone else will want to use it, so I will not bother with documenting it, at
25 #pod least for now.
26 #pod
27 #pod =for Pod::Coverage configure
28 #pod
29 #pod =cut
30  
31 package Dist::Zilla::PluginBundle::Author::VDB;
32  
33 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 2 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 2 ▶use version 0.77;
Subroutine BEGIN: called CC=1 SCAR=0.0
36  
37 # PODNAME: Dist::Zilla::PluginBundle::Author::VDB
38 # ABSTRACT: VDB's plugin bundle
39 2 our $VERSION = 'v0.11.3'; # VERSION
40  
41 2 with 'Dist::Zilla::Role::PluginBundle::Easy';
42  
43 # These modules used by the bundle directly.
44 2 ▶use Carp qw{ croak };
Subroutine BEGIN: called CC=1 SCAR=0.0
45 2 ▶use Dist::Zilla::File::InMemory;
Subroutine BEGIN: called CC=1 SCAR=0.0
46 2 ▶use Dist::Zilla::File::OnDisk;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 2 ▶use Path::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
48 2 ▶use Sub::Exporter::ForMethods qw{ method_installer };
Subroutine BEGIN: called CC=1 SCAR=0.0
49 2 ▶use Data::Section { installer => method_installer }, -setup;
Subroutine BEGIN: called CC=1 SCAR=0.0
50  
51 # These modules are used by hooks. Require all the modules explicitly now to avoid unexpected
52 # failures in the middle of build or release.
53 2 ▶use App::Prove ();
Subroutine BEGIN: called CC=1 SCAR=0.0
54 2 ▶use File::pushd ();
Subroutine BEGIN: called CC=1 SCAR=0.0
55 2 ▶use IPC::Run3 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
56 2 ▶use IPC::System::Simple ();
Subroutine BEGIN: called CC=1 SCAR=0.0
57 2 ▶use Path::Tiny 0.070 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
58  
59 # --------------------------------------------------------------------------------------------------
60  
61 #pod =option minimum_perl
62 #pod
63 #pod Desired minimum Perl version. Extra test F<minimum-version.t> fails if actually required Perl
64 #pod version is greater than desired.
65 #pod
66 #pod Optional, default value C<5.006>.
67 #pod
68 #pod =cut
69  
70 has minimum_perl => (
71 is => 'ro',
72 isa => 'Str',
73 lazy => 1,
74 7 ▶ default => sub {
Subroutine __ANON__: called CC=2 SCAR=7.2
75 7 my ( $self ) = @_;
76 7 ▶ return $self->payload->{ minimum_perl } // '5.006';
Condition50%1/2
$self->payload->{"minimum_perl"} // "5.006"
l!l
07
MC/DC0%0/1
$self->payload->{"minimum_perl"} // "5.006"
$self->payload->{"minimum_perl"}
Truth table50%1/2
A
A= $self->payload->{"minimum_perl"}
Aresult
11
00
77 },
78 2 );
79  
80 # --------------------------------------------------------------------------------------------------
81  
82 #pod =option copying
83 #pod
84 #pod Name of POD file to generate distribution F<COPYING> text file. Empty value disables generation
85 #pod F<COPYING> file.
86 #pod
87 #pod C<Str>, optional, default value C<doc/copying.pod>.
88 #pod
89 #pod =cut
90  
91 has copying => (
92 is => 'ro',
93 isa => 'Str',
94 lazy => 1,
95 7 ▶ default => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
96 7 my ( $self ) = @_;
97 7 ▶ return $self->payload->{ copying } // 'doc/copying.pod';
Condition100%2/2
$self->payload->{"copying"} // "doc/copying.pod"
l!l
25
MC/DC100%1/1
$self->payload->{"copying"} // "doc/copying.pod"
$self->payload->{"copying"}
Truth table100%2/2
A
A= $self->payload->{"copying"}
Aresult
11
00
98 },
99 2 );
100  
101 # --------------------------------------------------------------------------------------------------
102  
103 #pod =option readme
104 #pod
105 #pod Names of POD files to generate distribution F<README> text file. This is a multi-value option.
106 #pod Empty values are ignored. Empty list disables generating F<README> file.
107 #pod
108 #pod C<ArrayRef[Str]>, optional, default value C<[ 'doc/what.pod', 'doc/why.pod', 'doc/naming.pod', 'doc/forms.pod', 'doc/source.pod', 'doc/distribution.pod', 'doc/installing.pod', 'doc/hacking.pod', 'doc/documentation.pod', 'doc/feedback.pod', 'doc/glossary.pod' ]>.
109 #pod
110 #pod =cut
111  
112 has readme => (
113 is => 'ro',
114 isa => 'Maybe[ArrayRef[Str]]',
115 lazy => 1,
116 7 ▶ default => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
117 7 my ( $self ) = @_;
118 7 ▶ my $readme = $self->payload->{ readme } // [ 'doc/what.pod', 'doc/why.pod', 'doc/naming.pod', 'doc/forms.pod', 'doc/source.pod', 'doc/distribution.pod', 'doc/installing.pod', 'doc/hacking.pod', 'doc/documentation.pod', 'doc/feedback.pod', 'doc/glossary.pod' ];
Condition100%2/2
$self->payload->{"readme"} // ["doc/what.pod", "doc/why.pod", "doc/naming.pod", "doc/forms.pod", "doc/source.pod", "doc/distribution.pod", "doc/installing.pod", "doc/hacking.pod", "doc/documentation.pod", "doc/feedback.pod", "doc/glossary.pod"]
l!l
25
MC/DC100%1/1
$self->payload->{"readme"} // ["doc/what.pod", "doc/why.pod", "doc/naming.pod", "doc/forms.pod", "doc/source.pod", "doc/distribution.pod", "doc/installing.pod", "doc/hacking.pod", "doc/documentation.pod", "doc/feedback.pod", "doc/glossary.pod"]
$self->payload->{"readme"}
Truth table100%2/2
A
A= $self->payload->{"readme"}
Aresult
11
00
119 7 $readme = [ grep( { $_ ne '' } @$readme ) ]; # Ignore empty items.
120 7 ▶ if ( not @$readme ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$readme) 1 6 7
121 1 $readme = undef;
122 };
123 7 return $readme;
124 },
125 2 );
126  
127 # --------------------------------------------------------------------------------------------------
128  
129 #pod =option local_release
130 #pod
131 #pod If true, release will be a local one, i. e. no external operations will be done: C<UploadToCPAN>
132 #pod and C<hg push> will be skipped, <hg tag> will create a local tag.
133 #pod
134 #pod Option can be set trough F<dist.ini> file or with C<DZIL_LOCAL_RELEASE> environment variable.
135 #pod
136 #pod Optional, default value is 0.
137 #pod
138 #pod =cut
139  
140 has local_release => (
141 is => 'ro',
142 isa => 'Bool',
143 lazy => 1,
144 7 ▶ default => sub {
Subroutine __ANON__: called CC=2 SCAR=8.1
145 7 my ( $self ) = @_;
146 7 ▶ return $self->payload->{ local_release } // $ENV{ DZIL_LOCAL_RELEASE };
Condition33%1/3
$self->payload->{"local_release"} // $ENV{"DZIL_LOCAL_RELEASE"}
l!l&&r!l&&!r
007
MC/DC0%0/2
$self->payload->{"local_release"} // $ENV{"DZIL_LOCAL_RELEASE"}
$self->payload->{"local_release"} $ENV{"DZIL_LOCAL_RELEASE"}
Truth table33%1/3
A // B
A= $self->payload->{"local_release"}B= $ENV{"DZIL_LOCAL_RELEASE"}
ABresult
1X1
011
000
147 },
148 2 );
149  
150 # --------------------------------------------------------------------------------------------------
151  
152 #pod =option archive
153 #pod
154 #pod Directory to archive files to. If empty, release will not be archived. If such directory does not
155 #pod exist, it will be created before release.
156 #pod
157 #pod Optional, default value C<".releases">.
158 #pod
159 #pod =cut
160  
161 has archive => (
162 is => 'ro',
163 isa => 'Str',
164 lazy => 1,
165 7 ▶ default => sub {
Subroutine __ANON__: called CC=2 SCAR=7.2
166 7 my ( $self ) = @_;
167 7 ▶ return $self->payload->{ archive } // ".releases";
Condition50%1/2
$self->payload->{"archive"} // ".releases"
l!l
07
MC/DC0%0/1
$self->payload->{"archive"} // ".releases"
$self->payload->{"archive"}
Truth table50%1/2
A
A= $self->payload->{"archive"}
Aresult
11
00
168 },
169 2 );
170  
171 # --------------------------------------------------------------------------------------------------
172  
173 #pod =option templates
174 #pod
175 #pod This option will be passed to C<Templates> plugin. If you no not want C<Templates> to process
176 #pod files, specify C<:NoFiles>. This is multi-value option (i. e. may be specified several times).
177 #pod
178 #pod Optional, default value C<[ ':InstallModules' ]>.
179 #pod
180 #pod =cut
181  
182 has templates => (
183 is => 'ro',
184 isa => 'Maybe[ArrayRef[Str]]',
185 lazy => 1,
186 7 ▶ default => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
187 7 my ( $self ) = @_;
188 7 ▶ my $templates = $self->payload->{ templates } // [ ':InstallModules' ];
Condition100%2/2
$self->payload->{"templates"} // [":InstallModules"]
l!l
25
MC/DC100%1/1
$self->payload->{"templates"} // [":InstallModules"]
$self->payload->{"templates"}
Truth table100%2/2
A
A= $self->payload->{"templates"}
Aresult
11
00
189 7 $templates = [ grep( { $_ ne '' } @$templates ) ]; # Ignore empty items.
190 7 ▶ if ( not @$templates ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$templates) 1 6 7
191 1 $templates = undef;
192 };
193 7 return $templates;
194 },
195 2 );
196  
197 # --------------------------------------------------------------------------------------------------
198  
199 #pod =option unwanted_module
200 #pod
201 #pod =option unwanted_modules
202 #pod
203 #pod C<Data::Printer> is a great module for debugging. But sometimes I forget to remove debug statements
204 #pod from the code before release. This option helps to check it.
205 #pod
206 #pod If any of enlisted modules appears in the distribution dependencies, release will be aborted.
207 #pod
208 #pod Default value C<[ qw{ DDP Data::Printer } ]>.
209 #pod
210 #pod =cut
211  
212 has unwanted_modules => (
213 isa => 'ArrayRef[Str]',
214 is => 'ro',
215 lazy => 1,
216 7 ▶ default => sub {
Subroutine __ANON__: called CC=5 SCAR=20.9
217 7 my ( $self ) = @_;
218 7 my $p = $self->payload;
219 7 my $u1 = $p->{ unwanted_module };
220 7 my $u2 = $p->{ unwanted_modules };
221 7 ▶ return $u1 || $u2 ? [ $u1 ? @$u1 : (), $u2 ? @$u2 : () ] : [ qw{ DDP Data::Printer } ];
Branch: 3 branches
BranchTrueFalseTotal
$u1 || $u2 ? : 0 7 7
$u1 ? : 0 0 0
$u2 ? : 0 0 0
Condition33%1/3
$u1 or $u2
l!l&&r!l&&!r
007
MC/DC0%0/2
$u1 or $u2
$u1 $u2
Truth table33%1/3
A or B
A= $u1B= $u2
ABresult
1X1
011
000
222 },
223 2 );
224  
225 # --------------------------------------------------------------------------------------------------
226  
227 #pod =option spellchecker
228 #pod
229 #pod Command to run spellchecker. Spellchecker command is expected to read text from stdin, and print to
230 #pod stdout misspelled words. If empty, spellchecking will be skipped. This option affects
231 #pod C<Test::PodSpelling> plugin and internally implemented checking the F<Changes> file.
232 #pod
233 #pod Optional, default value C<aspell list -l en -p ./xt/aspell-en.pws>.
234 #pod
235 #pod =cut
236  
237 has spellchecker => (
238 is => 'ro',
239 isa => 'Str',
240 lazy => 1,
241 7 ▶ default => sub {
Subroutine __ANON__: called CC=2 SCAR=7.2
242 7 my ( $self ) = @_;
243 7 ▶ return $self->payload->{ spellchecker } // 'aspell list -l en -p ./xt/aspell-en.pws';
Condition50%1/2
$self->payload->{"spellchecker"} // "aspell list -l en -p ./xt/aspell-en.pws"
l!l
07
MC/DC0%0/1
$self->payload->{"spellchecker"} // "aspell list -l en -p ./xt/aspell-en.pws"
$self->payload->{"spellchecker"}
Truth table50%1/2
A
A= $self->payload->{"spellchecker"}
Aresult
11
00
244 # Leading dot (in `./xt/aspell.en.pws`) is important! Whitout the dot `aspell`
245 # fails to find the dictionary.
246 },
247 2 );
248  
249 # --------------------------------------------------------------------------------------------------
250  
251 #pod =option repository
252 #pod
253 #pod Mercurial repository to push changes after release to. Option may be specified multiple times to
254 #pod push changes into several repositories. By default changes are pushed to one repository C<default>.
255 #pod
256 #pod =cut
257  
258 has repository => (
259 isa => 'ArrayRef[Str]',
260 is => 'ro',
261 lazy => 1,
262 7 ▶ default => sub {
Subroutine __ANON__: called CC=2 SCAR=7.2
263 7 my ( $self ) = @_;
264 7 ▶ return $self->payload->{ repository } // [ 'default' ];
Condition50%1/2
$self->payload->{"repository"} // ["default"]
l!l
07
MC/DC0%0/1
$self->payload->{"repository"} // ["default"]
$self->payload->{"repository"}
Truth table50%1/2
A
A= $self->payload->{"repository"}
Aresult
11
00
265 },
266 2 );
267  
268 # --------------------------------------------------------------------------------------------------
269  
270 #pod =option installer
271 #pod
272 #pod Installer plugin.
273 #pod
274 #pod Default value C<'ModuleBuildTiny'>.
275 #pod
276 #pod =cut
277  
278 has installer => (
279 isa => 'Str',
280 is => 'ro',
281 lazy => 1,
282 7 ▶ default => sub {
Subroutine __ANON__: called CC=2 SCAR=7.2
283 7 my ( $self ) = @_;
284 7 ▶ return $self->payload->{ installer } // 'ModuleBuildTiny';
Condition50%1/2
$self->payload->{"installer"} // "ModuleBuildTiny"
l!l
07
MC/DC0%0/1
$self->payload->{"installer"} // "ModuleBuildTiny"
$self->payload->{"installer"}
Truth table50%1/2
A
A= $self->payload->{"installer"}
Aresult
11
00
285 },
286 2 );
287  
288 # --------------------------------------------------------------------------------------------------
289  
290 #pod =method mvp_multivalue_args
291 #pod
292 #pod =cut
293  
294 7 ▶sub mvp_multivalue_args {
Subroutine mvp_multivalue_args: called CC=1 SCAR=0.0
Pod documented
295 7 return qw{ templates unwanted_module unwanted_modules readme repository };
296 };
297  
298 # --------------------------------------------------------------------------------------------------
299  
300 #pod =method _quote
301 #pod
302 #pod Convert an attribute to a form suitable for using in source. C<Str> attribute is converted into a
303 #pod string literal, C<ArrayRef> attribute is converted to a list of string literals.
304 #pod
305 #pod =cut
306  
307 19 ▶sub _quote {
Subroutine _quote: called CC=4 SCAR=13.9
308 19 my ( $self, @args ) = @_;
309 19 my @names;
310 19 for my $arg ( @args ) {
311 19 ▶ for ( ref( $arg ) eq 'ARRAY' ? @$arg : $arg ) {
Branch: 1 branch
BranchTrueFalseTotal
ref $arg eq 'ARRAY' ? : 13 6 19
312 77 my $name = $_;
313 77 $name =~ s{([\\'])}{\$1}gx;
314 77 push( @names, "'$name'" );
315 };
316 };
317 19 return join( ', ', @names );
318 };
319  
320 # --------------------------------------------------------------------------------------------------
321  
322 # Helper func: Iterate through distribution prerequisities.
323  
324 0 ▶sub MY::prereqs($$) { ## no critic ( ProhibitSubroutinePrototypes )
Subroutine prereqs: not called CC=5 SCAR=34.0
325 0 my ( $plugin, $callback ) = @_;
326 0 my $prereqs = $plugin->zilla->prereqs->cpan_meta_prereqs;
327 0 for my $phase ( $prereqs->__legal_phases ) {
328 0 for my $type ( $prereqs->__legal_types ) {
329 0 ▶ my $reqs = $prereqs->requirements_for( $phase, $type ) or next;
Branch: 1 branch
BranchTrueFalseTotal
my $reqs = $prereqs->requirements_for($phase, $type) or next 0 0 0
330 0 for my $module ( keys( %{ $reqs->{ requirements } } ) ) {
331 0 $callback->( $plugin, $module, $phase, $type, $reqs );
332 };
333 };
334 };
335 0 return;
336 };
337  
338 0 ▶sub MY::file {
Subroutine file: not called CC=3 SCAR=24.8
339 0 my ( $plugin, $name ) = @_;
340 0 our $Self; ## no critic ( ProhibitPackageVars )
341 0 my $data = $Self->merged_section_data;
342 0 my $root = path( $plugin->zilla->root );
343 0 my $file;
344 0 ▶ if ( $root->child( $name )->exists ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($root->child($name)->exists) { } 0 0 0
elsif ($data->{$name}) { } 0 0 0
345 0 $file = Dist::Zilla::File::OnDisk->new( {
346 name => $name,
347 } );
348 } elsif ( $data->{ $name } ) {
349 $file = Dist::Zilla::File::InMemory->new( {
350 name => $name,
351 0 content => ${ $data->{ $name } },
352 } );
353 } else {
354 0 croak "$name: file not found";
355 };
356 0 return $file;
357 };
358  
359 # --------------------------------------------------------------------------------------------------
360  
361 7 ▶sub configure {
Subroutine configure: called CC=16 SCAR=29.3
Pod undocumented
362  
363 7 my ( $self ) = @_;
364 7 our $Self = $self; ## no critic ( ProhibitPackageVars )
365 7 my $name = $self->name;
366  
367 $self->add_plugins(
368  
369 [ 'Hook' => 'prologue' => {
370 # DOES NOT WORK because plugin name will be '$name/prologue'.
371 'hook' => [ q{
372 use autodie ':all';
373 use IPC::System::Simple qw{ capture };
374 use Path::Tiny;
375 } ],
376 } ],
377  
378 [ 'Author::VDB::Version::Read', ],
379  
380 [ 'Hook::Init' => 'init stuff' => {
381 'hook' => [ q[
382 $dist->license->{ program } = 'perl-' . $dist->name;
383 { pack] . q[age MY; # Hide declaration from `new-version.t`.
384 our $name = $dist->name;
385 ( our $package = $name ) =~ s{-}{::}g;
386 our $version = $dist->version;
387 our $Abstract = $dist->abstract;
388 our $abstract = lcfirst( $Abstract );
389 our $author = $dist->authors->[ -1 ];
390 our $metacpan = "https://metacpan.org/release/$name";
391 our $cpan_rt_mailto = "mailto:bug-$name\@rt.cpan.org";
392 our $cpan_rt_browse = "https://rt.cpan.org/Public/Dist/Display.html?Name=$name";
393 our $cpan_rt_report = "https://rt.cpan.org/Public/Bug/Report.html?Queue=$name";
394 our $repo_type ||= "hg";
395 our $repo_host ||= "fedorapeople.org";
396 our $repo_url ||= "https://vandebugger.$repo_host/hg/perl-$name";
397 our $repo_web ||= undef;
398 our $repo_clone = "$repo_type clone $repo_url" .
399 ( $repo_url =~ m{/\Qperl-$name\E\z} ? '' : " \\\\\\n perl-$name" );
400 our $bundle = $Dist::Zilla::PluginBundle::Author::VDB::Self;
401 };
402 $ENV{ 'TEST_FIX' . 'ME_FORMAT' } = 'perl'; # Hide keyword from `fixme.t`.
403 ] ],
404 } ],
405  
406 #
407 # Files to include
408 #
409  
410 [ 'Manifest::Read' ], # REQUIRED VERSION: v0.5.0
411 # Colon-prefixed file finders (e. g. 'Manifest::Read/:AllFiles') are used.
412  
413 #
414 # Generated files
415 #
416  
417 $self->copying ne '' ? (
418 [ 'GenerateFile' => 'COPYING' => {
419 'filename' => 'COPYING',
420 'content' => [
421 q[{] . q[{],
422 q[ include( MY::file( $plugin, ] . $self->_quote( $self->copying ) . q[ ) ) ],
423 q[ ->fill_in ],
424 q[ ->pod2text( width => 80, indent => 0, loose => 1, quotes => 'none' ) ],
425 q[ ->chomp; ],
426 # Resulting file may have one or two empty lines at the end, it affects
427 # testing. Let's try to chomp empty lines to avoid it.
428 q[}] . q[}], # One newline will be added there.
429 ],
430 } ],
431 ) : (
432 ),
433  
434 $self->readme ? (
435 [ 'GenerateFile' => 'README' => {
436 'filename' => 'README',
437 'content' => [
438 q[{] . q[{],
439 q[join( ],
440 q[ "\n\n", ],
441 q[ map( ],
442 q[ { ],
443 q[ include( MY::file( $plugin, $_ ) ) ],
444 q[ ->fill_in ],
445 q[ ->pod2text( width => 80, indent => 0, loose => 1, quotes => 'none' ) ],
446 q[ ->chomp ],
447 q[ } ],
448 q[ ] . $self->_quote( $self->readme ) . q[ ],
449 q[ ) ],
450 q[); ],
451 q[}] . q[}], # One newline will be added there.
452 ],
453 } ],
454 ) : (
455 ),
456  
457 [ 'Manifest::Write' => { # REQUIRED VERSION: v0.9.7
458 # `Manifest::Write` v0.9.0 strictly requires plugin names, not monikers.
459 # `Manifest::Write` v0.9.6 provides `exclude_files` option.
460 # `Manifest::Write` v0.9.7 provides `manifest_skip` option and feature.
461 'source_provider' => [
462 "$name/Manifest::Read",
463 $self->copying ne '' ? "$name/COPYING" : (),
464 $self->readme ? "$name/README" : (),
465 ],
466 'metainfo_provider' => [
467 # Defaults are not suitable because they are just `MetaJSON` and `MetaYAML`.
468 "$name/Manifest::Write",
469 "$name/MetaJSON",
470 "$name/MetaYAML",
471 ],
472 'exclude_files' => [
473 ":ExtraTestFiles", # REQUIRE: Dist::Zilla 5.038
474 ],
475 } ],
476  
477 #
478 # File mungers
479 #
480  
481 [ 'Templates' => { # REQUIRED VERSION: v0.5.0 # for including `Dist::Zilla::File` objects.
482 'templates' => [
483 "$name/src doc",
484 7 ▶ @{ $self->templates // [] },
Branch: 14 branches
BranchTrueFalseTotal
$self->copying ne '' ? : 6 1 7
$self->readme ? : 6 1 7
$self->copying ne '' ? : 6 1 7
$self->readme ? : 6 1 7
$self->copying ne '' ? : 6 1 7
$self->readme ? : 6 1 7
$self->spellchecker ? : 7 0 7
$self->installer ? : 7 0 7
$self->archive ? : 7 0 7
$self->spellchecker ? : 7 0 7
$self->local_release ? : 0 7 7
$self->archive ? : 7 0 7
$self->local_release ? : 0 7 7
$self->local_release ? : 0 7 7
Condition100%2/2
$self->templates // []
l!l
61
MC/DC100%1/1
$self->templates // []
$self->templates
Truth table100%2/2
A
A= $self->templates
Aresult
11
00
485 ],
486 } ],
487  
488 [ 'OurPkgVersion' ],
489  
490 [ 'SurgicalPodWeaver' => {
491 'config_plugin' => '@Author::VDB', # REQUIRE: Pod::Weaver::PluginBundle::Author::VDB
492 'replacer' => 'replace_with_comment',
493 } ],
494  
495 [ 'FileFinder::ByName' => 'src doc' => {
496 # Plugin name will be `$name/doc`.
497 'file' => [
498 $self->copying ne '' ? ( 'COPYING' ) : (),
499 $self->readme ? ( 'README' ) : (),
500 ],
501 } ],
502  
503 #
504 # Update sources
505 #
506  
507 # Copy built doc files back to source directory.
508 [ 'Hook::AfterBuild' => 'update src doc' => {
509 'hook' => [ q{
510 use Path::Tiny;
511 my $files = $zilla->plugin_named( '} . $name . q{/src doc' )->find_files();
512 my $build = path( $arg->{ build_root } );
513 my $root = path( $dist->root );
514 for my $file ( @$files ) {
515 my $new_file = $build->child( $file->name );
516 my $old_file = $root->child( $file->name );
517 my $new_bulk = $new_file->slurp;
518 my $old_bulk = $old_file->exists ? $old_file->slurp : undef;
519 if ( not defined( $old_bulk ) or $new_bulk ne $old_bulk ) {
520 $self->log( [ 'updating %s', $file->name ] );
521 $old_file->append( { truncate => 1 }, $new_bulk );
522 # `append` is not atomic, but does not reset file mode.
523 };
524 };
525 } ],
526 } ],
527  
528 #
529 # Tests
530 #
531  
532 [ 'Test::DiagINC' ],
533  
534 # Files
535  
536 [ 'Test::Portability' ], # Checks filenames.
537  
538 [ 'Test::EOL' => {
539 'finder' => "$name/Manifest::Read/:AllFiles",
540 } ],
541  
542 [ 'Test::NoTabs' => {
543 'finder' => "$name/Manifest::Read/:AllFiles",
544 } ],
545  
546 [ 'MojibakeTests' ],
547  
548 # Code
549  
550 [ 'Test::Compile' => {
551 'fake_home' => 1,
552 } ],
553  
554 [ 'Test::Version' => { # All modules have version.
555 finder => "$name/Manifest::Read/:InstallModules",
556 # REQUIRE: Dist::Zilla::Plugin::Manifest::Read v0.4.0 # want `/:InstallModules`.
557 is_strict => 0, # Strict version test fails in trial releases.
558 } ],
559  
560 # I would like to set `Test::Version`'s `is_strict` option to `1`, but it will fail for
561 # trial releases. To avoid that let's do a trick: set `is_strict` to `1` only in case of
562 # non-trial release.
563 [ 'Hook::BeforeBuild' => 'hack Test::Version' => {
564 'hook' => [ q{
565 my $tv = $zilla->plugin_named( '} . $name . q{/Test::Version' );
566 $tv->{ is_strict } = $dist->is_trial ? '0' : '1';
567 } ],
568 } ],
569  
570 [ 'Test::NewVersion' ], # This is not a version already uploaded to CPAN.
571  
572 [ 'Test::MinimumVersion' => {
573 'max_target_perl' => $self->minimum_perl,
574 } ],
575  
576 [ 'Test::Fixme' ],
577  
578 [ 'Test::Perl::Critic' => {
579 'critic_config' => 'xt/perlcritic.ini',
580 # The test does not check tests. TODO: How to fix?
581 } ],
582  
583 # POD
584  
585 [ 'PodSyntaxTests' ], # `Dist-Zilla`-bundled test, uses `Test::Pod`.
586  
587 [ 'PodCoverageTests' ], # `Dist-Zilla`-bundled test, uses `Pod::Coverage::TrustPod`.
588  
589 $self->spellchecker ? (
590 [ 'Test::PodSpelling' => {
591 'spell_cmd' => $self->spellchecker,
592 } ],
593 ) : (
594 ),
595  
596 [ 'Test::Pod::LinkCheck' ],
597  
598 [ 'Test::Pod::No404s' ], # No dead URLs.
599  
600 [ 'Test::Synopsis' ],
601  
602 # Metadata
603  
604 [ 'MetaTests' ], # `Dist-Zilla`-bundled test, uses `Test::CPAN::Meta`, checks `META.yml`.
605  
606 [ 'Test::CPAN::Meta::JSON' ], # Uses `Test::CPAN::Meta::JSON`.
607  
608 [ 'Test::CPAN::Changes' ],
609 # Does not check that `Changes` has a record for current version, see
610 # <https://github.com/doherty/Dist-Zilla-Plugin-Test-CPAN-Changes/issues/6>.
611  
612 [ 'Test::DistManifest' ],
613  
614 # Overall
615  
616 [ 'Test::Kwalitee' ],
617  
618 #
619 # Metainfo
620 #
621  
622 [ 'MinimumPerl' ],
623  
624 [ 'AutoPrereqs' => {
625 'extra_scanners' => 'Hint', # REQUIRE: Perl::PrereqScanner::Scanner::Hint
626 } ],
627  
628 # `Prereqs::AuthorDeps` has a problem:
629 # <https://github.com/dagolden/Dist-Zilla-Plugin-Prereqs-AuthorDeps/issues/1>
630 # It adds local plugins (e. g. tools::GenerateHooks) to the dependencies,
631 # which obviously are not indexed on CPAN.
632 [ 'Prereqs::AuthorDeps' => {
633 #~ 'exclude' => [
634 #~ # Exclude option requires a list of specific files, while I want to ignore all
635 #~ # files in specific directory.
636 #~ ],
637 } ],
638  
639 # TODO: Remove when possible.
640 # This is a dirty hack. Remove it when `Prereqs::AuthorDeps` allows me to ignore all the
641 # modules from `tools/` directory. Meanwhile, find and remove all the dependencies on
642 # modules with `tools::` prefix.
643 [ 'Hook::PrereqSource' => 'tools' => {
644 'hook' => [ q{
645 MY::prereqs( $self, sub {
646 my ( $self, $module, $phase, $type, $reqs ) = @_;
647 if ( $module =~ m{^tools::} ) {
648 $self->log_debug( [
649 'found dependency on module %s (phase %s, type %s), deleting it',
650 $module, $phase, $type
651 ] );
652 delete( $reqs->{ requirements }->{ $module } );
653 };
654  
655 } );
656 } ],
657 } ],
658  
659 # `use autodie ':all';` implicitly requires `IPC::System::Simple` module, but this
660 # dependency is not detected by `AutoPrereqs`. If there is dependency on `autodie`, let
661 # us add dependency on `IPC::System::Simple`.
662 [ 'Hook::PrereqSource' => 'autodie' => {
663 'hook' => [ q{
664 MY::prereqs( $self, sub {
665 my ( $self, $module, $phase, $type ) = @_;
666 if ( $module eq 'autodie' ) {
667 $self->log_debug( [
668 'found dependency on module %s (phase %s, type %s), ' .
669 'adding dependency on IPC::System::Simple',
670 $module, $phase, $type
671 ] );
672 $dist->register_prereqs(
673 { phase => $phase, type => $type },
674 'IPC::System::Simple' => 0,
675 );
676 };
677 } );
678 } ],
679 } ],
680  
681 [ 'MetaProvides::Package' ],
682  
683 [ 'MetaResources::Template' => {
684 'delimiters' => '{ }',
685 'homepage' => '{$MY::metacpan}',
686 'license' => '{$dist->license->url}',
687 'repository.type' => '{$MY::repo_type}',
688 'repository.url' => '{$MY::repo_url}',
689 'repository.web' => '{$MY::repo_web}',
690 'bugtracker.mailto' => '{$MY::cpan_rt_mailto}',
691 'bugtracker.web' => '{$MY::cpan_rt_browse}',
692 } ],
693  
694 [ 'MetaYAML' ], # Generate `META.yml`.
695  
696 [ 'MetaJSON' ], # Generate `META.json`.
697  
698 #
699 # Installer
700 #
701  
702 $self->installer ? (
703 [ $self->installer ],
704 ) : (
705 ),
706  
707 #
708 # Release
709 #
710  
711 $self->archive ? (
712 # Make sure archive directory exists. Do it in the very beginnig of release because
713 # it is simple and fast operation. It will be annoying to pass all the tests and
714 # stop release because `dzil` fails to create archive directory.
715 [ 'Hook::BeforeRelease' => 'archive directory' => {
716 'hook' => [ q{
717 my $root = path( $self->zilla->root . '' );
718 my $dir = path( "} . $self->archive . q{" );
719 if ( $dir->is_absolute ) {
720 $self->log_error( [ 'bad archive directory: %s', "$dir" ] );
721 $self->log_error( [ 'absolute path not allowed' ] );
722 $self->abort();
723 };
724 if ( not $dir->is_dir ) {
725 $self->log( [ 'creating archive directory %s', "$dir" ] );
726 $dir->mkpath();
727 };
728 } ],
729 } ]
730 ) : (
731 ),
732  
733 # I want to run xtest before release. Neither RunExtraTests nor CheckExtraTests work for
734 # me. The first one executes extra test when user runs `dzil test`. I do not want it,
735 # because it slows down regular testing. The second one unpacks tarball, builds it, and
736 # run extra tests… But tarball does not include extra tests.
737  
738 [ 'Hook::BeforeRelease' => 'xtest' => {
739 'hook' => [ q{
740 use File::pushd;
741 my $wd = pushd( $zilla->ensure_built );
742 $zilla->_ensure_blib();
743 use App::Prove;
744 local $ENV{ AUTHOR_TESTING } = 1;
745 local $ENV{ RELEASE_TESTING } = 1;
746 my $prove = App::Prove->new({
747 blib => 1,
748 recurse => 1,
749 argv => [ 'xt' ],
750 });
751 $prove->run() or $self->log_error( "xtest failed" );
752 $self->abort_if_errors();
753 } ],
754 } ],
755  
756 [ 'TestRelease' ], # Unpack tarball and run tests.
757  
758 # Make sure the distro does not depend on unwanted modules. Unwanted module, for example,
759 # is `Data::Printer`. I use it often for debugging purposes and forget to remove
760 # debugging code.
761 [ 'Hook::BeforeRelease' => 'unwanted deps' => {
762 'hook' => [ q{
763 my @unwanted = (} . $self->_quote( $self->unwanted_modules ) . q{);
764 my %unwanted = map( { $_ => 1 } @unwanted );
765 my $heading = 'unwanted modules found:';
766 MY::prereqs( $self, sub {
767 my ( $self, $module, $phase, $type ) = @_;
768 if ( $unwanted{ $module } ) {
769 if ( $heading ) {
770 $self->log_error( $heading );
771 $heading = undef;
772 };
773 $self->log_error( [
774 ' %s (phase %s, type %s)', $module, $phase, $type
775 ] );
776 };
777 } );
778 $self->abort_if_error();
779 } ],
780 } ],
781  
782 [ 'CheckPrereqsIndexed' ], # Make sure all prereqs are published in CPAN.
783  
784 [ 'CheckChangesHasContent' ],
785  
786 $self->spellchecker ? (
787 [ 'Hook::BeforeRelease' => 'spellcheck changes' => {
788 'hook' => [ q{
789 $self->log( 'spellchecking Changes' );
790 use File::pushd;
791 my $wd = pushd( $zilla->built_in );
792 #
793 # Run spellchecker, collect list of unknown words.
794 #
795 use IPC::Run3;
796 my @list;
797 run3( '} . $self->spellchecker . q{', 'Changes', \@list );
798 if ( $? > 0 ) {
799 $self->abort();
800 };
801 chomp( @list );
802 #
803 # Steal list of words to ignore from `PodSpelling` plugin.
804 #
805 my $podspelling = $zilla->plugin_named( '} . $name . q{/Test::PodSpelling' );
806 my %ignore = map( { $_ => 1 } @{ $podspelling->stopwords } );
807 #
808 # Add all module names.
809 #
810 my $prereqs = $dist->prereqs->cpan_meta_prereqs;
811 for my $phase ( $prereqs->__legal_phases ) {
812 for my $type ( $prereqs->__legal_types ) {
813 my $reqs = $prereqs->requirements_for( $phase, $type ) or next;
814 for my $module ( keys( %{ $reqs->{ requirements } } ) ) {
815 $ignore{ $_ } = 1 for split( '::', $module );
816 };
817 };
818 };
819 #
820 # Build maps: word => count and count => word.
821 #
822 my %w2c; # word => count
823 $w2c{ $_ } += 1 for grep( { not $ignore{ $_ } and not $ignore{ lc( $_ ) } } @list );
824 my %c2w; # count => word
825 push( @{ $c2w{ $w2c{ $_ } } }, $_ ) for keys( %w2c );
826 #
827 # Now print the list of spelling errors.
828 #
829 for my $count ( sort( { $b <=> $a } keys( %c2w ) ) ) {
830 printf( "%2d: %s\n", $count, join( ', ', sort( @{ $c2w{ $count } } ) ) );
831 };
832 if ( %w2c ) {
833 $self->abort( 'spelling errors found in Changes' );
834 };
835 } ],
836 } ],
837 ) : (
838 ),
839  
840 [ 'Author::VDB::Hg::Tag::Check', ],
841  
842 [ 'Author::VDB::Hg::Status', ],
843  
844 $self->local_release ? (
845 [ 'Hook::BeforeRelease' => 'release note' => {
846 'hook' => [ q{
847 $self->log( '*** Preparing to *local* release ***' );
848 } ],
849 } ],
850 ) : (
851 ),
852 [ 'ConfirmRelease' ], # Ask confirmation before uploading the release.
853  
854 [ 'Hook::Releaser' => 'tgz' => {
855 'hook' => [ q{
856 $MY::tgz = $arg;
857 } ],
858 } ],
859  
860 # `Archive` is a good plugin, but I need to copy, not move tarball, because I want to
861 # archive the tarball first, and then upload it to CPAN.
862 $self->archive ? (
863 [ 'Hook::Releaser' => 'archive release' => {
864 'hook' => [ q{
865 use Path::Tiny;
866 my $tgz = path( $arg );
867 my $dir = path( "} . $self->archive . q{" );
868 $self->log( [ 'copying %s to %s', "$tgz", "$dir" ] );
869 $tgz->copy( $dir->child( $tgz->basename ) );
870 } ],
871 } ],
872 ) : (
873 ),
874  
875 $self->local_release ? (
876 # No need in `FakeRelease`: we have at least one releaser, it is enough.
877 ) : (
878 [ 'UploadToCPAN' ],
879 ),
880  
881 [ 'Author::VDB::Hg::Tag::Add', ],
882  
883 [ 'NextRelease' => {
884 'format' => '%V @ %{yyyy-MM-dd HH:mm zzz}d',
885 'time_zone' => 'UTC',
886 } ],
887  
888 [ 'Author::VDB::Version::Bump', ],
889  
890 [ 'Author::VDB::Hg::Commit', {
891 'files' => [
892 '.hgtags', # Changed by `Hg::Tag::Add`.
893 'Changes', # Changed by `NextRelease`.
894 'VERSION', # Changed by `Version::Bump`.
895 ],
896 } ],
897  
898 $self->local_release ? (
899 ) : (
900 [ 'Author::VDB::Hg::Push', {
901 repository => $self->repository,
902 } ],
903 ),
904  
905 [ 'Hook::AfterRelease' => 'install' => {
906 'hook' => [ q{
907 use autodie ':all';
908 use File::pushd;
909 $self->log( [ 'installing %s-%s', $dist->name, $dist->version ] );
910 my $wd = pushd( $zilla->built_in );
911 system( 'cpanm', '--notest', '.' );
912 # ^ We run the tests on unpacked tarball before release, no need in running
913 # tests one more time.
914 } ],
915 } ],
916  
917 [ 'Hook::AfterRelease' => 'clean' => {
918 'hook' => [ q{
919 $zilla->clean();
920 } ],
921 } ],
922  
923 );
924  
925 7 return;
926  
927 };
928  
929 2 __PACKAGE__->meta->make_immutable();
930  
931 2 1;
932  
933 #pod =head1 COPYRIGHT AND LICENSE
934 #pod
935 #pod Copyright (C) 2015 Van de Bugger
936 #pod
937 #pod License GPLv3+: The GNU General Public License version 3 or later
938 #pod <http://www.gnu.org/licenses/gpl-3.0.txt>.
939 #pod
940 #pod This is free software: you are free to change and redistribute it. There is
941 #pod NO WARRANTY, to the extent permitted by law.
942 #pod
943 #pod
944 #pod =cut
945  
946 # ------------------------------------------------------------------------------------------------
947 #
948 # file: doc/what.pod
949 #
950 # This file is part of perl-Dist-Zilla-PluginBundle-Author-VDB.
951 #
952 # ------------------------------------------------------------------------------------------------
953  
954 #pod =encoding UTF-8
955 #pod
956 #pod =head1 WHAT?
957 #pod
958 #pod C<Dist-Zilla-PluginBundle-Author-VDB> (or just C<@Author::VDB>) is a C<Dist-Zilla> plugin bundle used by VDB.
959 #pod
960 #pod =cut
961  
962 # end of file #
963 # ------------------------------------------------------------------------------------------------
964 #
965 # doc/why.pod
966 #
967 # This file is part of perl-Dist-Zilla-PluginBundle-Author-VDB.
968 #
969 # ------------------------------------------------------------------------------------------------
970  
971 #pod =encoding UTF-8
972 #pod
973 #pod =head1 WHY?
974 #pod
975 #pod I have published few distributions on CPAN. Every distribution have F<dist.ini> file. All the
976 #pod F<dist.ini> files are very similar. Maintaining multiple very similar F<dist.ini> files is boring.
977 #pod Plugin bundle solves the problem.
978 #pod
979 #pod =cut
980  
981 # end of file #
982  
983 =pod
984  
985 =encoding UTF-8
986  
987 =head1 NAME
988  
989 Dist::Zilla::PluginBundle::Author::VDB - VDB's plugin bundle
990  
991 =head1 VERSION
992  
993 Version v0.11.3, released on 2016-12-21 19:58 UTC.
994  
995 =head1 WHAT?
996  
997 C<Dist-Zilla-PluginBundle-Author-VDB> (or just C<@Author::VDB>) is a C<Dist-Zilla> plugin bundle used by VDB.
998  
999 =head1 DESCRIPTION
1000  
1001 It is unlikely that someone else will want to use it, so I will not bother with documenting it, at
1002 least for now.
1003  
1004 =head1 OBJECT METHODS
1005  
1006 =head2 mvp_multivalue_args
1007  
1008 =head2 _quote
1009  
1010 Convert an attribute to a form suitable for using in source. C<Str> attribute is converted into a
1011 string literal, C<ArrayRef> attribute is converted to a list of string literals.
1012  
1013 =head1 OPTIONS
1014  
1015 =head2 minimum_perl
1016  
1017 Desired minimum Perl version. Extra test F<minimum-version.t> fails if actually required Perl
1018 version is greater than desired.
1019  
1020 Optional, default value C<5.006>.
1021  
1022 =head2 copying
1023  
1024 Name of POD file to generate distribution F<COPYING> text file. Empty value disables generation
1025 F<COPYING> file.
1026  
1027 C<Str>, optional, default value C<doc/copying.pod>.
1028  
1029 =head2 readme
1030  
1031 Names of POD files to generate distribution F<README> text file. This is a multi-value option.
1032 Empty values are ignored. Empty list disables generating F<README> file.
1033  
1034 C<ArrayRef[Str]>, optional, default value C<[ 'doc/what.pod', 'doc/why.pod', 'doc/naming.pod', 'doc/forms.pod', 'doc/source.pod', 'doc/distribution.pod', 'doc/installing.pod', 'doc/hacking.pod', 'doc/documentation.pod', 'doc/feedback.pod', 'doc/glossary.pod' ]>.
1035  
1036 =head2 local_release
1037  
1038 If true, release will be a local one, i. e. no external operations will be done: C<UploadToCPAN>
1039 and C<hg push> will be skipped, <hg tag> will create a local tag.
1040  
1041 Option can be set trough F<dist.ini> file or with C<DZIL_LOCAL_RELEASE> environment variable.
1042  
1043 Optional, default value is 0.
1044  
1045 =head2 archive
1046  
1047 Directory to archive files to. If empty, release will not be archived. If such directory does not
1048 exist, it will be created before release.
1049  
1050 Optional, default value C<".releases">.
1051  
1052 =head2 templates
1053  
1054 This option will be passed to C<Templates> plugin. If you no not want C<Templates> to process
1055 files, specify C<:NoFiles>. This is multi-value option (i. e. may be specified several times).
1056  
1057 Optional, default value C<[ ':InstallModules' ]>.
1058  
1059 =head2 unwanted_module
1060  
1061 =head2 unwanted_modules
1062  
1063 C<Data::Printer> is a great module for debugging. But sometimes I forget to remove debug statements
1064 from the code before release. This option helps to check it.
1065  
1066 If any of enlisted modules appears in the distribution dependencies, release will be aborted.
1067  
1068 Default value C<[ qw{ DDP Data::Printer } ]>.
1069  
1070 =head2 spellchecker
1071  
1072 Command to run spellchecker. Spellchecker command is expected to read text from stdin, and print to
1073 stdout misspelled words. If empty, spellchecking will be skipped. This option affects
1074 C<Test::PodSpelling> plugin and internally implemented checking the F<Changes> file.
1075  
1076 Optional, default value C<aspell list -l en -p ./xt/aspell-en.pws>.
1077  
1078 =head2 repository
1079  
1080 Mercurial repository to push changes after release to. Option may be specified multiple times to
1081 push changes into several repositories. By default changes are pushed to one repository C<default>.
1082  
1083 =head2 installer
1084  
1085 Installer plugin.
1086  
1087 Default value C<'ModuleBuildTiny'>.
1088  
1089 =head1 WHY?
1090  
1091 I have published few distributions on CPAN. Every distribution have F<dist.ini> file. All the
1092 F<dist.ini> files are very similar. Maintaining multiple very similar F<dist.ini> files is boring.
1093 Plugin bundle solves the problem.
1094  
1095 =for Pod::Coverage configure
1096  
1097 =head1 AUTHOR
1098  
1099 Van de Bugger <van.de.bugger@gmail.com>
1100  
1101 =head1 COPYRIGHT AND LICENSE
1102  
1103 Copyright (C) 2015 Van de Bugger
1104  
1105 License GPLv3+: The GNU General Public License version 3 or later
1106 <http://www.gnu.org/licenses/gpl-3.0.txt>.
1107  
1108 This is free software: you are free to change and redistribute it. There is
1109 NO WARRANTY, to the extent permitted by law.
1110  
1111 =cut
1112  
1113 __DATA__
« Role/Author/VDB/ProgramRunner.pm ↑ Summary Plugin/Author/VDB/Hg/Status.pm »