File Coverage

lib/Dist/Zilla/PluginBundle/Author/RUSSOZ.pm
Criterion Covered Total %
statement 18 48 37.5
branch 0 20 0.0
condition 0 3 0.0
subroutine 6 13 46.1
pod 0 1 0.0
total 24 85 28.2


line stmt bran cond sub pod time code
1             package Dist::Zilla::PluginBundle::Author::RUSSOZ;
2              
3 1     1   1308 use strict;
  1         3  
  1         27  
4 1     1   4 use warnings;
  1         2  
  1         49  
5              
6             # ABSTRACT: configure Dist::Zilla like RUSSOZ
7             our $VERSION = '0.026'; # VERSION
8              
9 1     1   6 use Moose 0.99;
  1         20  
  1         8  
10 1     1   6441 use namespace::autoclean 0.09;
  1         27  
  1         24  
11 1     1   489 use version;
  1         1469  
  1         5  
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( 'Test::ReportPrereqs',
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('Git::Contributors');
184              
185 0           $self->add_plugins('ExtraTests');
186              
187 0           return;
188             }
189              
190             __PACKAGE__->meta->make_immutable;
191 1     1   696 no Moose;
  1         2  
  1         7  
192              
193             1;
194              
195             __END__
196              
197             =pod
198              
199             =encoding UTF-8
200              
201             =head1 NAME
202              
203             Dist::Zilla::PluginBundle::Author::RUSSOZ - configure Dist::Zilla like RUSSOZ
204              
205             =head1 VERSION
206              
207             version 0.026
208              
209             =head1 SYNOPSIS
210              
211             # in dist.ini
212             [@Author::RUSSOZ]
213             ; fake = 0
214             ; version = none | auto | gitnext
215             ; auto_prereqs = 1
216             ; github = 1
217             ; use_no404 = 0
218             ; task_weaver = 0
219             ; signature = 1
220             ; report = 0
221              
222             =head1 DESCRIPTION
223              
224             C<Dist::Zilla::PluginBundle::Author::RUSSOZ> provides shorthand for
225             a L<Dist::Zilla> configuration approximately like:
226              
227             [@Basic]
228              
229             [MetaJSON]
230             [ReadmeFromPod]
231             [InstallGuide]
232             [GitFmtChanges]
233             max_age = 365
234             tag_regexp = ^.*$
235             file_name = Changes
236             log_format = short
237              
238             [OurPkgVersion]
239             [GithubMeta] ; if github = 1
240             [AutoPrereqs] ; unless auto_prereqs = 0
241              
242             [ReportVersions::Tiny]
243             [PodWeaver]
244             config_plugin = @Author::RUSSOZ
245              
246             ; if task_weaver =1
247             [TaskWeaver]
248              
249             ; else (task_weaver = 0)
250             [@TestingMania]
251             disable = Test::CPAN::Changes, SynopsisTests
252             ; [Test::Pod::No404]
253              
254             ; endif
255              
256             [Signature] ; if signature = 1
257             [ReportPhase] ; if report = 1
258             [@Git]
259              
260             =head1 NAME
261              
262             Dist::Zilla::PluginBundle::Author::RUSSOZ - configure Dist::Zilla like RUSSOZ
263              
264             =head1 VERSION
265              
266             version 0.026
267              
268             =head1 TASK CONTENTS
269              
270             =head1 USAGE
271              
272             Just put C<[@Author::RUSSOZ]> in your F<dist.ini>. You can supply the following
273             options:
274              
275             =for :list * version
276             How to handle version numbering. Possible values: none,
277             auto (will use L<Dist::Zilla::Plugin::AutoVersion>),
278             gitnext (will use Dist::Zilla::Plugin::Git::NextVersion).
279             Default = none.
280             * auto_prereqs
281             Whether the module will use C<AutoPrereqs> or not. Default = 1.
282             * github
283             If using github, enable C<[GithubMeta]>. Default = 1.
284             * use_no404
285             Whether to use C<[Test::Pod::No404]> in the distribution. Default = 0.
286             * task_weaver
287             Set to 1 if this is a C<Task::> distribution. It will enable C<[TaskWeaver]>
288             while disabling C<[PodWeaver]> and all release tests. Default = 0.
289             * fake
290             Set to 1 if this is a fake release. It will disable [UploadToCPAN] and
291             enable [FakeRelease]. It can also be enabled by setting the environemnt
292             variable C<FAKE>. Default = 0.
293             * signature
294             Whether to GPG sign the module or not. Default = 1.
295             * report
296             Whether to report the Dist::Zilla building phases. Default = 0.
297              
298             =for Pod::Coverage configure
299              
300             =head1 SEE ALSO
301              
302             C<< L<Dist::Zilla> >>
303              
304             =head1 ACKNOWLEDGMENTS
305              
306             Much of the first implementation was shamelessly copied from
307             C<Dist::Zilla::PluginBundle::Author::DOHERTY>.
308              
309             =head1 AUTHOR
310              
311             Alexei Znamensky <russoz@cpan.org>
312              
313             =head1 COPYRIGHT AND LICENSE
314              
315             This software is copyright (c) 2011 - 2017 by Alexei Znamensky.
316              
317             This is free software; you can redistribute it and/or modify it under
318             the same terms as the Perl 5 programming language system itself.
319              
320             =head1 AUTHOR
321              
322             Alexei Znamensky <russoz@cpan.org>
323              
324             =head1 COPYRIGHT AND LICENSE
325              
326             This software is copyright (c) 2011 - 2017 by Alexei Znamensky.
327              
328             This is free software; you can redistribute it and/or modify it under
329             the same terms as the Perl 5 programming language system itself.
330              
331             =cut