File Coverage

lib/Dist/Zilla/Plugin/Regenerate/AfterReleasers.pm
Criterion Covered Total %
statement 20 30 66.6
branch 0 4 0.0
condition n/a
subroutine 7 10 70.0
pod 0 3 0.0
total 27 47 57.4


line stmt bran cond sub pod time code
1 1     1   791 use 5.006; # our
  1         3  
2 1     1   4 use strict;
  1         1  
  1         19  
3 1     1   2 use warnings;
  1         1  
  1         66  
4              
5             package Dist::Zilla::Plugin::Regenerate::AfterReleasers;
6              
7             our $VERSION = '0.001000';
8              
9             # ABSTRACT: Tickle plugins that do "AfterRelease" from regenerate
10              
11             our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
12              
13 1     1   466 use Moose qw( with has around );
  1         282839  
  1         6  
14 1     1   4441 use Safe::Isa qw( $_does );
  1         334  
  1         108  
15 1     1   381 use namespace::clean -except => 'meta';
  1         3872  
  1         4  
16              
17             with qw/ Dist::Zilla::Role::Plugin Dist::Zilla::Role::Regenerator /;
18              
19             has plugins => (
20             is => 'ro',
21             isa => 'ArrayRef',
22             default => sub { [] },
23             );
24              
25             around dump_config => sub {
26             my ( $orig, $self, @args ) = @_;
27             my $config = $self->$orig(@args);
28             my $payload = $config->{ +__PACKAGE__ } = {};
29             $payload->{plugins} = $self->plugins;
30              
31             ## no critic (RequireInterpolationOfMetachars)
32             # Self report when inherited
33             $payload->{ q[$] . __PACKAGE__ . '::VERSION' } = $VERSION unless __PACKAGE__ eq ref $self;
34             return $config;
35             };
36              
37 1     1   222 no Moose;
  1         1  
  1         5  
38             __PACKAGE__->meta->make_immutable;
39              
40              
41              
42              
43              
44 0     0 0   sub mvp_multivalue_args { qw( plugins ) }
45 0     0 0   sub mvp_aliases { +{ plugin => 'plugins' } }
46              
47             sub regenerate {
48 0     0 0   my ($self) = @_;
49 0           my $zilla = $self->zilla;
50 0           for my $plugin ( @{ $self->plugins } ) {
  0            
51 0           my $ref = $zilla->plugin_named($plugin);
52 0 0         $self->log_fatal("No such plugin $plugin") if not $ref;
53 0 0         $self->log_fatal("$plugin does not do -AfterRelease") if not $ref->$_does('Dist::Zilla::Role::AfterRelease');
54 0           $ref->after_release();
55             }
56             }
57              
58             1;
59              
60             __END__
61              
62             =pod
63              
64             =encoding UTF-8
65              
66             =head1 NAME
67              
68             Dist::Zilla::Plugin::Regenerate::AfterReleasers - Tickle plugins that do "AfterRelease" from regenerate
69              
70             =head1 VERSION
71              
72             version 0.001000
73              
74             =head1 SYNOPSIS
75              
76             ; Example AfterRelease module
77             [CopyFilesFromRelease / MyName]
78              
79             ; Configured to trip CopyFilesFromRelease during regenerate
80             [Regenerate::AfterReleasers]
81             plugin = MyName
82              
83             =head1 DESCRIPTION
84              
85             This C<Dist::Zilla> C<Plugin> allows you to promote selected plugins to execution under C<dzil regenerate>
86              
87             Simply specifying the list of C<Plugin B<NAMES>> you wish to invoke will have their respective C<after_release>
88             methods called in the stated order.
89              
90             B<Note:> They are executed in C<STATED> order, B<NOT> the order in C<dist.ini>. This may be seen as a bug or a feature,
91             and may be subject to change if it turns out to be a bad idea.
92              
93             =for Pod::Coverage mvp_multivalue_args mvp_aliases regenerate
94              
95             =head1 ATTRIBUTES
96              
97             =head2 plugins
98              
99             An Array of Strings of C<PluginName>
100              
101             [Regenerate]
102             plugin = pluginName
103             plugin = pluginName
104              
105             B<aliases:> C<plugin>
106              
107             =head1 AUTHOR
108              
109             Kent Fredric <kentnl@cpan.org>
110              
111             =head1 COPYRIGHT AND LICENSE
112              
113             This software is copyright (c) 2016 by Kent Fredric <kentfredric@gmail.com>.
114              
115             This is free software; you can redistribute it and/or modify it under
116             the same terms as the Perl 5 programming language system itself.
117              
118             =cut