File Coverage

lib/Dist/Zilla/Plugin/Author/KENTNL/DistINI.pm
Criterion Covered Total %
statement 31 34 91.1
branch 1 2 50.0
condition 2 4 50.0
subroutine 9 9 100.0
pod 1 1 100.0
total 44 50 88.0


line stmt bran cond sub pod time code
1 5     5   1082823 use 5.006; # our
  5         15  
2 5     5   18 use strict;
  5         6  
  5         84  
3 5     5   14 use warnings;
  5         6  
  5         270  
4              
5              
6              
7              
8              
9             package Dist::Zilla::Plugin::Author::KENTNL::DistINI;
10              
11             # ABSTRACT: Generate a dist.ini for @Author::KENTNL projects.
12              
13             our $VERSION = '2.025020';
14              
15             our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
16              
17              
18              
19              
20              
21              
22              
23              
24              
25              
26              
27              
28              
29              
30 5     5   402 use Moose qw( with );
  5         275984  
  5         22  
31              
32             with qw(Dist::Zilla::Role::FileGatherer);
33              
34             __PACKAGE__->meta->make_immutable;
35 5     5   16811 no Moose;
  5         7  
  5         18  
36              
37             use String::Formatter named_stringf => {
38             -as => 'str_rf',
39             codes => {
40 32         2254 s => sub { "$_" },
41 0         0 S => sub { q{"} . "$_" . q{"} },
42 0         0 n => sub { int },
43             },
44 5     5   2906 };
  5         9398  
  5         48  
45              
46              
47              
48              
49              
50              
51              
52             sub _template {
53 4     4   7 my $empty = q{};
54 4         264 return <<"EOF";
55             ; Generated by %{GENPACKAGE}s version %{GENVERSION}s at %{GENTIME}s
56             ; vim: syntax=dosini
57             name = %{name}s
58             author = %{author}s
59             license = %{license}s
60             copyright_holder = %{copyrightholder}s
61             $empty
62             ; Uncomment this to bootstrap via self
63             ; [Bootstrap::lib]
64             $empty
65             [\@Author::KENTNL]
66             :version = %{depversion}s
67             normal_form = numify
68             mantissa = 6
69             toolkit = eumm
70             toolkit_hardness = soft
71             bumpversions = 1
72             srcreadme = mkdn
73             ; twitter_extra_hash_tags =
74             ; auto_prereqs_skip = File::Find
75             $empty
76             [Prereqs]
77             $empty
78             EOF
79             }
80              
81             sub gather_files {
82 4     4 1 3217257 my ( $self, ) = @_;
83             my $code = sub {
84             ## no critic (RegularExpressions)
85 4     4   158553 my $license = ref $self->zilla->license;
86 4 50       121 if ( $license =~ /^Software::License::(.+)$/ ) {
87 4         10 $license = $1;
88             }
89             else {
90 0         0 $license = "=$license";
91             }
92              
93             # TODO: support >1 authors. Too lazy atm, its just me. -- Kentnl - 2010-06-10
94             # TODO: Actually workout whatever localtime is where Kentnl lives. Atm, its overkill. -- Kentnl - 2010-06-10
95 4   50     14 my $content = str_rf(
      50        
96             $self->_template,
97             {
98             GENPACKAGE => __PACKAGE__,
99             GENVERSION => ( __PACKAGE__->VERSION || '(unversioned:dist)' ),
100             GENTIME => ( scalar localtime ),
101             name => $self->zilla->name,
102             author => $self->zilla->authors->[0],
103             license => $license,
104             copyrightholder => $self->zilla->copyright_holder,
105             rel_year => (localtime)[5] + 1900,
106             rel_month => (localtime)[4] + 1,
107             rel_day => (localtime)[3],
108             rel_hour => (localtime)[2],
109             tz => 'Pacific/Auckland',
110             tags => '#perl #cpan',
111             depversion => ( __PACKAGE__->VERSION || '2.016000' ),
112             },
113             );
114 4         349 return $content;
115 4         23 };
116 4         28 require Dist::Zilla::File::FromCode;
117 4         125 my $file = Dist::Zilla::File::FromCode->new(
118             {
119             name => 'dist.ini',
120             code => $code,
121             },
122             );
123 4         547 $self->add_file($file);
124 4         1869 return 1;
125             }
126              
127             1;
128              
129             __END__
130              
131             =pod
132              
133             =encoding UTF-8
134              
135             =head1 NAME
136              
137             Dist::Zilla::Plugin::Author::KENTNL::DistINI - Generate a dist.ini for @Author::KENTNL projects.
138              
139             =head1 VERSION
140              
141             version 2.025020
142              
143             =head1 SYNOPSIS
144              
145             ; ~/.dzil/profiles/default/profile.ini
146             [Author::KENTNL::DistINI]
147              
148             ; ~/.dzil/config.ini
149             [%Rights]
150             license_class = Perl_5
151             copyright_holder = Kent Fredric <kentnl@cpan.org>
152              
153             [%PAUSE]
154             user = KENTNL
155             password = ; you don't think I'm stupid do you?
156              
157             ; ~/.netrc
158             machine api.twitter.com
159             login kentnlrelease
160             password ; still not quite stupid enough
161              
162             Then
163              
164             dzil new Some-Distname
165             # start hacking.
166              
167             This sets up [@Author::KENTNL] packages the way KENTNL likes it.
168              
169             This involves initial configuration of the parameters that get
170             passed through to AutoVersion::Relative to provide the
171             relative frame of reference.
172              
173             =head1 METHODS
174              
175             =head2 C<gather_files>
176              
177             generates a C<dist.ini> file.
178              
179             =begin MetaPOD::JSON v1.1.0
180              
181             {
182             "namespace":"Dist::Zilla::Plugin::Author::KENTNL::DistINI",
183             "interface":"class",
184             "inherits":"Moose::Object",
185             "does":"Dist::Zilla::Role::FileGatherer"
186             }
187              
188              
189             =end MetaPOD::JSON
190              
191             =head1 NAMING RATIONALE
192              
193             Plugin::DistINI::KENTNL # Argh, too pollutive of the ::DistINI subspace
194             Plugin::DistINI::Author::KENTNL
195             # Argh, its going to result in lots of 'Author' subspaces ;(
196             Plugin::Author::KENTNL::* # Low pollution, well clustered.
197              
198             As it is, the following stuff is starting to get to me in terms of
199             name-space pollution:
200              
201             Plugin::EOLTests # Would prefer Plugin::Test::EOL
202             Plugin::PodSyntaxTests # Would prefer Plugin::Test::Pod::Syntax
203              
204             And I have half a mind to rename L<< C<Dist::Zilla::PluginBundle::KENTNL>|Dist::Zilla::PluginBundle::KENTNL >> to be
205             C<Dist::Zilla::PluginBundle::Author::KENTNL> just to keep the top level cleaner, for stuff where bundles of plug-ins are useful
206             for people other than ... well.. me. Call me a counter-egotist, if you will.
207              
208             =head1 AUTHOR
209              
210             Kent Fredric <kentnl@cpan.org>
211              
212             =head1 COPYRIGHT AND LICENSE
213              
214             This software is copyright (c) 2016 by Kent Fredric <kentfredric@gmail.com>.
215              
216             This is free software; you can redistribute it and/or modify it under
217             the same terms as the Perl 5 programming language system itself.
218              
219             =cut