File Coverage

lib/Dist/Zilla/Plugin/Author/SKIRMESS/RepositoryBase.pm
Criterion Covered Total %
statement 29 70 41.4
branch 0 14 0.0
condition 0 3 0.0
subroutine 10 17 58.8
pod 0 4 0.0
total 39 108 36.1


line stmt bran cond sub pod time code
1             package Dist::Zilla::Plugin::Author::SKIRMESS::RepositoryBase;
2              
3 1     1   932 use 5.006;
  1         3  
4 1     1   4 use strict;
  1         2  
  1         19  
5 1     1   4 use warnings;
  1         1  
  1         43  
6              
7             our $VERSION = '0.030';
8              
9 1     1   5 use Moose;
  1         1  
  1         9  
10              
11             with(
12             'Dist::Zilla::Role::BeforeBuild',
13             'Dist::Zilla::Role::FileFinderUser' => {
14             method => 'found_module_files',
15             finder_arg_names => ['module_finder'],
16             default_finders => [':InstallModules'],
17             },
18             'Dist::Zilla::Role::FileFinderUser' => {
19             method => 'found_script_files',
20             finder_arg_names => ['script_finder'],
21             default_finders => [':PerlExecFiles'],
22             },
23             'Dist::Zilla::Role::FileMunger',
24             'Dist::Zilla::Role::TextTemplate',
25             );
26              
27             sub mvp_multivalue_args { return (qw( skip stopwords travis_ci_ignore_perl travis_ci_no_author_testing_perl travis_ci_osx_perl )) }
28              
29             has skip => (
30             is => 'ro',
31             isa => 'Maybe[ArrayRef]',
32             default => sub { [] },
33             );
34              
35             has stopwords => (
36             is => 'ro',
37             isa => 'Maybe[ArrayRef]',
38             default => sub { [] },
39             );
40              
41             has travis_ci_ignore_perl => (
42             is => 'ro',
43             isa => 'Maybe[ArrayRef]',
44             default => sub { [] },
45             );
46              
47             has travis_ci_no_author_testing_perl => (
48             is => 'ro',
49             isa => 'Maybe[ArrayRef]',
50             default => sub { [qw(5.8)] },
51             );
52              
53             has travis_ci_osx_perl => (
54             is => 'ro',
55             isa => 'ArrayRef[Str]',
56             default => sub { [qw(5.18)] },
57             );
58              
59             has _travis_available_perl => (
60             is => 'ro',
61             isa => 'ArrayRef[Str]',
62             default => sub { [qw( 5.8 5.10 5.12 5.14 5.16 5.18 5.20 5.22 5.24 5.26)] },
63             traits => ['Array'],
64             );
65              
66 1     1   5587 use Carp;
  1         2  
  1         63  
67 1     1   396 use Config::Std { def_sep => q{=} };
  1         11301  
  1         15  
68 1     1   52 use File::Spec;
  1         2  
  1         24  
69 1     1   362 use List::SomeUtils qw(uniq);
  1         4787  
  1         68  
70 1     1   7 use Path::Tiny;
  1         1  
  1         38  
71              
72 1     1   5 use namespace::autoclean;
  1         1  
  1         8  
73              
74             sub before_build {
75 0     0 0   my ($self) = @_;
76              
77             # Files must exist during the "gather files" phase and therefore we're
78             # forced to create them in the "before build" phase.
79 0           $self->_write_files();
80              
81 0           return;
82             }
83              
84             sub munge_files {
85 0     0 0   my ($self) = @_;
86              
87             # Files are already generated in the before build phase.
88              
89             # This module is part of the Author::SKIRMESS plugin bundle. The bundle
90             # is either used to release itself, but also to release other
91             # distributions. We must know which kind of build the current build is
92             # because if we build another distribution we are done, the files were
93             # already correctly generated during the "before build" phase.
94             #
95             # But if we are using the bundle to release itself we have to recreate
96             # the generated files because the new version of this plugin was not
97             # known during the "before build" phase.
98             #
99             # If __FILE__ is inside lib of the cwd we are run with Bootstrap::lib
100             # which means we are building the bundle. Otherwise we use the bundle to
101             # build another distribution.
102 0 0 0       if ( exists $ENV{DZIL_RELEASING} && path('lib')->realpath->subsumes( path(__FILE__)->realpath() ) ) {
103              
104             # Ok, we are releasing the bundle itself. That means that $VERSION of
105             # this module is not set correctly as the module was require'd before
106             # the $VERSION was adjusted in the file (during the "munge files"
107             # phase). We have to fix this now to write the correct version to the
108             # generated files.
109              
110             # NOTE: Just a reminder if someone wants to refactor this module.
111             # $self->zilla->version() must not be called in the "before build"
112             # phase because it calls _build_version which is going to fail the
113             # build. Besides that, VersionFromMainModule is run during the
114             # "munge files" phase and before that we can't even know the new
115             # version of the bundle.
116              
117 0           local $VERSION = $self->zilla->version;
118              
119             # re-write all generated files
120 0           $self->_write_files();
121              
122 0           return;
123             }
124              
125             # We are building, or releasing something else - not the bundle itself.
126              
127             # We always have to write t/00-load.t during the munge files phase
128             # because this file is not created correctly during the before
129             # build phase because the FileFinderUser isn't initialized that
130             # early
131 0           $self->_write_file('t/00-load.t');
132 0           return;
133             }
134              
135             sub _write_files {
136 0     0     my ($self) = @_;
137              
138 0 0         my %file_to_skip = map { $_ => 1 } grep { defined && !m{ ^ \s* $ }xsm } @{ $self->skip };
  0            
  0            
  0            
139              
140             FILE:
141 0           for my $file ( sort $self->files() ) {
142 0 0         if ( exists $file_to_skip{$file} ) {
143 0           next FILE;
144             }
145              
146 0           $self->_write_file($file);
147             }
148              
149 0           return;
150             }
151              
152             sub _write_file {
153 0     0     my ( $self, $file ) = @_;
154              
155 0           $file = path($file);
156              
157 0 0         if ( -e $file ) {
158 0           $file->remove();
159             }
160             else {
161             # If the file does not yet exist, the basedir might also not
162             # exist. Create it if required.
163 0           my $parent = $file->parent();
164 0 0         if ( !-e $parent ) {
165 0           $self->log("Creating directory $parent");
166 0           $parent->mkpath();
167             }
168             }
169              
170 0           $self->log("Generate file $file");
171              
172             # write the file to disk
173 0           $file->spew( $self->file($file) );
174              
175 0           return;
176             }
177              
178             =pod
179              
180             =encoding UTF-8
181              
182             =head1 NAME
183              
184             Dist::Zilla::Plugin::Author::SKIRMESS::RepositoryBase - Automatically create and update files
185              
186             =head1 VERSION
187              
188             Version 0.030
189              
190             =head1 SYNOPSIS
191              
192             This plugin is part of the
193             L<Dist::Zilla::PluginBundle::Author::SKIRMESS|Dist::Zilla::PluginBundle::Author::SKIRMESS>
194             bundle and should not be used outside of that.
195              
196             =head1 DESCRIPTION
197              
198             This plugin creates a collection of files that are shared between all my
199             CPAN distributions which makes it easy to keep them all up to date.
200              
201             The following files are created in the repository and in the distribution:
202              
203             =cut
204              
205             {
206             # Files to generate
207             my %file;
208              
209             sub files {
210 0     0 0   my ($self) = @_;
211              
212 0           return keys %file;
213             }
214              
215             sub file {
216 0     0 0   my ( $self, $filename ) = @_;
217              
218 0 0         if ( !exists $file{$filename} ) {
219 0           $self->log_fatal("File '$filename' is not defined");
220              
221             # log_fatal should die
222 0           croak 'internal error';
223             }
224              
225 0           my $file_content = $file{$filename};
226 0 0   0     if ( ref $file_content eq ref sub { } ) {
227 0           $file_content = $file_content->($self);
228             }
229              
230             # process the file template
231 0           return $self->fill_in_string(
232             $file_content,
233             {
234             plugin => \$self,
235             },
236             );
237             }
238              
239             =head2 .appveyor.yml
240              
241             The configuration file for AppVeyor.
242              
243             =cut
244              
245             $file{q{.appveyor.yml}} = <<'APPVEYOR_YML';
246             # Automatically generated file
247             # {{ ref $plugin }} {{ $plugin->VERSION() }}
248              
249             skip_tags: true
250              
251             cache:
252             - C:\strawberry -> appveyor.yml
253              
254             install:
255             - if not exist "C:\strawberry" cinst strawberryperl
256             - set PATH=C:\strawberry\perl\bin;C:\strawberry\perl\site\bin;C:\strawberry\c\bin;%PATH%
257             - cd C:\projects\%APPVEYOR_PROJECT_NAME%
258             - cpanm --quiet --installdeps --notest --skip-satisfied --with-develop .
259              
260             build_script:
261             - perl Makefile.PL
262             - set AUTOMATED_TESTING=1
263             - gmake test
264             - prove -lr xt/author
265             APPVEYOR_YML
266              
267             =head2 .perlcriticrc
268              
269             The configuration for L<Perl::Critic|Perl::Critic>. This file is created from
270             a default contained in this plugin and from distribution specific settings in
271             F<perlcriticrc.local>.
272              
273             =cut
274              
275             $file{q{.perlcriticrc}} = sub {
276             my ($self) = @_;
277              
278             my $perlcriticrc_template = <<'PERLCRITICRC_TEMPLATE';
279             # Automatically generated file
280             # {{ ref $plugin }} {{ $plugin->VERSION() }}
281              
282             only = 1
283             severity = 1
284             verbose = [%p] %m at %f line %l, near '%r'\n
285              
286             [BuiltinFunctions::ProhibitBooleanGrep]
287             [BuiltinFunctions::ProhibitComplexMappings]
288             [BuiltinFunctions::ProhibitLvalueSubstr]
289             [BuiltinFunctions::ProhibitReverseSortBlock]
290             [BuiltinFunctions::ProhibitSleepViaSelect]
291             [BuiltinFunctions::ProhibitStringyEval]
292             [BuiltinFunctions::ProhibitStringySplit]
293             [BuiltinFunctions::ProhibitUniversalCan]
294             [BuiltinFunctions::ProhibitUniversalIsa]
295             [BuiltinFunctions::ProhibitUselessTopic]
296             [BuiltinFunctions::ProhibitVoidGrep]
297             [BuiltinFunctions::ProhibitVoidMap]
298             [BuiltinFunctions::RequireBlockGrep]
299             [BuiltinFunctions::RequireBlockMap]
300             [BuiltinFunctions::RequireGlobFunction]
301             [BuiltinFunctions::RequireSimpleSortBlock]
302             [ClassHierarchies::ProhibitAutoloading]
303             [ClassHierarchies::ProhibitExplicitISA]
304             [ClassHierarchies::ProhibitOneArgBless]
305             [CodeLayout::ProhibitHardTabs]
306             [CodeLayout::ProhibitParensWithBuiltins]
307             [CodeLayout::ProhibitQuotedWordLists]
308             [CodeLayout::ProhibitTrailingWhitespace]
309             [CodeLayout::RequireConsistentNewlines]
310             [CodeLayout::RequireTidyCode]
311             [CodeLayout::RequireTrailingCommas]
312             [ControlStructures::ProhibitCStyleForLoops]
313             [ControlStructures::ProhibitCascadingIfElse]
314             [ControlStructures::ProhibitDeepNests]
315             [ControlStructures::ProhibitLabelsWithSpecialBlockNames]
316             [ControlStructures::ProhibitMutatingListFunctions]
317             [ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions]
318             [ControlStructures::ProhibitPostfixControls]
319             [ControlStructures::ProhibitUnlessBlocks]
320             [ControlStructures::ProhibitUnreachableCode]
321             [ControlStructures::ProhibitUntilBlocks]
322             [ControlStructures::ProhibitYadaOperator]
323             #[Documentation::PodSpelling]
324             [Documentation::RequirePackageMatchesPodName]
325             [Documentation::RequirePodAtEnd]
326             [Documentation::RequirePodLinksIncludeText]
327             #[Documentation::RequirePodSections]
328              
329             [ErrorHandling::RequireCarping]
330             allow_in_main_unless_in_subroutine = 1
331              
332             [ErrorHandling::RequireCheckingReturnValueOfEval]
333             [InputOutput::ProhibitBacktickOperators]
334             [InputOutput::ProhibitBarewordFileHandles]
335             [InputOutput::ProhibitExplicitStdin]
336             [InputOutput::ProhibitInteractiveTest]
337             [InputOutput::ProhibitJoinedReadline]
338             [InputOutput::ProhibitOneArgSelect]
339             [InputOutput::ProhibitReadlineInForLoop]
340             [InputOutput::ProhibitTwoArgOpen]
341             [InputOutput::RequireBracedFileHandleWithPrint]
342             #[InputOutput::RequireBriefOpen]
343             [InputOutput::RequireCheckedClose]
344             [InputOutput::RequireCheckedOpen]
345              
346             [InputOutput::RequireCheckedSyscalls]
347             functions = :builtins
348             exclude_functions = print say sleep
349              
350             [InputOutput::RequireEncodingWithUTF8Layer]
351             [Miscellanea::ProhibitFormats]
352             [Miscellanea::ProhibitTies]
353             [Miscellanea::ProhibitUnrestrictedNoCritic]
354             [Miscellanea::ProhibitUselessNoCritic]
355             [Modules::ProhibitAutomaticExportation]
356             [Modules::ProhibitConditionalUseStatements]
357              
358             [Modules::ProhibitEvilModules]
359             modules = Class::ISA {Found use of Class::ISA. This module is deprecated by the Perl 5 Porters.} Pod::Plainer {Found use of Pod::Plainer. This module is deprecated by the Perl 5 Porters.} Shell {Found use of Shell. This module is deprecated by the Perl 5 Porters.} Switch {Found use of Switch. This module is deprecated by the Perl 5 Porters.} Readonly {Found use of Readonly. Please use constant.pm or Const::Fast.} base {Found use of base. Please use parent instead.} File::Slurp {Found use of File::Slurp. Please use Path::Tiny instead.} common::sense {Found use of common::sense. Please use strict and warnings instead.} Class::Load {Found use of Class::Load. Please use Module::Runtime instead.} Any::Moose {Found use of Any::Moose. Please use Moo instead.} Error {Found use of Error.pm. Please use Throwable.pm instead.} Getopt::Std {Found use of Getopt::Std. Please use Getopt::Long instead.} HTML::Template {Found use of HTML::Template. Please use Template::Toolkit.} IO::Socket::INET6 {Found use of IO::Socket::INET6. Please use IO::Socket::IP.} JSON {Found use of JSON. Please use JSON::MaybeXS or Cpanel::JSON::XS.} JSON::Any {Found use of JSON::Any. Please use JSON::MaybeXS.} List::MoreUtils {Found use of List::MoreUtils. Please use List::Util or List::UtilsBy.} Mouse {Found use of Mouse. Please use Moo.} Net::IRC {Found use of Net::IRC. Please use POE::Component::IRC, Net::Async::IRC, or Mojo::IRC.} XML::Simple {Found use of XML::Simple. Please use XML::LibXML, XML::TreeBuilder, XML::Twig, or Mojo::DOM.} Sub::Infix {Found use of Sub::Infix. Please do not use it.}
360              
361             #[Modules::ProhibitExcessMainComplexity]
362             [Modules::ProhibitMultiplePackages]
363             [Modules::RequireBarewordIncludes]
364             [Modules::RequireEndWithOne]
365             [Modules::RequireExplicitPackage]
366             [Modules::RequireFilenameMatchesPackage]
367             [Modules::RequireNoMatchVarsWithUseEnglish]
368             #[Modules::RequireVersionVar]
369             [NamingConventions::Capitalization]
370             [NamingConventions::ProhibitAmbiguousNames]
371             [Objects::ProhibitIndirectSyntax]
372             [References::ProhibitDoubleSigils]
373             [RegularExpressions::ProhibitCaptureWithoutTest]
374             [RegularExpressions::ProhibitComplexRegexes]
375             [RegularExpressions::ProhibitEnumeratedClasses]
376             [RegularExpressions::ProhibitEscapedMetacharacters]
377             [RegularExpressions::ProhibitFixedStringMatches]
378             [RegularExpressions::ProhibitSingleCharAlternation]
379             [RegularExpressions::ProhibitUnusedCapture]
380             [RegularExpressions::ProhibitUnusualDelimiters]
381             [RegularExpressions::ProhibitUselessTopic]
382             [RegularExpressions::RequireBracesForMultiline]
383             [RegularExpressions::RequireDotMatchAnything]
384             [RegularExpressions::RequireExtendedFormatting]
385             [RegularExpressions::RequireLineBoundaryMatching]
386             [Subroutines::ProhibitAmpersandSigils]
387             [Subroutines::ProhibitBuiltinHomonyms]
388             [Subroutines::ProhibitExcessComplexity]
389             [Subroutines::ProhibitExplicitReturnUndef]
390             [Subroutines::ProhibitManyArgs]
391             [Subroutines::ProhibitNestedSubs]
392             [Subroutines::ProhibitReturnSort]
393             [Subroutines::ProhibitSubroutinePrototypes]
394              
395             [Subroutines::ProhibitUnusedPrivateSubroutines]
396             private_name_regex = _(?!build_)\w+
397              
398             [Subroutines::ProtectPrivateSubs]
399             [Subroutines::RequireArgUnpacking]
400             [Subroutines::RequireFinalReturn]
401             [TestingAndDebugging::ProhibitNoStrict]
402             [TestingAndDebugging::ProhibitNoWarnings]
403             [TestingAndDebugging::ProhibitProlongedStrictureOverride]
404             [TestingAndDebugging::RequireTestLabels]
405             [TestingAndDebugging::RequireUseStrict]
406             [TestingAndDebugging::RequireUseWarnings]
407             [ValuesAndExpressions::ProhibitCommaSeparatedStatements]
408              
409             [ValuesAndExpressions::ProhibitComplexVersion]
410             forbid_use_version = 1
411              
412             [ValuesAndExpressions::ProhibitConstantPragma]
413             [ValuesAndExpressions::ProhibitEmptyQuotes]
414             [ValuesAndExpressions::ProhibitEscapedCharacters]
415             [ValuesAndExpressions::ProhibitImplicitNewlines]
416             [ValuesAndExpressions::ProhibitInterpolationOfLiterals]
417             [ValuesAndExpressions::ProhibitLeadingZeros]
418             [ValuesAndExpressions::ProhibitLongChainsOfMethodCalls]
419             [ValuesAndExpressions::ProhibitMagicNumbers]
420             [ValuesAndExpressions::ProhibitMismatchedOperators]
421             [ValuesAndExpressions::ProhibitMixedBooleanOperators]
422             [ValuesAndExpressions::ProhibitNoisyQuotes]
423             [ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters]
424             [ValuesAndExpressions::ProhibitSpecialLiteralHeredocTerminator]
425             [ValuesAndExpressions::ProhibitVersionStrings]
426             [ValuesAndExpressions::RequireConstantVersion]
427             [ValuesAndExpressions::RequireInterpolationOfMetachars]
428             [ValuesAndExpressions::RequireNumberSeparators]
429             [ValuesAndExpressions::RequireQuotedHeredocTerminator]
430             [ValuesAndExpressions::RequireUpperCaseHeredocTerminator]
431             [Variables::ProhibitAugmentedAssignmentInDeclaration]
432             [Variables::ProhibitConditionalDeclarations]
433             [Variables::ProhibitEvilVariables]
434             [Variables::ProhibitLocalVars]
435             [Variables::ProhibitMatchVars]
436             [Variables::ProhibitPackageVars]
437             [Variables::ProhibitPerl4PackageNames]
438              
439             [Variables::ProhibitPunctuationVars]
440             allow = $@ $! $/ $0
441              
442             [Variables::ProhibitReusedNames]
443             [Variables::ProhibitUnusedVariables]
444             [Variables::ProtectPrivateVars]
445             [Variables::RequireInitializationForLocalVars]
446             [Variables::RequireLexicalLoopIterators]
447             [Variables::RequireLocalizedPunctuationVars]
448             [Variables::RequireNegativeIndices]
449              
450             ### Perl::Critic::Bangs
451             [Bangs::ProhibitBitwiseOperators]
452             #[Bangs::ProhibitCommentedOutCode]
453             [Bangs::ProhibitDebuggingModules]
454             [Bangs::ProhibitFlagComments]
455             #[Bangs::ProhibitNoPlan]
456             [Bangs::ProhibitNumberedNames]
457             [Bangs::ProhibitRefProtoOrProto]
458             [Bangs::ProhibitUselessRegexModifiers]
459             #[Bangs::ProhibitVagueNames]
460              
461             ### Perl::Critic::Moose
462             [Moose::ProhibitDESTROYMethod]
463             equivalent_modules = Moo Moo::Role
464              
465             [Moose::ProhibitLazyBuild]
466             equivalent_modules = Moo Moo::Role
467              
468             [Moose::ProhibitMultipleWiths]
469             equivalent_modules = Moo Moo::Role
470              
471             [Moose::ProhibitNewMethod]
472             equivalent_modules = Moo Moo::Role
473              
474             [Moose::RequireCleanNamespace]
475             [Moose::RequireMakeImmutable]
476              
477             ### Perl::Critic::Freenode
478             [Freenode::AmpersandSubCalls]
479             [Freenode::ArrayAssignAref]
480             [Freenode::BarewordFilehandles]
481             [Freenode::ConditionalDeclarations]
482             [Freenode::ConditionalImplicitReturn]
483             [Freenode::DeprecatedFeatures]
484             [Freenode::DiscouragedModules]
485             [Freenode::DollarAB]
486             [Freenode::Each]
487             #[Freenode::EmptyReturn]
488             [Freenode::IndirectObjectNotation]
489             [Freenode::ModPerl]
490             [Freenode::OpenArgs]
491             [Freenode::OverloadOptions]
492             [Freenode::PackageMatchesFilename]
493             [Freenode::POSIXImports]
494             [Freenode::Prototypes]
495             [Freenode::StrictWarnings]
496             [Freenode::Threads]
497             [Freenode::Wantarray]
498             [Freenode::WarningsSwitch]
499             [Freenode::WhileDiamondDefaultAssignment]
500              
501             ### Perl::Critic::Policy::HTTPCookies
502             [HTTPCookies]
503              
504             ### Perl::Critic::Itch
505             #[CodeLayout::ProhibitHashBarewords]
506              
507             ### Perl::Critic::Lax
508             [Lax::ProhibitComplexMappings::LinesNotStatements]
509             #[Lax::ProhibitEmptyQuotes::ExceptAsFallback]
510             #[Lax::ProhibitLeadingZeros::ExceptChmod]
511             #[Lax::ProhibitStringyEval::ExceptForRequire]
512             #[Lax::RequireConstantOnLeftSideOfEquality::ExceptEq]
513             #[Lax::RequireEndWithTrueConst]
514             #[Lax::RequireExplicitPackage::ExceptForPragmata]
515              
516             ### Perl::Critic::More
517             #[CodeLayout::RequireASCII]
518             #[Editor::RequireEmacsFileVariables]
519             #[ErrorHandling::RequireUseOfExceptions]
520             [Modules::PerlMinimumVersion]
521             [Modules::RequirePerlVersion]
522             #[ValuesAndExpressions::RequireConstantOnLeftSideOfEquality]
523             #[ValuesAndExpressions::RestrictLongStrings]
524              
525             # Perl::Critic::PetPeeves::JTRAMMELL
526             [Variables::ProhibitUselessInitialization]
527              
528             ### Perl::Critic::Policy::BuiltinFunctions::ProhibitDeleteOnArrays
529             [BuiltinFunctions::ProhibitDeleteOnArrays]
530              
531             ### Perl::Critic::Policy::BuiltinFunctions::ProhibitReturnOr
532             [BuiltinFunctions::ProhibitReturnOr]
533              
534             ### Perl::Critic::Policy::Moo::ProhibitMakeImmutable
535             [Moo::ProhibitMakeImmutable]
536              
537             ### Perl::Critic::Policy::ValuesAndExpressions::ProhibitSingleArgArraySlice
538             # requires Perl 5.12
539             #[ValuesAndExpressions::ProhibitSingleArgArraySlice]
540              
541             ### Perl::Critic::Policy::Perlsecret
542             [Perlsecret]
543              
544             ### Perl::Critic::Policy::TryTiny::RequireBlockTermination
545             [TryTiny::RequireBlockTermination]
546              
547             ### Perl::Critic::Policy::TryTiny::RequireUse
548             [TryTiny::RequireUse]
549              
550             ### Perl::Critic::Policy::ValuesAndExpressions::PreventSQLInjection
551             [ValuesAndExpressions::PreventSQLInjection]
552              
553             ### Perl::Critic::Policy::Variables::ProhibitUnusedVarsStricter
554             [Variables::ProhibitUnusedVarsStricter]
555             allow_unused_subroutine_arguments = 1
556              
557             ### Perl::Critic::Pulp
558             [CodeLayout::ProhibitFatCommaNewline]
559             #[CodeLayout::ProhibitIfIfSameLine]
560             [CodeLayout::RequireFinalSemicolon]
561             [CodeLayout::RequireTrailingCommaAtNewline]
562             [Compatibility::ConstantLeadingUnderscore]
563             [Compatibility::ConstantPragmaHash]
564             #[Compatibility::Gtk2Constants]
565             [Compatibility::PerlMinimumVersionAndWhy]
566             #[Compatibility::PodMinimumVersion]
567             [Compatibility::ProhibitUnixDevNull]
568             [Documentation::ProhibitAdjacentLinks]
569             [Documentation::ProhibitBadAproposMarkup]
570             [Documentation::ProhibitDuplicateHeadings]
571             #[Documentation::ProhibitDuplicateSeeAlso]
572             [Documentation::ProhibitLinkToSelf]
573             [Documentation::ProhibitParagraphEndComma]
574             [Documentation::ProhibitParagraphTwoDots]
575             [Documentation::ProhibitUnbalancedParens]
576             [Documentation::ProhibitVerbatimMarkup]
577             [Documentation::RequireEndBeforeLastPod]
578             [Documentation::RequireFilenameMarkup]
579             #[Documentation::RequireFinalCut]
580             [Documentation::RequireLinkedURLs]
581             #[Miscellanea::TextDomainPlaceholders]
582             #[Miscellanea::TextDomainUnused]
583             [Modules::ProhibitModuleShebang]
584             [Modules::ProhibitPOSIXimport]
585             [Modules::ProhibitUseQuotedVersion]
586             [ValuesAndExpressions::ConstantBeforeLt]
587             [ValuesAndExpressions::NotWithCompare]
588             [ValuesAndExpressions::ProhibitArrayAssignAref]
589             [ValuesAndExpressions::ProhibitBarewordDoubleColon]
590             [ValuesAndExpressions::ProhibitDuplicateHashKeys]
591             [ValuesAndExpressions::ProhibitEmptyCommas]
592             #[ValuesAndExpressions::ProhibitFiletest_f]
593             [ValuesAndExpressions::ProhibitNullStatements]
594             [ValuesAndExpressions::ProhibitUnknownBackslash]
595             [ValuesAndExpressions::RequireNumericVersion]
596             [ValuesAndExpressions::UnexpandedSpecialLiteral]
597              
598             ### Perl::Critic::StricterSubs
599             [Modules::RequireExplicitInclusion]
600             #[Subroutines::ProhibitCallsToUndeclaredSubs]
601             #[Subroutines::ProhibitCallsToUnexportedSubs]
602             [Subroutines::ProhibitExportingUndeclaredSubs]
603             [Subroutines::ProhibitQualifiedSubDeclarations]
604              
605             ### Perl::Critic::Tics
606             #[Tics::ProhibitLongLines]
607             [Tics::ProhibitManyArrows]
608             [Tics::ProhibitUseBase]
609             PERLCRITICRC_TEMPLATE
610              
611             # Conig::Std will not preserve a comment on the last line, therefore
612             # we append at least one empty line at the end
613             $perlcriticrc_template .= "\n\n";
614              
615             read_config \$perlcriticrc_template, my %perlcriticrc;
616              
617             my $perlcriticrc_local = 'perlcriticrc.local';
618              
619             if ( -f $perlcriticrc_local ) {
620             $self->log("Adjusting Perl::Critic config from '$perlcriticrc_local'");
621              
622             read_config $perlcriticrc_local, my %perlcriticrc_local;
623              
624             my %local_seen;
625              
626             POLICY:
627             for my $policy ( keys %perlcriticrc_local ) {
628              
629             if ( $policy eq q{-} ) {
630             $self->log_fatal('We cannot disable the global settings');
631              
632             # log_fatal should die
633             croak 'internal error';
634             }
635              
636             my $policy_name = $policy =~ m{ ^ - (.+) }xsm ? $1 : $policy;
637              
638             if ( exists $local_seen{$policy_name} ) {
639             $self->log_fatal("There are multiple entries for policy '$policy_name' in '$perlcriticrc_local'.");
640              
641             # log_fatal should die
642             croak 'internal error';
643             }
644              
645             $local_seen{$policy_name} = 1;
646              
647             delete $perlcriticrc{$policy_name};
648              
649             if ( $policy =~ m{ ^ - }xsm ) {
650             $self->log("Disabling policy '$policy_name'");
651             next POLICY;
652             }
653              
654             if ( $policy eq q{} ) {
655             $self->log('Custom global settings');
656             }
657             else {
658             $self->log("Custom configuration for policy '$policy_name'");
659             }
660              
661             $perlcriticrc{$policy_name} = $perlcriticrc_local{$policy_name};
662             }
663             }
664              
665             if ( ( !exists $perlcriticrc{q{}}{only} ) or ( $perlcriticrc{q{}}{only} ne '1' ) ) {
666             $self->log(q{Setting global option 'only' back to '1'});
667             $perlcriticrc{q{}}{only} = '1';
668             }
669              
670             my $content;
671             write_config %perlcriticrc, \$content;
672              
673             return $content;
674             };
675              
676             =head2 .perltidyrc
677              
678             The configuration file for B<perltidy>.
679              
680             =cut
681              
682             $file{q{.perltidyrc}} = <<'PERLTIDYRC';
683             # Automatically generated file
684             # {{ ref $plugin }} {{ $plugin->VERSION() }}
685              
686             --maximum-line-length=0
687             --break-at-old-comma-breakpoints
688             --backup-and-modify-in-place
689             --output-line-ending=unix
690             PERLTIDYRC
691              
692             =head2 .travis.yml
693              
694             The configuration file for TravisCI. All known supported Perl versions are
695             enabled unless disabled with B<travis_ci_ignore_perl>.
696              
697             With B<travis_ci_osx_perl> you can specify one or multiple Perl versions to
698             be tested on OSX, in addition to on Linux. If omitted it defaults to one
699             single version.
700              
701             Use the B<travis_ci_no_author_testing_perl> option to disable author tests on
702             some Perl versions.
703              
704             =cut
705              
706             $file{q{.travis.yml}} = sub {
707             my ($self) = @_;
708              
709             my $travis_yml = <<'TRAVIS_YML_1';
710             # Automatically generated file
711             # {{ ref $plugin }} {{ $plugin->VERSION() }}
712              
713             language: perl
714              
715             cache:
716             directories:
717             - ~/perl5
718              
719             env:
720             global:
721             - AUTOMATED_TESTING=1
722              
723             matrix:
724             include:
725             TRAVIS_YML_1
726              
727             my %ignore_perl;
728             @ignore_perl{ @{ $self->travis_ci_ignore_perl } } = ();
729              
730             my %no_auth;
731             @no_auth{ @{ $self->travis_ci_no_author_testing_perl } } = ();
732              
733             my %osx_perl;
734             @osx_perl{ @{ $self->travis_ci_osx_perl } } = ();
735              
736             PERL:
737             for my $perl ( @{ $self->_travis_available_perl } ) {
738             next PERL if exists $ignore_perl{$perl};
739              
740             my @os = (undef);
741             if ( exists $osx_perl{$perl} ) {
742             push @os, 'osx';
743             }
744              
745             for my $os (@os) {
746             $travis_yml .= " - perl: '$perl'\n";
747              
748             if ( !exists $no_auth{$perl} ) {
749             $travis_yml .= " env: AUTHOR_TESTING=1\n";
750             }
751              
752             if ( defined $os ) {
753             $travis_yml .= " os: $os\n";
754             }
755              
756             $travis_yml .= "\n";
757             }
758             }
759              
760             $travis_yml .= <<'TRAVIS_YML';
761             before_install:
762             - |
763             case "${TRAVIS_OS_NAME}" in
764             "linux" )
765             ;;
766             "osx" )
767             # TravisCI extracts the broken perl archive with sudo which creates the
768             # $HOME/perl5 directory with owner root:staff. Subdirectories under
769             # perl5 are owned by user travis.
770             sudo chown "$USER" "$HOME/perl5"
771              
772             # The perl distribution TravisCI extracts on OSX is incomplete
773             sudo rm -rf "$HOME/perl5/perlbrew"
774              
775             # Install cpanm and local::lib
776             curl -L https://cpanmin.us | perl - App::cpanminus local::lib
777             eval $(perl -I $HOME/perl5/lib/perl5/ -Mlocal::lib)
778             ;;
779             esac
780              
781             install:
782             - |
783             if [ -n "$AUTHOR_TESTING" ]
784             then
785             cpanm --quiet --installdeps --notest --skip-satisfied --with-develop .
786             else
787             cpanm --quiet --installdeps --notest --skip-satisfied .
788             fi
789              
790             script:
791             - perl Makefile.PL && make test
792             - |
793             if [ -n "$AUTHOR_TESTING" ]
794             then
795             prove -lr xt/author
796             fi
797             TRAVIS_YML
798              
799             return $travis_yml;
800             };
801              
802             # test header
803             my $test_header = <<'_TEST_HEADER';
804             #!perl
805              
806             use 5.006;
807             use strict;
808             use warnings;
809              
810             # this test was generated with
811             # {{ ref $plugin }} {{ $plugin->VERSION() }}
812              
813             _TEST_HEADER
814              
815             =head2 t/00-load.t
816              
817             Verifies that all modules and perl scripts can be compiled with require_ok
818             from L<Test::More|Test::More>.
819              
820             =cut
821              
822             $file{q{t/00-load.t}} = sub {
823             my ($self) = @_;
824              
825             my %use_lib_args = (
826             lib => undef,
827             q{.} => undef,
828             );
829              
830             my @modules;
831             MODULE:
832             for my $module ( map { $_->name } @{ $self->found_module_files() } ) {
833             next MODULE if $module =~ m{ [.] pod $}xsm;
834              
835             my @dirs = File::Spec->splitdir($module);
836             if ( $dirs[0] eq 'lib' && $dirs[-1] =~ s{ [.] pm $ }{}xsm ) {
837             shift @dirs;
838             push @modules, join q{::}, @dirs;
839             $use_lib_args{lib} = 1;
840             next MODULE;
841             }
842              
843             $use_lib_args{q{.}} = 1;
844             push @modules, $module;
845             }
846              
847             my @scripts = map { $_->name } @{ $self->found_script_files() };
848             if (@scripts) {
849             $use_lib_args{q{.}} = 1;
850             }
851              
852             my $content = $test_header . <<'T_OO_LOAD_T';
853             use Test::More;
854              
855             T_OO_LOAD_T
856              
857             if ( !@scripts && !@modules ) {
858             $content .= qq{BAIL_OUT("No files found in distribution");\n};
859              
860             return $content;
861             }
862              
863             $content .= 'use lib qw(';
864             if ( defined $use_lib_args{lib} ) {
865             if ( defined $use_lib_args{q{.}} ) {
866             $content .= 'lib .';
867             }
868             else {
869             $content .= 'lib';
870             }
871             }
872             else {
873             $content .= q{.};
874             }
875             $content .= ");\n\n";
876              
877             $content .= "my \@modules = qw(\n";
878              
879             for my $module ( @modules, @scripts ) {
880             $content .= " $module\n";
881             }
882             $content .= <<'T_OO_LOAD_T';
883             );
884              
885             plan tests => scalar @modules;
886              
887             for my $module (@modules) {
888             require_ok($module) || BAIL_OUT();
889             }
890             T_OO_LOAD_T
891              
892             return $content;
893             };
894              
895             =head2 xt/author/clean-namespaces.t
896              
897             L<Test::CleanNamespaces|Test::CleanNamespaces> author test.
898              
899             =cut
900              
901             $file{q{xt/author/clean-namespaces.t}} = $test_header . <<'XT_AUTHOR_CLEAN_NAMESPACES_T';
902             use Test::More;
903             use Test::CleanNamespaces;
904              
905             if ( !Test::CleanNamespaces->find_modules() ) {
906             plan skip_all => 'No files found to test.';
907             }
908              
909             all_namespaces_clean();
910             XT_AUTHOR_CLEAN_NAMESPACES_T
911              
912             =head2 xt/author/critic.t
913              
914             L<Test::Perl::Critic|Test::Perl::Critic> author test.
915              
916             =cut
917              
918             $file{q{xt/author/critic.t}} = $test_header . <<'XT_AUTHOR_CRITIC_T';
919             use File::Spec;
920              
921             use Perl::Critic::Utils qw(all_perl_files);
922             use Test::More;
923             use Test::Perl::Critic;
924              
925             my @dirs = qw(bin lib t xt);
926              
927             my @ignores;
928             my %file;
929             @file{ all_perl_files(@dirs) } = ();
930             delete @file{@ignores};
931             my @files = keys %file;
932              
933             if ( @files == 0 ) {
934             BAIL_OUT('no files to criticize found');
935             }
936              
937             all_critic_ok(@files);
938             XT_AUTHOR_CRITIC_T
939              
940             =head2 xt/author/minimum_version.t
941              
942             L<Test::MinimumVersion|Test::MinimumVersion> author test.
943              
944             =cut
945              
946             $file{q{xt/author/minimum_version.t}} = $test_header . <<'XT_AUTHOR_MINIMUM_VERSION_T';
947             use Test::MinimumVersion 0.008;
948              
949             all_minimum_version_from_metayml_ok();
950             XT_AUTHOR_MINIMUM_VERSION_T
951              
952             =head2 xt/author/mojibake.t
953              
954             L<Test::Mojibake|Test::Mojibake> author test.
955              
956             =cut
957              
958             $file{q{xt/author/mojibake.t}} = $test_header . <<'XT_AUTHOR_MOJIBAKE_T';
959             use Test::Mojibake;
960              
961             all_files_encoding_ok( grep { -d } qw( bin lib t xt ) );
962             XT_AUTHOR_MOJIBAKE_T
963              
964             =head2 xt/author/no-tabs.t
965              
966             L<Test::NoTabs|Test::NoTabs> author test.
967              
968             =cut
969              
970             $file{q{xt/author/no-tabs.t}} = $test_header . <<'XT_AUTHOR_NO_TABS_T';
971             use Test::NoTabs;
972              
973             all_perl_files_ok( grep { -d } qw( bin lib t xt ) );
974             XT_AUTHOR_NO_TABS_T
975              
976             =head2 xt/author/pod-no404s.t
977              
978             L<Test::Pod::No404s|Test::Pod::No404s> author test.
979              
980             =cut
981              
982             $file{q{xt/author/pod-no404s.t}} = $test_header . <<'XT_AUTHOR_POD_NO404S_T';
983             if ( exists $ENV{AUTOMATED_TESTING} ) {
984             print "1..0 # SKIP these tests during AUTOMATED_TESTING\n";
985             exit 0;
986             }
987              
988             use Test::Pod::No404s;
989              
990             all_pod_files_ok();
991             XT_AUTHOR_POD_NO404S_T
992              
993             =head2 xt/author/pod-spell.t
994              
995             L<Test::Spelling|Test::Spelling> author test. B<stopwords> are added as stopwords.
996              
997             =cut
998              
999             $file{q{xt/author/pod-spell.t}} = sub {
1000             my ($self) = @_;
1001              
1002             my $content = $test_header . <<'XT_AUTHOR_POD_SPELL_T';
1003             use Test::Spelling 0.12;
1004             use Pod::Wordlist;
1005              
1006             add_stopwords(<DATA>);
1007              
1008             all_pod_files_spelling_ok( grep { -d } qw( bin lib t xt ) );
1009             __DATA__
1010             XT_AUTHOR_POD_SPELL_T
1011              
1012             my @stopwords = grep { defined && !m{ ^ \s* $ }xsm } @{ $self->stopwords };
1013             push @stopwords, split /\s/xms, join q{ }, @{ $self->zilla->authors };
1014              
1015             $content .= join "\n", uniq( sort @stopwords ), q{};
1016              
1017             return $content;
1018             };
1019              
1020             =head2 xt/author/pod-syntax.t
1021              
1022             L<Test::Pod|Test::Pod> author test.
1023              
1024             =cut
1025              
1026             $file{q{xt/author/pod-syntax.t}} = $test_header . <<'XT_AUTHOR_POD_SYNTAX_T';
1027             use Test::Pod 1.26;
1028              
1029             all_pod_files_ok( grep { -d } qw( bin lib t xt) );
1030             XT_AUTHOR_POD_SYNTAX_T
1031              
1032             =head2 xt/author/portability.t
1033              
1034             L<Test::Portability::Files|Test::Portability::Files> author test.
1035              
1036             =cut
1037              
1038             $file{q{xt/author/portability.t}} = $test_header . <<'XT_AUTHOR_PORTABILITY_T';
1039             BEGIN {
1040             if ( !-f 'MANIFEST' ) {
1041             print "1..0 # SKIP No MANIFEST file\n";
1042             exit 0;
1043             }
1044             }
1045              
1046             use Test::Portability::Files;
1047              
1048             options( test_one_dot => 0 );
1049             run_tests();
1050             XT_AUTHOR_PORTABILITY_T
1051              
1052             =head2 xt/author/test-version.t
1053              
1054             L<Test::Version|Test::Version> author test.
1055              
1056             =cut
1057              
1058             $file{q{xt/author/test-version.t}} = $test_header . <<'XT_AUTHOR_TEST_VERSION_T';
1059             use Test::More 0.88;
1060             use Test::Version 0.04 qw( version_all_ok ), {
1061             consistent => 1,
1062             has_version => 1,
1063             is_strict => 0,
1064             multiple => 0,
1065             };
1066              
1067             version_all_ok;
1068             done_testing();
1069             XT_AUTHOR_TEST_VERSION_T
1070              
1071             =head2 xt/release/changes.t
1072              
1073             L<Test::CPAN::Changes|Test::CPAN::Changes> release test.
1074              
1075             =cut
1076              
1077             $file{q{xt/release/changes.t}} = $test_header . <<'XT_RELEASE_CHANGES_T';
1078             use Test::CPAN::Changes;
1079              
1080             changes_ok();
1081             XT_RELEASE_CHANGES_T
1082              
1083             =head2 xt/release/distmeta.t
1084              
1085             L<Test::CPAN::Meta|Test::CPAN::Meta> release test.
1086              
1087             =cut
1088              
1089             $file{q{xt/release/distmeta.t}} = $test_header . <<'XT_RELEASE_DISTMETA_T';
1090             use Test::CPAN::Meta;
1091              
1092             meta_yaml_ok();
1093             XT_RELEASE_DISTMETA_T
1094              
1095             =head2 xt/release/eol.t
1096              
1097             L<Test::EOL|Test::EOL> release test.
1098              
1099             =cut
1100              
1101             $file{q{xt/release/eol.t}} = $test_header . <<'XT_RELEASE_EOL_T';
1102             use Test::EOL;
1103              
1104             all_perl_files_ok( { trailing_whitespace => 1 }, grep { -d } qw( bin lib t xt) );
1105             XT_RELEASE_EOL_T
1106              
1107             =head2 xt/release/kwalitee.t
1108              
1109             L<Test::Kwalitee|Test::Kwalitee> release test.
1110              
1111             =cut
1112              
1113             $file{q{xt/release/kwalitee.t}} = $test_header . <<'XT_RELEASE_KWALITEE_T';
1114             use Test::More 0.88;
1115             use Test::Kwalitee 'kwalitee_ok';
1116              
1117             # Module::CPANTS::Analyse does not find the LICENSE in scripts that don't end in .pl
1118             kwalitee_ok(qw{-has_license_in_source_file -has_abstract_in_pod});
1119              
1120             done_testing();
1121             XT_RELEASE_KWALITEE_T
1122              
1123             =head2 xt/release/manifest.t
1124              
1125             L<Test::DistManifest|Test::DistManifest> release test.
1126              
1127             =cut
1128              
1129             $file{q{xt/release/manifest.t}} = $test_header . <<'XT_RELEASE_MANIFEST_T';
1130             use Test::DistManifest 1.003;
1131              
1132             manifest_ok();
1133             XT_RELEASE_MANIFEST_T
1134              
1135             =head2 xt/release/meta-json.t
1136              
1137             L<Test::CPAN::Meta::JSON|Test::CPAN::Meta::JSON> release test.
1138              
1139             =cut
1140              
1141             $file{q{xt/release/meta-json.t}} = $test_header . <<'XT_RELEASE_META_JSON_T';
1142             use Test::CPAN::Meta::JSON;
1143              
1144             meta_json_ok();
1145             XT_RELEASE_META_JSON_T
1146              
1147             =head2 xt/release/meta-yaml.t
1148              
1149             L<Test::CPAN::Meta|Test::CPAN::Meta> release test.
1150              
1151             =cut
1152              
1153             $file{q{xt/release/meta-yaml.t}} = $test_header . <<'XT_RELEASE_META_YAML_T';
1154             use Test::CPAN::Meta 0.12;
1155              
1156             meta_yaml_ok();
1157             XT_RELEASE_META_YAML_T
1158             }
1159              
1160             __PACKAGE__->meta->make_immutable;
1161              
1162             1;
1163              
1164             __END__
1165              
1166             =head1 USAGE
1167              
1168             The following configuration options are supported:
1169              
1170             =over 4
1171              
1172             =item *
1173              
1174             C<skip> - Defines files to be skipped (not generated).
1175              
1176             =item *
1177              
1178             C<stopwords> - Defines stopwords for the spell checker.
1179              
1180             =item *
1181              
1182             C<travis_ci_ignore_perl> - By default, the generated F<.travis.yml> file
1183             runs on all Perl version known to exist on TravisCI. Use the
1184             C<travis_ci_ignore_perl> option to define Perl versions to not check.
1185              
1186             =back
1187              
1188             =head1 SUPPORT
1189              
1190             =head2 Bugs / Feature Requests
1191              
1192             Please report any bugs or feature requests through the issue tracker
1193             at L<https://github.com/skirmess/Dist-Zilla-PluginBundle-Author-SKIRMESS/issues>.
1194             You will be notified automatically of any progress on your issue.
1195              
1196             =head2 Source Code
1197              
1198             This is open source software. The code repository is available for
1199             public review and contribution under the terms of the license.
1200              
1201             L<https://github.com/skirmess/Dist-Zilla-PluginBundle-Author-SKIRMESS>
1202              
1203             git clone https://github.com/skirmess/Dist-Zilla-PluginBundle-Author-SKIRMESS.git
1204              
1205             =head1 AUTHOR
1206              
1207             Sven Kirmess <sven.kirmess@kzone.ch>
1208              
1209             =head1 COPYRIGHT AND LICENSE
1210              
1211             This software is Copyright (c) 2017 by Sven Kirmess.
1212              
1213             This is free software, licensed under:
1214              
1215             The (two-clause) FreeBSD License
1216              
1217             =head1 SEE ALSO
1218              
1219             L<Dist::Zilla::PluginBundle::Author::SKIRMESS|Dist::Zilla::PluginBundle::Author::SKIRMESS>
1220              
1221             =cut
1222              
1223             # vim: ts=4 sts=4 sw=4 et: syntax=perl