File Coverage

blib/lib/Dist/Zilla/PluginBundle/Author/GETTY.pm
Criterion Covered Total %
statement 21 86 24.4
branch 0 54 0.0
condition 0 23 0.0
subroutine 7 9 77.7
pod 0 2 0.0
total 28 174 16.0


line stmt bran cond sub pod time code
1             package Dist::Zilla::PluginBundle::Author::GETTY;
2             our $AUTHORITY = 'cpan:GETTY';
3             # ABSTRACT: BeLike::GETTY when you build your dists
4             $Dist::Zilla::PluginBundle::Author::GETTY::VERSION = '0.114';
5 1     1   1455 use Moose;
  1         515180  
  1         5  
6 1     1   8340 use Moose::Autobox;
  1         224444  
  1         5  
7 1     1   1480 use Dist::Zilla;
  1         1251798  
  1         79  
8             with 'Dist::Zilla::Role::PluginBundle::Easy';
9              
10 1     1   755 use Dist::Zilla::Plugin::TravisCI ();
  1         597816  
  1         45  
11              
12              
13 1     1   625 use Dist::Zilla::PluginBundle::Basic;
  1         75038  
  1         35  
14 1     1   510 use Dist::Zilla::PluginBundle::Git;
  1         518256  
  1         3006  
15              
16             has manual_version => (
17             is => 'ro',
18             isa => 'Bool',
19             lazy => 1,
20             default => sub { $_[0]->payload->{manual_version} },
21             );
22              
23             has major_version => (
24             is => 'ro',
25             isa => 'Int',
26             lazy => 1,
27             default => sub { $_[0]->payload->{version} || 0 },
28             );
29              
30             has author => (
31             is => 'ro',
32             isa => 'Str',
33             lazy => 1,
34             default => sub { $_[0]->payload->{author} || 'GETTY' },
35             );
36              
37             has installrelease_command => (
38             is => 'ro',
39             isa => 'Str',
40             lazy => 1,
41             default => sub { $_[0]->payload->{installrelease_command} || 'cpanm .' },
42             );
43              
44             has no_installrelease => (
45             is => 'ro',
46             isa => 'Bool',
47             lazy => 1,
48             default => sub { $_[0]->payload->{no_installrelease} },
49             );
50              
51             has release_branch => (
52             is => 'ro',
53             isa => 'Str',
54             lazy => 1,
55             default => sub { $_[0]->payload->{release_branch} || 'master' },
56             );
57              
58             has deprecated => (
59             is => 'ro',
60             isa => 'Bool',
61             lazy => 1,
62             default => sub { $_[0]->payload->{deprecated} },
63             );
64              
65             has no_github => (
66             is => 'ro',
67             isa => 'Bool',
68             lazy => 1,
69             default => sub { $_[0]->payload->{no_github} },
70             );
71              
72             has no_cpan => (
73             is => 'ro',
74             isa => 'Bool',
75             lazy => 1,
76             default => sub { $_[0]->payload->{no_cpan} },
77             );
78              
79             has no_travis => (
80             is => 'ro',
81             isa => 'Bool',
82             lazy => 1,
83             default => sub { exists $_[0]->payload->{no_travis} ? $_[0]->payload->{no_travis} : 1 },
84             );
85              
86             has no_changelog_from_git => (
87             is => 'ro',
88             isa => 'Bool',
89             lazy => 1,
90             default => sub { $_[0]->payload->{no_changelog_from_git} },
91             );
92              
93             has no_changes => (
94             is => 'ro',
95             isa => 'Bool',
96             lazy => 1,
97             default => sub { $_[0]->payload->{no_changes} },
98             );
99              
100             has no_install => (
101             is => 'ro',
102             isa => 'Bool',
103             lazy => 1,
104             default => sub { $_[0]->payload->{no_install} },
105             );
106              
107             has no_makemaker => (
108             is => 'ro',
109             isa => 'Bool',
110             lazy => 1,
111             default => sub { $_[0]->payload->{no_makemaker} || $_[0]->is_alien || $_[0]->xs },
112             );
113              
114             has no_podweaver => (
115             is => 'ro',
116             isa => 'Bool',
117             lazy => 1,
118             default => sub { $_[0]->payload->{no_podweaver} },
119             );
120              
121             has xs => (
122             is => 'ro',
123             isa => 'Bool',
124             lazy => 1,
125             default => sub { $_[0]->payload->{xs} },
126             );
127              
128             has is_task => (
129             is => 'ro',
130             isa => 'Bool',
131             lazy => 1,
132             default => sub { $_[0]->payload->{task} },
133             );
134              
135             has is_alien => (
136             is => 'ro',
137             isa => 'Bool',
138             lazy => 1,
139             default => sub { $_[0]->alien_repo ? 1 : 0 },
140             );
141              
142             has weaver_config => (
143             is => 'ro',
144             isa => 'Str',
145             lazy => 1,
146             default => sub { $_[0]->payload->{weaver_config} || '@Author::GETTY' },
147             );
148              
149             my @gather_array_options = qw( exclude_filename exclude_match );
150             my @gather_array_attributes = map { 'gather_'.$_ } @gather_array_options;
151              
152             for my $attr (@gather_array_attributes) {
153             has $attr => (
154             is => 'ro',
155             isa => 'ArrayRef[Str]',
156             lazy => 1,
157             default => sub { defined $_[0]->payload->{$attr} ? $_[0]->payload->{$attr} : [] },
158             );
159             }
160              
161             has gather_include_dotfiles => (
162             is => 'ro',
163             isa => 'Bool',
164             lazy => 1,
165             default => sub { exists $_[0]->payload->{gather_include_dotfiles} ? $_[0]->payload->{gather_include_dotfiles} : 1 },
166             );
167              
168             has gather_include_untracked => (
169             is => 'ro',
170             isa => 'Bool',
171             lazy => 1,
172             default => sub { $_[0]->payload->{gather_include_untracked} },
173             );
174              
175             my @run_options = qw( after_build before_build before_release release after_release test );
176             my @run_ways = qw( run run_if_trial run_no_trial run_if_release run_no_release );
177              
178             my @run_attributes = map { my $o = $_; map { join('_',$_,$o) } @run_ways } @run_options;
179              
180             for my $attr (@run_attributes) {
181             has $attr => (
182             is => 'ro',
183             isa => 'ArrayRef[Str]',
184             lazy => 1,
185             default => sub { defined $_[0]->payload->{$attr} ? $_[0]->payload->{$attr} : [] },
186             );
187             }
188              
189             my @alien_options = qw( msys repo name bins pattern_prefix pattern_suffix pattern_version pattern autoconf_with_pic isolate_dynamic version_check );
190              
191             my @alien_attributes = map { 'alien_'.$_ } @alien_options;
192              
193             for my $attr (@alien_attributes) {
194             has $attr => (
195             is => 'ro',
196             isa => 'Str',
197             lazy => 1,
198             default => sub { defined $_[0]->payload->{$attr} ? $_[0]->payload->{$attr} : "" },
199             );
200             }
201              
202             has alien_bin_requires => (
203             is => 'ro',
204             isa => 'ArrayRef[Str]',
205             lazy => 1,
206             default => sub { defined $_[0]->payload->{alien_bin_requires} ? $_[0]->payload->{alien_bin_requires} : [] },
207             );
208              
209             my @travis_str_options = (
210             @Dist::Zilla::Plugin::TravisCI::bools,
211             );
212              
213             my @travis_str_attributes = map { 'travis_'.$_ } @travis_str_options;
214              
215             for my $attr (@travis_str_attributes) {
216             has $attr => (
217             is => 'ro',
218             isa => 'Str',
219             lazy => 1,
220             default => sub { defined $_[0]->payload->{$attr} ? $_[0]->payload->{$attr} : "" },
221             );
222             }
223              
224             my @travis_array_options = (
225             @Dist::Zilla::Plugin::TravisCI::phases,
226             @Dist::Zilla::Plugin::TravisCI::emptymvarrayattr,
227             'irc_template',
228             'perl_version',
229             );
230              
231             my @travis_array_attributes = map { 'travis_'.$_ } @travis_array_options;
232              
233             for my $attr (@travis_array_attributes) {
234             has $attr => (
235             is => 'ro',
236             isa => 'ArrayRef[Str]',
237             lazy => 1,
238             default => sub { defined $_[0]->payload->{$attr} ? $_[0]->payload->{$attr} : [] },
239             );
240             }
241              
242 0     0 0   sub mvp_multivalue_args { @travis_array_attributes, @run_attributes, @gather_array_attributes, 'alien_bin_requires' }
243              
244             sub configure {
245 0     0 0   my ($self) = @_;
246              
247 0 0 0       $self->log_fatal("you must not specify both weaver_config and is_task")
248             if $self->is_task and $self->weaver_config ne '@Author::GETTY';
249              
250 0 0 0       $self->log_fatal("you must not specify both author and no_cpan")
251             if $self->no_cpan and $self->author ne 'GETTY';
252              
253 0 0 0       $self->log_fatal("no_install can't be used together with no_makemaker")
254             if $self->no_install and $self->no_makemaker;
255              
256             $self->add_plugins([ 'Git::GatherDir' => {
257             include_dotfiles => $self->gather_include_dotfiles,
258             include_untracked => $self->gather_include_untracked,
259 0           scalar @{$self->gather_exclude_filename} > 0 ? ( exclude_filename => $self->gather_exclude_filename ) : (),
260 0 0         scalar @{$self->gather_exclude_match} > 0 ? ( exclude_match => $self->gather_exclude_match ) : (),
  0 0          
261             }]);
262              
263 0           my @removes = ('GatherDir','PruneCruft');
264 0 0 0       if ($self->no_cpan || $self->no_makemaker) {
265 0 0         push @removes, 'UploadToCPAN' if $self->no_cpan;
266 0 0         push @removes, 'MakeMaker' if $self->no_makemaker;
267             }
268 0           $self->add_bundle('Filter' => {
269             -bundle => '@Basic',
270             -remove => [@removes],
271             });
272              
273 0 0         if ($self->xs) {
274 0           $self->add_plugins(qw(
275             ModuleBuildTiny
276             ));
277             }
278              
279 0 0         if ($self->deprecated) {
280 0           $self->add_plugins(qw(
281             Deprecated
282             ));
283             }
284              
285 0 0         unless ($self->manual_version) {
286 0 0         if ($self->is_task) {
287             my $v_format = q<{{cldr('yyyyMMdd')}}>
288 0   0       . sprintf('.%03u', ($ENV{N} || 0));
289              
290 0           $self->add_plugins([
291             AutoVersion => {
292             major => $self->major_version,
293             format => $v_format,
294             }
295             ]);
296             } else {
297 0           $self->add_plugins([
298             'Git::NextVersion' => {
299             version_regexp => '^([0-9]+\.[0-9]+)$',
300             }
301             ]);
302             }
303             }
304              
305 0           for (@run_options) {
306 0           my $net = $_;
307 0           my $func = 'run_'.$_;
308 0 0         if (@{$self->$func}) {
  0            
309 0           my $plugin = join('',map { ucfirst($_) } split(/_/,$_));
  0            
310 0           $self->add_plugins([
311             'Run::'.$plugin => {
312             run => $self->$func,
313             }
314             ]);
315             }
316             }
317              
318 0           $self->add_plugins(qw(
319             PkgVersion
320             MetaConfig
321             MetaJSON
322             PodSyntaxTests
323             ));
324              
325 0 0         $self->add_plugins($self->no_github ? 'Repository' : 'GithubMeta');
326              
327 0 0         unless ($self->no_travis) {
328             $self->add_plugins([
329             TravisCI => {
330             ( map {
331 0           my $func = 'travis_'.$_;
332 0 0         $self->$func ? ( $_ => $self->$func ) : ();
333             } @travis_str_options ),
334             ( map {
335 0           my $func = 'travis_'.$_;
  0            
336 0 0         scalar @{$self->$func} ? ( $_ => $self->$func ) : ();
  0            
337             } @travis_array_options ),
338             },
339             ]);
340             }
341              
342 0 0         if ($self->is_alien) {
343 0           my %alien_values;
344 0           for (@alien_options) {
345 0           my $func = 'alien_'.$_;
346 0 0 0       $alien_values{$_} = $self->$func if defined $self->$func && $self->$func ne '';
347             }
348 0 0         if(@{ $self->alien_bin_requires }) {
  0            
349 0           $alien_values{bin_requires} = $self->alien_bin_requires;
350             }
351             $self->add_plugins([
352 0           'Alien' => \%alien_values,
353             ]);
354             }
355              
356 0 0 0       unless ($self->no_installrelease || $self->is_alien) {
357 0           $self->add_plugins([
358             'InstallRelease' => {
359             install_command => $self->installrelease_command,
360             }
361             ]);
362             }
363              
364 0 0 0       unless (!$self->is_alien || $self->no_installrelease) {
365 0           $self->add_plugins([
366             'Run::Test' => 'AlienInstallTestHack' => {
367             run_if_release => ['./Build install'],
368             },
369             ]);
370             }
371              
372 0 0         unless ($self->no_cpan) {
373 0           $self->add_plugins([
374             'Authority' => {
375             authority => 'cpan:'.$self->author,
376             do_metadata => 1,
377             }
378             ]);
379             }
380              
381             $self->add_plugins([
382 0           'Git::CheckFor::CorrectBranch' => {
383             release_branch => $self->release_branch,
384             },
385             ]);
386              
387 0           $self->add_plugins('Prereqs::FromCPANfile');
388              
389 0 0         unless ($self->no_changes) {
390 0 0         if ($self->no_changelog_from_git) {
391 0           $self->add_plugins(qw(
392             NextRelease
393             ));
394             } else {
395 0           $self->add_plugins([
396             'ChangelogFromGit' => {
397             max_age => 99999,
398             tag_regexp => '^v?(\d.+)$',
399             file_name => 'Changes',
400             wrap_column => 74,
401             debug => 0,
402             }
403             ]);
404             }
405             }
406              
407 0 0         if ($self->is_task) {
408 0           $self->add_plugins('TaskWeaver');
409             } else {
410 0 0         unless ($self->no_podweaver) {
411 0           $self->add_plugins([
412             PodWeaver => { config_plugin => $self->weaver_config }
413             ]);
414             }
415             }
416              
417 0           $self->add_bundle('@Git' => {
418             tag_format => '%v',
419             push_to => [ qw(origin) ],
420             });
421             }
422              
423             __PACKAGE__->meta->make_immutable;
424 1     1   20 no Moose;
  1         2  
  1         8  
425             1;
426              
427             __END__
428              
429             =pod
430              
431             =head1 NAME
432              
433             Dist::Zilla::PluginBundle::Author::GETTY - BeLike::GETTY when you build your dists
434              
435             =head1 VERSION
436              
437             version 0.114
438              
439             =head1 SYNOPSIS
440              
441             name = Your-App
442             author = You User <you@universe.org>
443             license = Perl_5
444             copyright_holder = You User
445             copyright_year = 2013
446              
447             [@Author::GETTY]
448             author = YOUONCPAN
449              
450             =head1 DESCRIPTION
451              
452             This is the plugin bundle that GETTY uses. You can configure it (given values
453             are default):
454              
455             [@Author::GETTY]
456             author = GETTY
457             deprecated = 0
458             release_branch = master
459             weaver_config = @Author::GETTY
460             no_cpan = 0
461             no_travis = 1 # deactivate by default now
462             no_install = 0
463             no_makemaker = 0
464             no_installrelease = 0
465             no_changes = 0
466             no_changelog_from_git = 0
467             no_podweaver = 0
468             xs = 0
469             installrelease_command = cpanm .
470              
471             In default configuration it is equivalent to:
472              
473             [@Filter]
474             -bundle = @Basic
475             -remove = GatherDir
476             -remove = PruneCruft
477              
478             [Git::NextVersion]
479             [PkgVersion]
480             [MetaConfig]
481             [MetaJSON]
482             [NextRelease]
483             [PodSyntaxTests]
484             [GithubMeta]
485             [TravisCI]
486              
487             [InstallRelease]
488             install_command = cpanm .
489              
490             [Authority]
491             authority = cpan:GETTY
492             do_metadata = 1
493              
494             [PodWeaver]
495             config_plugin = @Author::GETTY
496              
497             [Repository]
498            
499             [Git::CheckFor::CorrectBranch]
500             release_branch = master
501              
502             [@Git]
503             tag_format = %v
504             push_to = origin
505              
506             [ChangelogFromGit]
507             max_age = 99999
508             tag_regexp = ^v(.+)$
509             file_name = Changes
510             wrap_column = 74
511             debug = 0
512              
513             If the C<task> argument is given to the bundle, PodWeaver is replaced with
514             TaskWeaver and Git::NextVersion is replaced with AutoVersion, you can also
515             give independent a bigger major version with C<version>:
516              
517             [@Author::GETTY]
518             task = 1
519              
520             If the C<manual_version> argument is given, AutoVersion and Git::NextVersion
521             are omitted.
522              
523             [@Author::GETTY]
524             manual_version = 1.222333
525              
526             You can also use shortcuts for integrating L<Dist::Zilla::Plugin::Run>:
527              
528             [@Author::GETTY]
529             run_after_build = script/do_this.pl --dir %s --version %s
530             run_before_build = script/do_this.pl --version %s
531             run_before_release = script/myapp_before1.pl %s
532             run_release = deployer.pl --dir %d --tgz %a --name %n --version %v
533             run_after_release = script/myapp_after.pl --archive %s --version %s
534             run_test = script/tester.pl --name %n --version %v some_file.ext
535             run_if_release_test = ./Build install
536             run_if_release_test = make install
537              
538             You can also use add up configuration for L<Dist::Zilla::Plugin::Git::GatherDir>,
539             excluding I<root> or I<prefix>:
540              
541             [@Author::GETTY]
542             gather_include_dotfiles = 1 # activated by default
543             gather_include_untracked = 0
544             gather_exclude_filename = dir/skip
545             gather_exclude_match = ^local_
546              
547             You can use all options of L<Dist::Zilla::Plugin::TravisCI> just by prefix
548             them with B<travis_>, like here:
549              
550             [@Author::GETTY]
551             travis_before_install = install_additional_packages.sh
552              
553             It also combines on request with L<Dist::Zilla::Plugin::Alien>, you can set
554             all parameter of the Alien plugin here, just by preceeding with I<alien_>, the
555             only required parameter here is C<alien_repo>:
556              
557             [@Author::GETTY]
558             alien_repo = http://myapp.org/releases
559             alien_bins = myapp myapp_helper
560             alien_name = myapp
561             alien_pattern_prefix = myapp-
562             alien_pattern_version = ([\d\.]+)
563             alien_pattern_suffix = \.tar\.gz
564             alien_pattern = myapp-([\d\.]+)\.tar\.gz
565              
566             =head1 ATTRIBUTES
567              
568             =head2 author
569              
570             This is used to name the L<CPAN|http://www.cpan.org/> author of the
571             distribution. See L<Dist::Zilla::Plugin::Authority/authority>.
572              
573             =head2 deprecated
574              
575             Adds L<Dist::Zilla::Plugin::Deprecated> to the distribution.
576              
577             =head2 release_branch
578              
579             This variable is used to set the release_branch, only releases on this branch
580             will be allowed. See L<Dist::Zilla::Plugin::Git::CheckFor::CorrectBranch/release_branch>.
581              
582             =head2 weaver_config
583              
584             This defines the L<PodWeaver> config that is used. See B<config_plugin> on
585             L<Dist::Zilla::Plugin::PodWeaver>.
586              
587             =head2 no_github
588              
589             If set to 1, this attribute will disable L<Dist::Zilla::Plugin::GithubMeta> and
590             will add L<Dist::Zilla::Plugin::Repository> instead.
591              
592             =head2 no_cpan
593              
594             If set to 1, this attribute will disable L<Dist::Zilla::Plugin::UploadToCPAN>.
595             By default a dzil release would release to L<CPAN|http://www.cpan.org/>.
596              
597             =head2 no_travis
598              
599             If set to 1, this attribute will disable L<Dist::Zilla::Plugin::TravisCI>. By
600             default a dzil build or release would also generate a B<.travis.yml>.
601              
602             =head2 no_changelog_from_git
603              
604             If set to 1, then L<Dist::Zilla::Plugin::ChangelogFromGit> will be disabled, and
605             L<Dist::Zilla::Plugin::NextRelease> will be used instead.
606              
607             =head2 no_changes
608              
609             If set to 1, then neither L<Dist::Zilla::Plugin::ChangelogFromGit> or
610             L<Dist::Zilla::Plugin::NextRelease> will be used.
611              
612             =head2 no_podweaver
613              
614             If set to 1, then L<Dist::Zilla::Plugin::PodWeaver> is not used.
615              
616             =head2 xs
617              
618             If set to 1, then L<Dist::Zilla::Plugin::ModuleBuildTiny>. This will also
619             automatically set B<no_makemaker> to 1.
620              
621             =head2 no_install
622              
623             If set to 1, the resulting distribution can't be installed.
624              
625             =head2 no_makemaker
626              
627             If set to 1, the resulting distribution will not use L<Dist::Zilla::Plugin::MakeMaker>.
628             This is an internal function, and you should know what you do, if you activate
629             this flag.
630              
631             =head2 no_installrelease
632              
633             By default, this bundle will install your distribution after the release. If
634             you set this attribute to 1, then this will not happen. See
635             L<Dist::Zilla::Plugin::InstallRelease>.
636              
637             If you use the L<Dist::Zilla::Plugin::Alien> options, then this one will not
638             use L<Dist::Zilla::Plugin::InstallRelease>, instead, it will use the trick
639             mentioned in L<Dist::Zilla::Plugin::Alien/InstallRelease>.
640              
641             =head2 installrelease_command
642              
643             If you don't like the usage of L<App::cpanminus> to install your distribution
644             after install, you can set another command here. See B<install_command> on
645             L<Dist::Zilla::Plugin::InstallRelease>.
646              
647             =head1 SEE ALSO
648              
649             L<Dist::Zilla::Plugin::Alien>
650              
651             L<Dist::Zilla::Plugin::Authority>
652              
653             L<Dist::Zilla::Plugin::BumpVersionFromGit>
654              
655             L<Dist::Zilla::PluginBundle::Git>
656              
657             L<Dist::Zilla::Plugin::ChangelogFromGit>
658              
659             L<Dist::Zilla::Plugin::Git::CheckFor::CorrectBranch>
660              
661             L<Dist::Zilla::Plugin::GithubMeta>
662              
663             L<Dist::Zilla::Plugin::InstallRelease>
664              
665             L<Dist::Zilla::Plugin::MakeMaker::SkipInstall>
666              
667             L<Dist::Zilla::Plugin::PodWeaver>
668              
669             L<Dist::Zilla::Plugin::Repository>
670              
671             L<Dist::Zilla::Plugin::Run>
672              
673             L<Dist::Zilla::Plugin::TaskWeaver>
674              
675             L<Dist::Zilla::Plugin::TravisCI>
676              
677             =head1 AUTHOR
678              
679             Torsten Raudssus <torsten@raudss.us> L<http://www.raudss.us/>
680              
681             =head1 COPYRIGHT AND LICENSE
682              
683             This software is copyright (c) 2014 by Torsten Raudssus L<http://www.raudss.us/>.
684              
685             This is free software; you can redistribute it and/or modify it under
686             the same terms as the Perl 5 programming language system itself.
687              
688             =cut