File Coverage

blib/lib/Pod/Weaver/PluginBundle/Author/ETHER.pm
Criterion Covered Total %
statement 60 60 100.0
branch 26 26 100.0
condition 11 14 78.5
subroutine 14 14 100.0
pod 0 2 0.0
total 111 116 95.6


line stmt bran cond sub pod time code
1 22     22   206854 use strict;
  22         82  
  22         829  
2 22     22   129 use warnings;
  22         56  
  22         1811  
3             package Pod::Weaver::PluginBundle::Author::ETHER;
4             # vim: set ts=8 sts=2 sw=2 tw=100 et :
5             # ABSTRACT: A plugin bundle for pod woven by ETHER
6              
7             our $VERSION = '0.162';
8              
9 22     22   159 use if "$]" >= 5.022, experimental => 're_strict';
  22         55  
  22         275  
10 22     22   7209 no if "$]" >= 5.031009, feature => 'indirect';
  22         59  
  22         259  
11 22     22   999 no if "$]" >= 5.033001, feature => 'multidimensional';
  22         61  
  22         119  
12 22     22   843 no if "$]" >= 5.033006, feature => 'bareword_filehandles';
  22         54  
  22         128  
13 22     22   1463 use namespace::autoclean -also => ['_exp'];
  22         18344  
  22         269  
14 22     22   12986 use Pod::Weaver::Config::Assembler;
  22         10040187  
  22         1074  
15 22     22   236 use Module::Runtime 'use_module';
  22         93  
  22         182  
16 22     22   11785 use PadWalker 'peek_sub';
  22         15036  
  22         19158  
17              
18             sub _exp { Pod::Weaver::Config::Assembler->expand_package($_[0]) }
19              
20             # This sub behaves somewhat like a Dist::Zilla pluginbundle's configure() -- it returns a list of strings or 1, 2
21             # or 3-element arrayrefs containing plugin specifications. The goal is to make this look as close to what
22             # weaver.ini looks like as possible.
23             sub configure {
24 75     75 0 366 my $self = shift;
25              
26             # I wouldn't have to do this ugliness if I could have some configuration values passed in from weaver.ini or
27             # the [PodWeaver] plugin's use of config_plugin (where I could define a 'licence' option)
28 75         206 my $podweaver_plugin = ${ peek_sub(\&Dist::Zilla::Plugin::PodWeaver::weaver)->{'$self'} };
  75         1695  
29 75   100     3012 my $licence_plugin = $podweaver_plugin && $podweaver_plugin->zilla->plugin_named('@Author::ETHER/License');
30 75 100       28268 my $licence_filename = $licence_plugin ? $licence_plugin->filename : 'LICENCE';
31              
32             return (
33             # equivalent to [@CorePrep]
34 75         5607 [ '-EnsurePod5' ],
35             [ '-H1Nester' ],
36             '-SingleEncoding',
37              
38             [ '-Transformer' => List => { transformer => 'List' } ],
39             [ '-Transformer' => Verbatim => { transformer => 'Verbatim' } ],
40              
41             [ 'Region' => 'header' ],
42             'Name',
43             'Version',
44             [ 'Region' => 'prelude' ],
45             [ 'Generic' => 'SYNOPSIS' ],
46             [ 'Generic' => 'DESCRIPTION' ],
47             [ 'Generic' => 'OVERVIEW' ],
48              
49             [ 'Collect' => 'ATTRIBUTES' => { command => 'attr' } ],
50             [ 'Collect' => 'METHODS' => { command => 'method' } ],
51             [ 'Collect' => 'FUNCTIONS' => { command => 'func' } ],
52             [ 'Collect' => 'TYPES' => { command => 'type' } ],
53             'Leftovers',
54             [ 'Region' => 'postlude' ],
55              
56             [ 'GenerateSection' => 'generate SUPPORT' => {
57             title => 'SUPPORT',
58             main_module_only => 0,
59             text => [ <<'SUPPORT',
60             {{ join("\n\n",
61             ($bugtracker_email && $bugtracker_email =~ /rt\.cpan\.org/)
62             ? "Bugs may be submitted through L<the RT bug tracker|$bugtracker_web>\n(or L<$bugtracker_email|mailto:$bugtracker_email>)."
63             : $bugtracker_web
64             ? "Bugs may be submitted through L<$bugtracker_web>."
65             : (),
66              
67             $distmeta->{resources}{x_MailingList} ? 'There is also a mailing list available for users of this distribution, at' . "\nL<" . $distmeta->{resources}{x_MailingList} . '>.' : (),
68              
69             $distmeta->{resources}{x_IRC}
70             ? 'There is also an irc channel available for users of this distribution, at' . "\nL<"
71             . do {
72             # try to extract the channel
73             if (my ($network, $channel) = ($distmeta->{resources}{x_IRC} =~ m!(?:://)?(\w+(?:\.\w+)*)/?(#\w+)!)) {
74             'C<' . $channel . '> on C<' . $network . '>|' . $distmeta->{resources}{x_IRC}
75             }
76             else {
77             $distmeta->{resources}{x_IRC}
78             }
79             }
80             . '>.'
81             : (),
82              
83             ($distmeta->{x_authority} // '') eq 'cpan:ETHER'
84             ? "I am also usually active on irc, as 'ether' at C<irc.perl.org> and C<irc.libera.chat>."
85             : (),
86             ) }}
87             SUPPORT
88             ] },
89             ],
90              
91             'Authors',
92             [ 'AllowOverride' => 'allow override AUTHOR' => {
93             header_re => '^AUTHORS?\b',
94             action => 'replace',
95             match_anywhere => 0,
96             },
97             ],
98              
99             [ 'Contributors' => { ':version' => '0.008' } ],
100             [ 'Legal' => { ':version' => '4.011', header => 'COPYRIGHT AND ' . $licence_filename } ],
101             [ 'Region' => 'footer' ],
102             );
103             }
104              
105             sub mvp_bundle_config {
106 75   50 75 0 57413403 my $self = shift || __PACKAGE__;
107              
108 75         673 return map $self->_expand_config($_), $self->configure;
109             }
110              
111             my $prefix;
112             sub _prefix {
113 1296     1296   77638 my $self = shift;
114 1296 100       4765 return $prefix if defined $prefix;
115 14   33     268 ($prefix = (ref($self) || $self)) =~ s/^Pod::Weaver::PluginBundle:://;
116 14         89 $prefix;
117             }
118              
119             sub _expand_config {
120 1832     1832   500247 my ($self, $this_spec) = @_;
121              
122 1832 100       3991 die 'undefined config' if not $this_spec;
123 1831 100 100     6637 die 'unrecognized config format: ' . ref($this_spec) if ref($this_spec) and ref($this_spec) ne 'ARRAY';
124              
125 1830         3141 my ($name, $class, $payload);
126              
127 1830 100       5689 if (not ref $this_spec) {
    100          
    100          
128 385         886 ($name, $class, $payload) = ($this_spec, _exp($this_spec), {});
129             }
130             elsif (@$this_spec == 1) {
131 150         719 ($name, $class, $payload) = ($this_spec->[0], _exp($this_spec->[0]), {});
132             }
133             elsif (@$this_spec == 2) {
134 688 100       2188 $name = ref $this_spec->[1] ? $this_spec->[0] : $this_spec->[1];
135 688 100       2041 $class = _exp(ref $this_spec->[1] ? $this_spec->[0] : $this_spec->[0]);
136 688 100       42471 $payload = ref $this_spec->[1] ? $this_spec->[1] : {};
137             }
138             else {
139 607         1542 ($name, $class, $payload) = ($this_spec->[1], _exp($this_spec->[0]), $this_spec->[2]);
140             }
141              
142 1830         73560 $name =~ s/^[@=-]//;
143              
144             # Region plugins have the custom plugin name moved to 'region_name' parameter,
145             # because we don't want our bundle name to be part of the region name.
146 1830 100       3827 if ($class eq _exp('Region')) {
147 303         17911 $name = $this_spec->[1];
148 303         1225 $payload = { region_name => $this_spec->[1], %$payload };
149             }
150              
151 1830 100       90598 use_module($class, $payload->{':version'}) if $payload->{':version'};
152              
153             # prepend '@Author::ETHER/' to each class name,
154             # except for Generic and Collect which are left alone.
155 1829 100 100     2117787 $name = '@' . $self->_prefix . '/' . $name
156             if $class ne _exp('Generic') and $class ne _exp('Collect');
157              
158 1829         37293 return [ $name => $class => $payload ];
159             }
160              
161             1;
162              
163             __END__
164              
165             =pod
166              
167             =encoding UTF-8
168              
169             =head1 NAME
170              
171             Pod::Weaver::PluginBundle::Author::ETHER - A plugin bundle for pod woven by ETHER
172              
173             =head1 VERSION
174              
175             version 0.162
176              
177             =head1 SYNOPSIS
178              
179             In your F<weaver.ini>:
180              
181             [@Author::ETHER]
182              
183             Or in your F<dist.ini>
184              
185             [PodWeaver]
186             config_plugin = @Author::ETHER
187              
188             It is also used automatically when your F<dist.ini> contains:
189              
190             [@Author::ETHER]
191             :version = 0.094 ; or any higher version
192              
193             =head1 DESCRIPTION
194              
195             =for stopwords optimizations
196              
197             This is a L<Pod::Weaver> plugin bundle. It is I<approximately> equal to the
198             following F<weaver.ini>, minus some optimizations:
199              
200             [-EnsurePod5]
201             [-H1Nester]
202             [-SingleEncoding]
203              
204             [-Transformer / List]
205             transformer = List
206              
207             [-Transformer / Verbatim]
208             transformer = Verbatim
209              
210             [Region / header]
211             [Name]
212             [Version]
213              
214             [Region / prelude]
215              
216             [Generic / SYNOPSIS]
217             [Generic / DESCRIPTION]
218             [Generic / OVERVIEW]
219              
220             [Collect / ATTRIBUTES]
221             command = attr
222              
223             [Collect / METHODS]
224             command = method
225              
226             [Collect / FUNCTIONS]
227             command = func
228              
229             [Collect / TYPES]
230             command = type
231              
232             [Leftovers]
233              
234             [Region / postlude]
235              
236             [GenerateSection / generate SUPPORT]
237             title = SUPPORT
238             main_module_only = 0
239             text = <template>
240             [AllowOverride / allow override SUPPORT]
241             header_re = ^(SUPPORT|BUGS)\b
242             action = prepend
243             match_anywhere = 0
244              
245             [Authors]
246             [AllowOverride / allow override AUTHOR]
247             header_re = ^AUTHORS?\b
248             action = replace
249             match_anywhere = 0
250              
251             [Contributors]
252             :version = 0.008
253              
254             [Legal]
255             :version = 4.011
256             header = COPYRIGHT AND <licence filename>
257              
258             [Region / footer]
259              
260             This is also equivalent (other than section ordering) to:
261              
262             [-Transformer / List]
263             transformer = List
264             [-Transformer / Verbatim]
265             transformer = Verbatim
266              
267             [Region / header]
268             [@Default]
269              
270             [Collect / TYPES]
271             command = type
272              
273             [GenerateSection / generate SUPPORT]
274             title = SUPPORT
275             main_module_only = 0
276             text = <template>
277             [AllowOverride / allow override SUPPORT]
278             header_re = ^(SUPPORT|BUGS)
279             action = prepend
280             match_anywhere = 0
281              
282             [Authors]
283             [Contributors]
284             :version = 0.008
285              
286             [Region / footer]
287              
288             =head1 OPTIONS
289              
290             None at this time. (The bundle is never instantiated, so this doesn't seem to
291             be possible without updates to L<Pod::Weaver>.)
292              
293             =head1 OVERRIDING A SPECIFIC SECTION
294              
295             This F<weaver.ini> will let you use a custom C<COPYRIGHT AND LICENCE> section and still use the plugin bundle:
296              
297             [@Author::ETHER]
298             [AllowOverride / OverrideLegal]
299             header_re = ^COPYRIGHT
300             match_anywhere = 1
301              
302             =head1 ADDING STOPWORDS FOR SPELLING TESTS
303              
304             As noted in L<Dist::Zilla::PluginBundle::Author::ETHER>, stopwords for
305             spelling tests can be added by adding a directive to pod:
306              
307             =for stopwords foo bar baz
308              
309             However, if the stopword appears in the module's abstract, it is moved to the
310             C<NAME> section, which will be above your stopword directive. You can handle
311             this by declaring the stopword in the special C<header> section, which will be
312             woven ahead of everything else:
313              
314             =for :header
315             =for stopwords foo bar baz
316              
317             =head1 SEE ALSO
318              
319             =over 4
320              
321             =item *
322              
323             L<Pod::Weaver>
324              
325             =item *
326              
327             L<Pod::Weaver::PluginBundle::Default>
328              
329             =item *
330              
331             L<Dist::Zilla::Plugin::PodWeaver>
332              
333             =item *
334              
335             L<Dist::Zilla::PluginBundle::Author::ETHER>
336              
337             =item *
338              
339             L<Dist::Zilla::MintingProfile::Author::ETHER>
340              
341             =back
342              
343             =head1 NAMING SCHEME
344              
345             =for stopwords KENTNL
346              
347             This distribution follows best practices for author-oriented plugin bundles; for more information,
348             see L<KENTNL's distribution|Dist::Zilla::PluginBundle::Author::KENTNL/NAMING-SCHEME>.
349              
350             =head1 SUPPORT
351              
352             Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=Dist-Zilla-PluginBundle-Author-ETHER>
353             (or L<bug-Dist-Zilla-PluginBundle-Author-ETHER@rt.cpan.org|mailto:bug-Dist-Zilla-PluginBundle-Author-ETHER@rt.cpan.org>).
354              
355             There is also a mailing list available for users of this distribution, at
356             L<http://dzil.org/#mailing-list>.
357              
358             There is also an irc channel available for users of this distribution, at
359             L<C<#distzilla> on C<irc.perl.org>|irc://irc.perl.org/#distzilla>.
360              
361             I am also usually active on irc, as 'ether' at C<irc.perl.org> and C<irc.libera.chat>.
362              
363             =head1 AUTHOR
364              
365             Karen Etheridge <ether@cpan.org>
366              
367             =head1 COPYRIGHT AND LICENCE
368              
369             This software is copyright (c) 2013 by Karen Etheridge.
370              
371             This is free software; you can redistribute it and/or modify it under
372             the same terms as the Perl 5 programming language system itself.
373              
374             =cut