File Coverage

blib/lib/Dist/Zilla/PluginBundle/Author/DBOOK.pm
Criterion Covered Total %
statement 45 47 95.7
branch 12 18 66.6
condition 4 6 66.6
subroutine 5 5 100.0
pod 0 1 0.0
total 66 77 85.7


line stmt bran cond sub pod time code
1             package Dist::Zilla::PluginBundle::Author::DBOOK;
2              
3 3     3   6284860 use Moose;
  3         476620  
  3         23  
4 3     3   20886 use Scalar::Util 'blessed';
  3         8  
  3         232  
5             with 'Dist::Zilla::Role::PluginBundle::Easy',
6             'Dist::Zilla::Role::PluginBundle::Config::Slicer',
7             'Dist::Zilla::Role::PluginBundle::PluginRemover';
8 3     3   652 use namespace::clean;
  3         6268  
  3         27  
9 3     3   1546 use Data::Section -setup;
  3         17068  
  3         29  
10              
11             our $VERSION = 'v1.0.2';
12              
13             sub configure {
14 2     2 0 15 my $self = shift;
15            
16 2         8 my %accepted_installers = map { ($_ => 1) }
  8         41  
17             qw(MakeMaker MakeMaker::Awesome ModuleBuildTiny ModuleBuildTiny::Fallback);
18 2   100     69 my $installer = $self->payload->{installer} // 'MakeMaker';
19 2 50       39 unless (exists $accepted_installers{$installer}) {
20 0         0 die "Invalid installer $installer. Possible installers: " .
21             join(', ', sort keys %accepted_installers) . "\n";
22             }
23 2 100       17 my $install_with_makemaker = ($installer =~ /^ModuleBuild/) ? 0 : 1;
24            
25 2   50     65 my $user = $self->payload->{github_user} // 'Grinnz';
26 2         34 my %githubmeta_config = (issues => 1);
27 2 50       12 $githubmeta_config{user} = $user if length $user;
28 2         25 $self->add_plugins([GithubMeta => \%githubmeta_config]);
29 2         301 $self->add_plugins([ReadmeAnyFromPod => 'Readme_Github' => { type => 'pod', filename => 'README.pod', location => 'root', phase => 'release' }]);
30 2         209 $self->add_plugins([GenerateFile => 'Generate_Contrib' => { filename => 'CONTRIBUTING.md', content => [split /\n/, ${$self->section_data('CONTRIBUTING.md')}] }]);
  2         12  
31 2         11290 $self->add_plugins('MetaProvides::Package', 'Prereqs::FromCPANfile', 'PrereqsFile', 'Git::Contributors');
32 2         373 $self->add_plugins([MetaNoIndex => { directory => [ qw/t xt inc share eg examples/ ] }]);
33            
34 2   50     260 my $irc = $self->payload->{irc} // '';
35 2 50       33 if (length $irc) {
36 0         0 $self->add_plugins([MetaResources => { x_IRC => $irc }]);
37             }
38            
39 2         10 my @from_build = qw(INSTALL LICENSE CONTRIBUTING.md META.json);
40 2 100       20 push @from_build, $install_with_makemaker ? 'Makefile.PL' : 'Build.PL';
41 2         9 my @ignore_files = qw(Build.PL Makefile.PL);
42 2         7 my @dirty_files = qw(dist.ini Changes README.pod);
43            
44             # @Git and versioning
45 2         63 $self->add_plugins(
46             'CheckChangesHasContent',
47             ['Git::Check' => { allow_dirty => \@dirty_files }],
48             'RewriteVersion',
49             [NextRelease => { format => '%-9v %{yyyy-MM-dd HH:mm:ss VVV}d%{ (TRIAL RELEASE)}T' }],
50             [CopyFilesFromRelease => { filename => \@from_build }],
51             ['Git::Commit' => { allow_dirty => [@dirty_files, @from_build], add_files_in => '/', commit_msg => '%v%n%n%c' }],
52             ['Git::Tag' => { tag_format => '%v', tag_message => '%v' }],
53             [BumpVersionAfterRelease => { munge_makefile_pl => 0, munge_build_pl => 0 }],
54             ['Git::Commit' => 'Commit_Version_Bump' => { allow_dirty_match => '^', commit_msg => 'Bump version' }],
55             'Git::Push');
56            
57             # Pod tests
58 2 50       775 if ($self->payload->{pod_tests}) {
59 2         23 $self->add_plugins('PodSyntaxTests');
60 2 50       252 $self->add_plugins('PodCoverageTests') unless $self->payload->{pod_tests} eq 'syntax';
61             }
62            
63             # Report prereqs
64 2 100       214 my $version_extractor = $install_with_makemaker ? 'ExtUtils::MakeMaker' : 'Module::Metadata';
65 2         15 $self->add_plugins(['Test::ReportPrereqs' => { version_extractor => $version_extractor }]);
66            
67 2         293 $self->add_plugins(
68             ['Git::GatherDir' => { exclude_filename => [@ignore_files, @from_build] }],
69             ['Regenerate::AfterReleasers' => { plugins => [$self->name . '/Readme_Github', $self->name . '/CopyFilesFromRelease'] }]);
70             # @Basic, with some modifications
71 2         638 $self->add_plugins(qw/PruneCruft ManifestSkip MetaYAML MetaJSON
72             License ReadmeAnyFromPod ExecDir ShareDir/);
73 2         573 $self->add_plugins([ExecDir => 'ScriptDir' => { dir => 'script' }]);
74 2         206 $self->add_plugins($installer);
75 2         202 $self->add_plugins(qw/RunExtraTests InstallGuide Manifest TestRelease ConfirmRelease/);
76 2 50       397 $self->add_plugins($ENV{FAKE_RELEASE} ? 'FakeRelease' : 'UploadToCPAN');
77             }
78              
79             __PACKAGE__->meta->make_immutable;
80             1;
81              
82             =head1 NAME
83              
84             Dist::Zilla::PluginBundle::Author::DBOOK - A plugin bundle for distributions
85             built by DBOOK
86              
87             =head1 SYNOPSIS
88              
89             [@Author::DBOOK]
90             pod_tests = 1
91             installer = MakeMaker::Awesome
92             MakeMaker::Awesome.test_file[] = t/*.t
93             Git::GatherDir.exclude_filename[0] = bad_file
94             Git::GatherDir.exclude_filename[1] = another_file
95              
96             =head1 DESCRIPTION
97              
98             This is the plugin bundle that DBOOK uses. It is equivalent to:
99              
100             [GithubMeta]
101             issues = 1
102             user = Grinnz
103            
104             [ReadmeAnyFromPod / Readme_Github]
105             type = pod
106             filename = README.pod
107             location = root
108             phase = release
109            
110             [GenerateFile / Generate_Contrib]
111             filename = CONTRIBUTING.md
112             content = ...
113            
114             [MetaProvides::Package]
115             [Prereqs::FromCPANfile]
116             [PrereqsFile]
117             [Git::Contributors]
118             [MetaNoIndex]
119             directory = t
120             directory = xt
121             directory = inc
122             directory = share
123             directory = eg
124             directory = examples
125            
126             [CheckChangesHasContent]
127             [Git::Check]
128             allow_dirty = dist.ini
129             allow_dirty = Changes
130             allow_dirty = README.pod
131             [RewriteVersion]
132             [NextRelease]
133             format = %-9v %{yyyy-MM-dd HH:mm:ss VVV}d%{ (TRIAL RELEASE)}T
134             [CopyFilesFromRelease]
135             filename = INSTALL
136             filename = LICENSE
137             filename = CONTRIBUTING.md
138             filename = META.json
139             filename = Makefile.PL
140             [Git::Commit]
141             add_files_in = /
142             allow_dirty = dist.ini
143             allow_dirty = Changes
144             allow_dirty = README.pod
145             allow_dirty = INSTALL
146             allow_dirty = LICENSE
147             allow_dirty = CONTRIBUTING.md
148             allow_dirty = META.json
149             allow_dirty = Makefile.PL
150             commit_msg = %v%n%n%c
151             [Git::Tag]
152             tag_format = %v
153             tag_message = %v
154             [BumpVersionAfterRelease]
155             munge_makefile_pl = 0
156             munge_build_pl = 0
157             [Git::Commit / Commit_Version_Bump]
158             allow_dirty_match = ^
159             commit_msg = Bump version
160             [Git::Push]
161            
162             [Test::ReportPrereqs]
163             [Git::GatherDir]
164             exclude_filename = INSTALL
165             exclude_filename = LICENSE
166             exclude_filename = CONTRIBUTING.md
167             exclude_filename = META.json
168             exclude_filename = Makefile.PL
169             exclude_filename = Build.PL
170             [Regenerate::AfterReleasers]
171             plugin = Readme_Github
172             plugin = CopyFilesFromRelease
173             [PruneCruft]
174             [ManifestSkip]
175             [MetaYAML]
176             [MetaJSON]
177             [License]
178             [ReadmeAnyFromPod]
179             [ExecDir]
180             [ExecDir / ScriptDir]
181             dir = script
182             [ShareDir]
183             [MakeMaker]
184             [RunExtraTests]
185             [InstallGuide]
186             [Manifest]
187             [TestRelease]
188             [ConfirmRelease]
189             [UploadToCPAN]
190              
191             This bundle assumes that your git repo has the following: a L<cpanfile>,
192             F<prereqs.json>, or F<prereqs.yml> with the dist's prereqs, a F<Changes>
193             populated for the current version (see L<Dist::Zilla::Plugin::NextRelease>),
194             and a F<.gitignore> including C</Name-Of-Dist-*> but not
195             C<Makefile.PL>/C<Build.PL> or C<META.json>.
196              
197             To faciliate building the distribution for testing or installation without
198             L<Dist::Zilla>, and provide important information about the distribution in
199             the repository, several files can be copied to the repository from the build
200             by running L<dzil regenerate|Dist::Zilla::App::Command::regenerate>, and are
201             copied and committed automatically on release. These files are:
202             C<CONTRIBUTING.md>, C<INSTALL>, C<LICENSE>, C<Makefile.PL>/C<Build.PL>, and
203             C<META.json>. The file C<README.pod> will also be generated in the repository
204             (but not the build) by C<dzil regenerate> and C<dzil release>.
205              
206             To test releasing, set the env var C<FAKE_RELEASE=1> to run everything except
207             the upload to CPAN.
208              
209             $ FAKE_RELEASE=1 dzil release
210              
211             =head1 OPTIONS
212              
213             This bundle composes the L<Dist::Zilla::Role::PluginBundle::Config::Slicer>
214             role, so options for any included plugin may be specified in that format. It
215             also composes L<Dist::Zilla::Role::PluginBundle::PluginRemover> so that plugins
216             may be removed. Additionally, the following options are provided.
217              
218             =head2 github_user
219              
220             github_user = gitster
221              
222             Set the user whose repository should be linked in metadata. Defaults to
223             C<Grinnz>, change this when the main repository is elsewhere. Set to an empty
224             string value to use the GitHub remote URL as found in the local repository, as
225             L<Dist::Zilla::Plugin::GithubMeta> does by default.
226              
227             =head2 installer
228              
229             installer = MakeMaker::Awesome
230             MakeMaker::Awesome.WriteMakefile_arg[] = (clean => { FILES => 'autogen.dat' })
231             MakeMaker::Awesome.delimiter = |
232             MakeMaker::Awesome.footer[00] = |{
233             MakeMaker::Awesome.footer[01] = | ...
234             MakeMaker::Awesome.footer[20] = |}
235              
236             installer = ModuleBuildTiny
237             ModuleBuildTiny.version_method = installed
238              
239             Set the installer plugin to use. Allowed installers are
240             L<MakeMaker|Dist::Zilla::Plugin::MakeMaker>,
241             L<MakeMaker::Awesome|Dist::Zilla::Plugin::MakeMaker::Awesome>,
242             L<ModuleBuildTiny|Dist::Zilla::Plugin::ModuleBuildTiny>, and
243             L<ModuleBuildTiny::Fallback|Dist::Zilla::Plugin::ModuleBuildTiny::Fallback>.
244             The default is C<MakeMaker>. Options for the selected installer can be
245             specified using config slicing.
246              
247             =head2 irc
248              
249             irc = irc://irc.perl.org/#distzilla
250              
251             Set the x_IRC resource metadata using L<Dist::Zilla::Plugin::MetaResources>.
252              
253             =head2 pod_tests
254              
255             pod_tests = 1
256              
257             Set to a true value to add L<Dist::Zilla::Plugin::PodSyntaxTests> and
258             L<Dist::Zilla::Plugin::PodCoverageTests>. Set to C<syntax> to only add the
259             syntax tests.
260              
261             =head1 BUGS
262              
263             Report any issues on the public bugtracker.
264              
265             =head1 AUTHOR
266              
267             Dan Book, C<dbook@cpan.org>
268              
269             =head1 COPYRIGHT AND LICENSE
270              
271             Copyright 2015, Dan Book.
272              
273             This library is free software; you may redistribute it and/or modify it under
274             the terms of the Artistic License version 2.0.
275              
276             =head1 SEE ALSO
277              
278             L<Dist::Zilla>, L<cpanfile>, L<Dist::Zilla::MintingProfile::Author::DBOOK>
279              
280             =cut
281              
282             __DATA__
283             __[ CONTRIBUTING.md ]__
284             # HOW TO CONTRIBUTE
285              
286             Thank you for considering contributing to this distribution. This file
287             contains instructions that will help you work with the source code.
288              
289             The distribution is managed with [Dist::Zilla](https://metacpan.org/pod/Dist::Zilla).
290             This means that many of the usual files you might expect are not in the
291             repository, but are generated at release time. Some generated files are kept
292             in the repository as a convenience (e.g. Build.PL/Makefile.PL and META.json).
293              
294             Generally, **you do not need Dist::Zilla to contribute patches**. You may need
295             Dist::Zilla to create a tarball. See below for guidance.
296              
297             ## Getting dependencies
298              
299             If you have App::cpanminus 1.6 or later installed, you can use
300             [cpanm](https://metacpan.org/pod/cpanm) to satisfy dependencies like this:
301              
302             $ cpanm --installdeps --with-develop .
303              
304             You can also run this command (or any other cpanm command) without installing
305             App::cpanminus first, using the fatpacked `cpanm` script via curl or wget:
306              
307             $ curl -L https://cpanmin.us | perl - --installdeps --with-develop .
308             $ wget -qO - https://cpanmin.us | perl - --installdeps --with-develop .
309              
310             Otherwise, look for either a `cpanfile` or `META.json` file for a list of
311             dependencies to satisfy.
312              
313             ## Running tests
314              
315             You can run tests directly using the `prove` tool:
316              
317             $ prove -l
318             $ prove -lv t/some_test_file.t
319              
320             For most of my distributions, `prove` is entirely sufficient for you to test
321             any patches you have. I use `prove` for 99% of my testing during development.
322              
323             ## Code style and tidying
324              
325             Please try to match any existing coding style. If there is a `.perltidyrc`
326             file, please install Perl::Tidy and use perltidy before submitting patches.
327              
328             ## Installing and using Dist::Zilla
329              
330             [Dist::Zilla](https://metacpan.org/pod/Dist::Zilla) is a very powerful
331             authoring tool, optimized for maintaining a large number of distributions with
332             a high degree of automation, but it has a large dependency chain, a bit of a
333             learning curve and requires a number of author-specific plugins.
334              
335             To install it from CPAN, I recommend one of the following approaches for the
336             quickest installation:
337              
338             # using CPAN.pm, but bypassing non-functional pod tests
339             $ cpan TAP::Harness::Restricted
340             $ PERL_MM_USE_DEFAULT=1 HARNESS_CLASS=TAP::Harness::Restricted cpan Dist::Zilla
341              
342             # using cpanm, bypassing *all* tests
343             $ cpanm -n Dist::Zilla
344              
345             In either case, it's probably going to take about 10 minutes. Go for a walk,
346             go get a cup of your favorite beverage, take a bathroom break, or whatever.
347             When you get back, Dist::Zilla should be ready for you.
348              
349             Then you need to install any plugins specific to this distribution:
350              
351             $ dzil authordeps --missing | cpanm
352              
353             You can use Dist::Zilla to install the distribution's dependencies if you
354             haven't already installed them with cpanm:
355              
356             $ dzil listdeps --missing --develop | cpanm
357              
358             You can instead combine these two steps into one command by installing
359             Dist::Zilla::App::Command::installdeps then running:
360              
361             $ dzil installdeps
362              
363             Once everything is installed, here are some dzil commands you might try:
364              
365             $ dzil build
366             $ dzil test
367             $ dzil regenerate
368              
369             You can learn more about Dist::Zilla at http://dzil.org/
370              
371             ## Other notes
372              
373             This distribution maintains the generated `META.json` and either `Makefile.PL`
374             or `Build.PL` in the repository. This allows two things:
375             [Travis CI](https://travis-ci.org/) can build and test the distribution without
376             requiring Dist::Zilla, and the distribution can be installed directly from
377             Github or a local git repository using `cpanm` for testing (again, not
378             requiring Dist::Zilla).
379              
380             $ cpanm git://github.com/Author/Distribution-Name.git
381             $ cd Distribution-Name; cpanm .
382              
383             Contributions are preferred in the form of a Github pull request. See
384             [Using pull requests](https://help.github.com/articles/using-pull-requests/)
385             for further information. You can use the Github issue tracker to report issues
386             without an accompanying patch.
387              
388             # CREDITS
389              
390             This file was adapted from an initial `CONTRIBUTING.mkdn` file from David
391             Golden under the terms of the [CC0](https://creativecommons.org/share-your-work/public-domain/cc0/), with inspiration from the
392             contributing documents from [Dist::Zilla::Plugin::Author::KENTNL::CONTRIBUTING](https://metacpan.org/pod/Dist::Zilla::Plugin::Author::KENTNL::CONTRIBUTING)
393             and [Dist::Zilla::PluginBundle::Author::ETHER](https://metacpan.org/pod/Dist::Zilla::PluginBundle::Author::ETHER).
394             __END__