File Coverage

blib/lib/Dist/Zilla/PluginBundle/Author/CSSON.pm
Criterion Covered Total %
statement 10 12 83.3
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 14 16 87.5


line stmt bran cond sub pod time code
1 1     1   15350 use 5.10.1;
  1         3  
  1         37  
2 1     1   4 use strict;
  1         2  
  1         28  
3 1     1   3 use warnings;
  1         1  
  1         67  
4              
5             package Dist::Zilla::PluginBundle::Author::CSSON;
6              
7             our $VERSION = '0.1000'; # VERSION
8              
9 1     1   890 use Moose;
  0            
  0            
10             use MooseX::AttributeShortcuts;
11             use Types::Standard qw/Str Bool/;
12             with 'Dist::Zilla::Role::PluginBundle::Easy';
13             with 'Dist::Zilla::Role::PluginBundle::PluginRemover';
14             with 'Dist::Zilla::Role::PluginBundle::Config::Slicer';
15              
16             use namespace::autoclean;
17             use List::AllUtils 'none';
18             use Config::INI;
19              
20             has installer => (
21             is => 'rw',
22             isa => Str,
23             lazy => 1,
24             default => sub { shift->payload->{'installer'} || 'ModuleBuildTiny' },
25             );
26             has is_private => (
27             is => 'rw',
28             isa => Bool,
29             required => 1,
30             default => 0,
31             );
32             has is_task => (
33             is => 'rw',
34             isa => Bool,
35             default => 0,
36             );
37             has weaver_config => (
38             is => 'rw',
39             isa => Str,
40             default => '@Iller',
41             );
42             has homepage => (
43             is => 'rw',
44             isa => Str,
45             builder => 1,
46             );
47              
48             sub _build_homepage {
49             my $distname = Config::INI::Reader->read_file('dist.ini')->{'_'}{'name'};
50             return sprintf 'https://metacpan.org/release/' . $distname;
51             }
52              
53             sub build_file {
54             my $self = shift;
55              
56             return $self->installer =~ m/MakeMaker/ ? 'Makefile.PL' : 'Build.PL';
57             }
58              
59             sub configure {
60             my $self = shift;
61              
62             my @possible_installers = qw/MakeMaker MakeMaker::IncShareDir ModuleBuild ModuleBuildTiny/;
63             if(none { $self->installer eq $_ } @possible_installers) {
64             die sprintf '%s is not one of the possible installers (%s)', $self->installer, join ', ' => @possible_installers;
65             }
66              
67             $self->add_plugins(
68             ['Git::GatherDir', { exclude_filename => [
69             'META.json',
70             'LICENSE',
71             'README.md',
72             $self->build_file,
73             ] },
74             ],
75             ['CopyFilesFromBuild', { copy => [
76             'META.json',
77             'LICENSE',
78             $self->build_file,
79             ] },
80             ],
81             ['PodnameFromFilename'],
82             ['ReversionOnRelease', { prompt => 1 } ],
83             ['OurPkgVersion'],
84             ['NextRelease', { format => '%v %{yyyy-MM-dd HH:mm:ss VVV}d' } ],
85             ['PreviousVersion::Changelog'],
86              
87             ['NextVersion::Semantic', { major => '',
88             minor => "API Changes, New Features, Enhancements",
89             revision => "Revision, Bug Fixes, Documentation, Meta",
90             format => '%d.%02d%02d',
91             numify_version => 0,
92             }
93             ],
94             (
95             $self->is_task ?
96             ['TaskWeaver']
97             :
98             ['PodWeaver', { config_plugin => $self->weaver_config } ]
99             ),
100             ['Git::Check', { allow_dirty => [
101             'dist.ini',
102             'Changes',
103             'META.json',
104             'README.md',
105             $self->build_file,
106             ] },
107             ],
108             (
109             $self->is_private ?
110             ()
111             :
112             ['GithubMeta', { issues => 1, homepage => $self->homepage } ]
113             ),
114             ['ReadmeAnyFromPod', { filename => 'README.md',
115             type => 'markdown',
116             location => 'root',
117             }
118             ],
119             ['MetaNoIndex', { directory => [qw/t xt inc share eg examples/] } ],
120             ['Prereqs::FromCPANfile'],
121             [ $self->installer ],
122             ['MetaJSON'],
123             ['ContributorsFromGit'],
124              
125             ['Test::NoTabs'],
126             ['Test::EOL'],
127             ['Test::EOF'],
128             ['PodSyntaxTests'],
129             ['Test::Kwalitee::Extra'],
130              
131             ['MetaYAML'],
132             ['License'],
133             ['ExtraTests'],
134              
135             ['ShareDir'],
136             ['ExecDir'],
137             ['Manifest'],
138             ['ManifestSkip'],
139             ['CheckChangesHasContent'],
140             ['TestRelease'],
141             ['ConfirmRelease'],
142             [ $ENV{'FAKE_RELEASE'} ? 'FakeRelease' : $self->is_private ? 'UploadToStratopan' : 'UploadToCPAN' ],
143             ['Git::Tag', { tag_format => '%v',
144             tag_message => ''
145             }
146             ],
147             ['Git::Push', { remotes_must_exist => 1 } ],
148             );
149             }
150              
151             1;
152              
153             # ABSTRACT: Dist::Zilla like Csson
154              
155             __END__
156              
157             =pod
158              
159             =encoding UTF-8
160              
161             =head1 NAME
162              
163             Dist::Zilla::PluginBundle::Author::CSSON - Dist::Zilla like Csson
164              
165             =head1 VERSION
166              
167             version 0.1000
168              
169             =head1 SYNOPSIS
170              
171             ; in dist.ini
172             [@Author::CSSON]
173              
174             =head1 DESCRIPTION
175              
176             It is about the same as a dist.ini with these plugins specified:
177              
178             [Git::GatherDir]
179             exclude_filename = Build.PL ; or equivalent
180             exclude_filename = META.json
181             exclude_filename = LICENSE
182             exclude_filename = README.md
183              
184             [CopyFilesFromBuild]
185             copy = META.json
186             copy = LICENSE
187             copy = Build.PL ; or equivalent
188              
189             [ReversionOnRelease]
190             prompt = 1
191              
192             [OurPkgVersion]
193              
194             [NextRelease]
195             format = %v %{yyyy-MM-dd HH:mm:ss VVV}d
196              
197             [PreviousVersion::Changelog]
198             [NextVersion::Semantic]
199             major =
200             minor = API Changes, New Features, Enhancements
201             revision = Revision, Bug Fixes, Documentation, Meta
202             format = %d.%02d%02d
203             numify_version = 0
204              
205             [Git::Check]
206             allow_dirty = dist.ini
207             allow_dirty = Changes
208             allow_dirty = META.json
209             allow_dirty = README.md
210             allow_dirty = Build.PL ; or equivalent
211              
212             ; if is_private == 0, see below
213             [GithubMeta]
214             issues = 1
215             homepage = http://metacpan.org/release/dist-name
216              
217             [PodWeaver]
218             config_bundle = @Author::CSSON
219              
220             [ReadmeAnyFromPod]
221             filename = README.md
222             type = markdown
223             location = root
224              
225             [MetaNoIndex]
226             directory = t
227             directory = xt
228             directory = inc
229             directory = share
230             directory = eg
231             directory = examples
232              
233             [Prereqs::FromCPANfile]
234              
235             ; settable, see installer below
236             [ModuleBuildTiny]
237              
238             [MetaJSON]
239              
240             [ContributorsFromGit]
241              
242             [Test::NoTabs]
243             [Test::EOL]
244             [Test::EOF]
245             [PodSyntaxTests]
246             [Test::Kwalitee::Extra]
247              
248             [MetaYAML]
249              
250             [License]
251              
252             [ExtraTests]
253              
254             [ShareDir]
255              
256             [Manifest]
257              
258             [ManifestSkip]
259              
260             [CheckChangesHasContent]
261              
262             [TestRelease]
263              
264             [ConfirmRelease]
265              
266             ; depends on is_private, see below
267             [UploadToCPAN or UploadToStratopan]
268              
269             [Git::Commit]
270             commit_msg = %v
271             allow_dirty = dist.ini
272             allow_dirty = Changes
273             allow_dirty = META.json
274             allow_dirty = README.md
275             allow_dirty = Build.PL
276              
277             [Git::Tag]
278             tag_format = %v
279             tag_message =
280              
281             [Git::Push]
282             remotes_must_exist = 0
283              
284             =head1 OPTIONS
285              
286             =head2 homepage
287              
288             String. Default is the release's page on metacpan.org. Not set if C<is_private> is true.
289              
290             =head2 installer
291              
292             String. Default is L<ModuleBuildTiny|Dist::Zilla::ModuleBuildTiny>.
293              
294             =head2 is_private
295              
296             Boolean. Default is B<0>.
297              
298             If false: Adds github repository to meta, uses github as issue tracker, and includes L<UploadToCPAN|Dist::Zilla::Plugin::UploadToCPAN>.
299              
300             If true: Adds no github information, and includes L<UploadToStratopan|Dist::Zilla::Plugin::UploadToStratopan>.
301              
302             To remove L<UploadToStratopan|Dist::Zilla::Plugin::UploadToStratopan>, add this to your dist.ini:
303              
304             -remove = UploadToStratopan
305              
306             To use L<UploadToStratopan|Dist::Zilla::Plugin::UploadToStratopan>, you need to specify C<repo> and C<stack> in dist.ini:
307              
308             UploadToStratopan.repo = ...
309             UploadToStratopan.stack = ...
310              
311             =head2 is_task
312              
313             Boolean. Default is B<0>.
314              
315             If true, L<Dist::Zilla::Plugin::TaskWeaver> is included instead of L<Dist::Zilla::Plugin::PodWeaver>.
316              
317             =head2 weaver_config
318              
319             String. Default is L<@Author::CSSON|Pod::Weaver::PluginBundle::Author::CSSON>.
320              
321             =head1 SEE ALSO
322              
323             L<Dist::Zilla>
324              
325             L<Pod::Weaver::PluginBundle::Author::CSSON>
326              
327             =head1 AUTHOR
328              
329             Erik Carlsson <info@code301.com>
330              
331             =head1 COPYRIGHT AND LICENSE
332              
333             This software is copyright (c) 2015 by Erik Carlsson <info@code301.com>.
334              
335             This is free software; you can redistribute it and/or modify it under
336             the same terms as the Perl 5 programming language system itself.
337              
338             =cut