File Coverage

lib/Dist/Zilla/PluginBundle/Author/RUSSOZ.pm
Criterion Covered Total %
statement 18 47 38.3
branch 0 20 0.0
condition 0 3 0.0
subroutine 6 13 46.1
pod 0 1 0.0
total 24 84 28.5


line stmt bran cond sub pod time code
1             package Dist::Zilla::PluginBundle::Author::RUSSOZ;
2              
3 1     1   930 use strict;
  1         2  
  1         28  
4 1     1   4 use warnings;
  1         2  
  1         45  
5              
6             # ABSTRACT: configure Dist::Zilla like RUSSOZ
7             our $VERSION = '0.024'; # VERSION
8              
9 1     1   5 use Moose 0.99;
  1         14  
  1         6  
10 1     1   5567 use namespace::autoclean 0.09;
  1         17  
  1         5  
11 1     1   348 use version;
  1         1350  
  1         4  
12              
13             with 'Dist::Zilla::Role::PluginBundle::Easy';
14              
15             has fake => (
16             is => 'ro',
17             isa => 'Bool',
18             lazy => 1,
19             default => sub {
20             return 1 if exists $ENV{FAKE};
21             ( defined $_[0]->payload->{fake} and $_[0]->payload->{fake} == 1 )
22             ? 1
23             : 0;
24             },
25             );
26              
27             has version => (
28             is => 'ro',
29             isa => 'Str',
30             lazy => 1,
31             default => sub { return ( $_[0]->payload->{version} or 'none' ) },
32             );
33              
34             has _version_types => (
35             is => 'ro',
36             isa => 'HashRef[CodeRef]',
37             lazy => 1,
38             builder => '_build_version_types',
39             );
40              
41             sub _build_version_types {
42 0     0     my $self = shift;
43             return {
44       0     'none' => sub { },
45 0     0     'auto' => sub { $self->add_plugins('AutoVersion') },
46 0     0     'gitnext' => sub { $self->add_plugins('Git::NextVersion') },
47 0     0     'module' => sub { $self->add_plugins('VersionFromMainModule') },
48 0           };
49             }
50              
51             sub _add_version {
52 0     0     my $self = shift;
53 0           my $spec = $self->version;
54 0 0         return unless exists $self->_version_types->{$spec};
55 0           $self->_version_types->{$spec}->();
56 0           return;
57             }
58              
59             has auto_prereqs => (
60             is => 'ro',
61             isa => 'Bool',
62             lazy => 1,
63             default => 1,
64             );
65              
66             has use_no404 => (
67             is => 'ro',
68             isa => 'Bool',
69             lazy => 1,
70             default => sub {
71             ( defined $_[0]->payload->{use_no404}
72             and $_[0]->payload->{use_no404} == 1 ) ? 1 : 0;
73             },
74             );
75              
76             has git => (
77             is => 'ro',
78             isa => 'Bool',
79             lazy => 1,
80             default => sub {
81             ( defined $_[0]->payload->{git} and $_[0]->payload->{git} == 0 )
82             ? 0
83             : 1;
84             },
85             );
86              
87             has github => (
88             is => 'ro',
89             isa => 'Bool',
90             lazy => 1,
91             default => sub {
92             return 0 unless $_[0]->git;
93             ( defined $_[0]->payload->{github} and $_[0]->payload->{github} == 0 )
94             ? 0
95             : 1;
96             },
97             );
98              
99             has task_weaver => (
100             is => 'ro',
101             isa => 'Bool',
102             lazy => 1,
103             default => sub {
104             ( defined $_[0]->payload->{task_weaver}
105             and $_[0]->payload->{task_weaver} == 1 ) ? 1 : 0;
106             },
107             );
108              
109             has signature => (
110             is => 'ro',
111             isa => 'Bool',
112             lazy => 1,
113             default => sub {
114             ( defined $_[0]->payload->{signature}
115             and $_[0]->payload->{signature} == 0 ) ? 0 : 1;
116             },
117             );
118              
119             has report => (
120             is => 'ro',
121             isa => 'Bool',
122             lazy => 1,
123             default => sub {
124             ( defined $_[0]->payload->{report} and $_[0]->payload->{report} == 1 )
125             ? 1
126             : 0;
127             },
128             );
129              
130             sub configure {
131 0     0 0   my $self = shift;
132              
133             # Basic sans upload
134 0           $self->add_plugins(
135             'GatherDir', 'PruneCruft', 'ManifestSkip', 'MetaYAML',
136             'License', 'ExecDir', 'ShareDir', 'MakeMaker',
137             'Manifest', 'TestRelease', 'ConfirmRelease',
138             );
139 0 0         $self->fake
140             ? $self->add_plugins('FakeRelease')
141             : $self->add_plugins('UploadToCPAN');
142              
143 0           $self->_add_version();
144              
145 0 0         $self->add_plugins('OurPkgVersion') unless $self->version eq 'module';
146 0           $self->add_plugins(
147             'MetaJSON',
148             'ReadmeFromPod',
149             'InstallGuide',
150             'PerlTidy',
151             [
152             'GitFmtChanges' => {
153             max_age => 365,
154             tag_regexp => q{^.*$},
155             file_name => q{Changes},
156             log_format => q{short},
157             }
158             ],
159             );
160              
161 0 0         $self->add_plugins('GithubMeta') if $self->github;
162 0 0         $self->add_plugins('AutoPrereqs') if $self->auto_prereqs;
163              
164 0 0         if ( $self->task_weaver ) {
165 0           $self->add_plugins('TaskWeaver');
166             }
167             else {
168 0           $self->add_plugins( 'ReportVersions::Tiny',
169             [ 'PodWeaver' => { config_plugin => '@Author::RUSSOZ' }, ],
170             );
171              
172 0           $self->add_plugins('Test::UseAllModules');
173 0           $self->add_bundle( 'TestingMania' =>
174             { disable => [ 'Test::CPAN::Changes', 'Test::Synopsis', ], } );
175             $self->add_plugins('Test::Pod::No404s')
176 0 0 0       if ( $self->use_no404 || $ENV{NO404} );
177             }
178              
179 0 0         $self->add_plugins('Signature') if $self->signature;
180 0 0         $self->add_plugins('ReportPhase') if $self->report;
181 0 0         $self->add_bundle('Git') if $self->git;
182              
183 0           $self->add_plugins('ExtraTests');
184              
185 0           return;
186             }
187              
188             __PACKAGE__->meta->make_immutable;
189 1     1   709 no Moose;
  1         2  
  1         8  
190              
191             1;
192              
193             __END__
194              
195             =pod
196              
197             =encoding UTF-8
198              
199             =head1 NAME
200              
201             Dist::Zilla::PluginBundle::Author::RUSSOZ - configure Dist::Zilla like RUSSOZ
202              
203             =head1 VERSION
204              
205             version 0.024
206              
207             =head1 SYNOPSIS
208              
209             # in dist.ini
210             [@Author::RUSSOZ]
211             ; fake = 0
212             ; version = none | auto | gitnext
213             ; auto_prereqs = 1
214             ; github = 1
215             ; use_no404 = 0
216             ; task_weaver = 0
217             ; signature = 1
218             ; report = 0
219              
220             =head1 DESCRIPTION
221              
222             C<Dist::Zilla::PluginBundle::Author::RUSSOZ> provides shorthand for
223             a L<Dist::Zilla> configuration approximately like:
224              
225             [@Basic]
226              
227             [MetaJSON]
228             [ReadmeFromPod]
229             [InstallGuide]
230             [GitFmtChanges]
231             max_age = 365
232             tag_regexp = ^.*$
233             file_name = Changes
234             log_format = short
235              
236             [OurPkgVersion]
237             [GithubMeta] ; if github = 1
238             [AutoPrereqs] ; unless auto_prereqs = 0
239              
240             [ReportVersions::Tiny]
241             [PodWeaver]
242             config_plugin = @Author::RUSSOZ
243              
244             ; if task_weaver =1
245             [TaskWeaver]
246              
247             ; else (task_weaver = 0)
248             [@TestingMania]
249             disable = Test::CPAN::Changes, SynopsisTests
250             ; [Test::Pod::No404]
251              
252             ; endif
253              
254             [Signature] ; if signature = 1
255             [ReportPhase] ; if report = 1
256             [@Git]
257              
258             =head1 NAME
259              
260             Dist::Zilla::PluginBundle::Author::RUSSOZ - configure Dist::Zilla like RUSSOZ
261              
262             =head1 VERSION
263              
264             version 0.024
265              
266             =head1 TASK CONTENTS
267              
268             =head1 USAGE
269              
270             Just put C<[@Author::RUSSOZ]> in your F<dist.ini>. You can supply the following
271             options:
272              
273             =for :list * version
274             How to handle version numbering. Possible values: none,
275             auto (will use L<Dist::Zilla::Plugin::AutoVersion>),
276             gitnext (will use Dist::Zilla::Plugin::Git::NextVersion).
277             Default = none.
278             * auto_prereqs
279             Whether the module will use C<AutoPrereqs> or not. Default = 1.
280             * github
281             If using github, enable C<[GithubMeta]>. Default = 1.
282             * use_no404
283             Whether to use C<[Test::Pod::No404]> in the distribution. Default = 0.
284             * task_weaver
285             Set to 1 if this is a C<Task::> distribution. It will enable C<[TaskWeaver]>
286             while disabling C<[PodWeaver]> and all release tests. Default = 0.
287             * fake
288             Set to 1 if this is a fake release. It will disable [UploadToCPAN] and
289             enable [FakeRelease]. It can also be enabled by setting the environemnt
290             variable C<FAKE>. Default = 0.
291             * signature
292             Whether to GPG sign the module or not. Default = 1.
293             * report
294             Whether to report the Dist::Zilla building phases. Default = 0.
295              
296             =for Pod::Coverage configure
297              
298             =head1 SEE ALSO
299              
300             C<< L<Dist::Zilla> >>
301              
302             =head1 ACKNOWLEDGMENTS
303              
304             Much of the first implementation was shamelessly copied from
305             C<Dist::Zilla::PluginBundle::Author::DOHERTY>.
306              
307             =head1 AUTHOR
308              
309             Alexei Znamensky <russoz@cpan.org>
310              
311             =head1 COPYRIGHT AND LICENSE
312              
313             This software is copyright (c) 2011 - 2017 by Alexei Znamensky.
314              
315             This is free software; you can redistribute it and/or modify it under
316             the same terms as the Perl 5 programming language system itself.
317              
318             =head1 AUTHOR
319              
320             Alexei Znamensky <russoz@cpan.org>
321              
322             =head1 COPYRIGHT AND LICENSE
323              
324             This software is copyright (c) 2011 - 2017 by Alexei Znamensky.
325              
326             This is free software; you can redistribute it and/or modify it under
327             the same terms as the Perl 5 programming language system itself.
328              
329             =cut