File Coverage

blib/lib/Pod/Loom/Template/Default.pm
Criterion Covered Total %
statement 65 69 94.2
branch 12 18 66.6
condition 6 8 75.0
subroutine 19 19 100.0
pod 14 14 100.0
total 116 128 90.6


line stmt bran cond sub pod time code
1             #---------------------------------------------------------------------
2             package Pod::Loom::Template::Default;
3             #
4             # Copyright 2009 Christopher J. Madsen
5             #
6             # Author: Christopher J. Madsen <perl@cjmweb.net>
7             # Created: 6 Oct 2009
8             #
9             # This program is free software; you can redistribute it and/or modify
10             # it under the same terms as Perl itself.
11             #
12             # This program is distributed in the hope that it will be useful,
13             # but WITHOUT ANY WARRANTY; without even the implied warranty of
14             # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either the
15             # GNU General Public License or the Artistic License for more details.
16             #
17             # ABSTRACT: Default template for Pod::Loom
18             #---------------------------------------------------------------------
19              
20 1     1   20 use 5.008;
  1         2  
  1         63  
21             our $VERSION = '0.05';
22             # This file is part of Pod-Loom 0.08 (March 23, 2014)
23              
24 1     1   5 use Moose;
  1         2  
  1         8  
25             extends 'Pod::Loom::Template';
26              
27 1     1   6113 use Pod::Loom::Template '%E';
  1         3  
  1         1072  
28             #=====================================================================
29              
30              
31             has qw(sort_attr is ro), isa => 'Int | ArrayRef[Str]';
32             has qw(sort_diag is ro), isa => 'Int | ArrayRef[Str]';
33             has qw(sort_method is ro), isa => 'Int | ArrayRef[Str]';
34             has qw(sort_sub is ro), isa => 'Int | ArrayRef[Str]';
35              
36             sub collect_commands
37             {
38 26     26 1 127 [ qw(head1 attr method sub diag) ];
39             } # end collect_commands
40              
41             #---------------------------------------------------------------------
42             # Don't forget to update DESCRIPTION and sort_method if changing this:
43             our @sections =
44             (qw(NAME VERSION SYNOPSIS DESCRIPTION ATTRIBUTES METHODS SUBROUTINES
45             * DIAGNOSTICS),
46             'CONFIGURATION AND ENVIRONMENT',
47             qw(DEPENDENCIES INCOMPATIBILITIES),
48             'BUGS AND LIMITATIONS',
49             'AUTHOR', 'COPYRIGHT AND LICENSE', 'DISCLAIMER OF WARRANTY');
50              
51 13     13   409 sub _build_sections { \@sections };
52             #---------------------------------------------------------------------
53              
54              
55             has qw(abstract is ro isa Str);
56             has qw(module is ro isa Str);
57              
58             sub section_NAME
59             {
60 9     9 1 12 my ($self, $title) = @_;
61              
62 9         27 my ($module, $abstract) = $self->required_attr($title, qw(module abstract));
63              
64 9         38 "=head1 $title\n\n$module - $abstract\n";
65             } # end section_NAME
66             #---------------------------------------------------------------------
67              
68              
69             has qw(version is ro isa Str);
70             has qw(version_desc is ro isa Str);
71              
72             sub section_VERSION
73             {
74 13     13 1 17 my ($self, $title) = @_;
75              
76 13 50       370 if ($self->version_desc) {
77 0         0 return "=head1 $title\n\n$E{$self->version_desc}\n";
78             }
79              
80 13         427 my $version = $self->version;
81              
82 13 50       26 return "=head1 $title\n\nversion $version\n" if defined $version;
83              
84 13         33 ''; # Otherwise, omit VERSION
85             } # end section_VERSION
86             #---------------------------------------------------------------------
87              
88              
89             sub section_ATTRIBUTES
90             {
91 13     13 1 15 my $self = shift;
92              
93 13         38 $self->joined_section(attr => 'head2', @_);
94             } # end section_ATTRIBUTES
95             #---------------------------------------------------------------------
96              
97              
98             sub section_METHODS
99             {
100 13     13 1 17 my $self = shift;
101              
102 13         29 $self->joined_section(method => 'head2', @_);
103             } # end section_METHODS
104              
105             #---------------------------------------------------------------------
106              
107              
108             sub section_SUBROUTINES
109             {
110 13     13 1 12 my $self = shift;
111              
112 13         26 $self->joined_section(sub => 'head2', @_);
113             } # end section_SUBROUTINES
114              
115             #---------------------------------------------------------------------
116             sub override_section
117             {
118 7     7 1 9 my ($self, $title) = @_;
119              
120 7   33     65 return ($title eq 'ATTRIBUTES' or
121             $title eq 'DIAGNOSTICS' or
122             $title eq 'METHODS' or
123             $title eq 'SUBROUTINES');
124             } # end override_section
125             #---------------------------------------------------------------------
126              
127              
128             sub section_DIAGNOSTICS
129             {
130 13     13 1 13 my $self = shift;
131              
132 13         29 $self->joined_section(diag => 'item', @_);
133             } # end section_DIAGNOSTICS
134             #---------------------------------------------------------------------
135              
136              
137             sub section_CONFIGURATION_AND_ENVIRONMENT
138             {
139 1     1 1 2 my ($self, $title) = @_;
140              
141 1         3 my ($module) = $self->required_attr($title, 'module');
142              
143 1         5 return <<"END CONFIGURATION";
144             \=head1 $title
145              
146             $module requires no configuration files or environment variables.
147             END CONFIGURATION
148             } # end section_CONFIGURATION_AND_ENVIRONMENT
149             #---------------------------------------------------------------------
150              
151              
152             sub section_INCOMPATIBILITIES
153             {
154 1     1 1 1 my ($self, $title) = @_;
155              
156 1         4 "=head1 $title\n\nNone reported.\n";
157             } # end section_INCOMPATIBILITIES
158             #---------------------------------------------------------------------
159              
160              
161             sub section_BUGS_AND_LIMITATIONS
162             {
163 1     1 1 2 my ($self, $title) = @_;
164              
165 1         5 "=head1 $title\n\nNo bugs have been reported.\n";
166             } # end section_BUGS_AND_LIMITATIONS
167             #---------------------------------------------------------------------
168              
169              
170             has qw(dist is ro isa Str);
171             has qw(authors is ro isa ArrayRef[Str]);
172             has qw(bugtracker is ro isa Maybe[HashRef]);
173             has qw(repository is ro isa Maybe[Str]);
174              
175             sub section_AUTHOR
176             {
177 13     13 1 15 my ($self, $title) = @_;
178              
179 13         29 my ($dist, $authors) = $self->required_attr($title, qw(dist authors));
180              
181 13         25 my $pod = "=head1 $title\n\n";
182              
183 13         21 foreach my $authorCredit (@$authors) {
184 13 50       72 if ($authorCredit =~ /(.*\S)\s*(<.*>)$/) {
185 13         25 my ($author, $email) = ($1, $2);
186 13         43 $email =~ s/@/ AT /g;
187 13         46 $pod .= "$author S<C<< $email >>>\n";
188             } else {
189 0         0 $pod .= "$authorCredit\n";
190             }
191             } # end foreach $authorCredit in @$authors
192              
193 13   100     351 my $bugs = $self->bugtracker || {
194             mailto => "bug-$dist\@rt.cpan.org",
195             web => "http://rt.cpan.org/Public/Bug/Report.html?Queue=$dist",
196             };
197              
198 13 100 100     45 if (my $mailto = $bugs->{mailto} or $bugs->{web}) {
199 12         15 $pod .= "\nPlease report any bugs or feature requests\n";
200              
201 12 100       19 if ($mailto) {
202 11         26 $mailto =~ s/@/ AT /g;
203 11         21 $pod .= "to S<C<< <$mailto> >>>";
204             }
205              
206 12 100       24 if ($bugs->{web}) {
207 11 100       19 $pod .= "\nor " if $mailto;
208 11         24 $pod .= "through the web interface at\nL<< $bugs->{web} >>";
209             }
210 12         13 $pod .= ".\n";
211             } # end if bugtracker
212              
213 13         347 my $repo = $self->repository;
214 13 50       27 if ($repo) {
215 0 0       0 $repo = "L<< $repo >>" if $repo =~ /^https?:/;
216              
217 0         0 $pod .= <<"END REPOSITORY";
218             \nYou can follow or contribute to ${dist}'s development at
219             $repo.
220             END REPOSITORY
221             } # end if $self->repository
222              
223 13         42 return $pod;
224             } # end section_AUTHOR
225             #---------------------------------------------------------------------
226              
227              
228             has qw(license_notice is ro isa Str);
229              
230             sub section_COPYRIGHT_AND_LICENSE
231             {
232 1     1 1 2 my ($self, $title) = @_;
233              
234 1         3 my ($notice) = $self->required_attr($title, 'license_notice');
235              
236             #FIXME other license
237 1         4 "=head1 $title\n\n$notice";
238             } # end section_COPYRIGHT_AND_LICENSE
239             #---------------------------------------------------------------------
240              
241              
242             sub section_DISCLAIMER_OF_WARRANTY
243             {
244 1     1 1 2 my ($self, $title) = @_;
245              
246 1         5 return <<"END DISCLAIMER";
247             \=head1 $title
248              
249             BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
250             FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
251             OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
252             PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
253             EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
254             WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
255             ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
256             YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
257             NECESSARY SERVICING, REPAIR, OR CORRECTION.
258              
259             IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
260             WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
261             REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENSE, BE
262             LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL,
263             OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
264             THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
265             RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
266             FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
267             SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
268             SUCH DAMAGES.
269             END DISCLAIMER
270             } # end section_DISCLAIMER_OF_WARRANTY
271              
272             #=====================================================================
273             # Package Return Value:
274              
275 1     1   8 no Moose;
  1         1  
  1         7  
276             __PACKAGE__->meta->make_immutable;
277             1;
278              
279             __END__
280              
281             =head1 NAME
282              
283             Pod::Loom::Template::Default - Default template for Pod::Loom
284              
285             =head1 VERSION
286              
287             This document describes version 0.05 of
288             Pod::Loom::Template::Default, released March 23, 2014
289             as part of Pod-Loom version 0.08.
290              
291             =head1 DESCRIPTION
292              
293             Pod::Loom::Template::Default is the default template for Pod::Loom.
294             It places the sections in this order:
295              
296             + NAME
297             + VERSION
298             SYNOPSIS
299             DESCRIPTION
300             ++ ATTRIBUTES
301             ++ METHODS
302             ++ SUBROUTINES
303             *
304             ++ DIAGNOSTICS
305             + CONFIGURATION AND ENVIRONMENT
306             DEPENDENCIES
307             + INCOMPATIBILITIES
308             + BUGS AND LIMITATIONS
309             + AUTHOR
310             + COPYRIGHT AND LICENSE
311             + DISCLAIMER OF WARRANTY
312              
313             Sections marked with C<+> will be provided by this template if they do
314             not appear in the original document. Sections marked C<++> will be
315             appended to even if they do appear in the original document (if the
316             document contains any entries that belong in that section).
317              
318             See L<Pod::Loom::Template/"Controlling the template"> for details on
319             how to rearrange sections and sort entries.
320              
321             =head1 ATTRIBUTES
322              
323             =head2 abstract
324              
325             The abstract for the module. Required by NAME.
326              
327              
328             =head2 authors
329              
330             An arrayref of author names (with optional email address in C<< <> >>).
331             Required by AUTHOR.
332              
333              
334             =head2 bugtracker
335              
336             An optional hashref giving the location of the distribution's public
337             bugtracker. If not specified, defaults to the CPAN RT. If present,
338             may have keys C<web> and C<mailto>.
339              
340              
341             =head2 dist
342              
343             The name of the distribution that contains this module.
344             Required by AUTHOR.
345              
346              
347             =head2 license_notice
348              
349             The complete text of the COPYRIGHT AND LICENSE section.
350             Required by COPYRIGHT AND LICENSE.
351              
352              
353             =head2 module
354              
355             The name of the module.
356             Required by NAME and CONFIGURATION AND ENVIRONMENT.
357              
358              
359             =head2 repository
360              
361             An optional string giving the location of the distribution's public
362             source code repository.
363              
364              
365             =head2 sort_attr
366              
367             This should be 0, 1, or an arrayref. If non 0, attributes will be
368             sorted. An arrayref lists the attributes that should come first, with
369             the remaining attributes in alphabetical order.
370             See L<Pod::Loom::Template/"Pod::Loom-sort_COMMAND">.
371              
372              
373             =head2 sort_diag
374              
375             Just like C<sort_attr>, but for diagnostic messages.
376              
377              
378             =head2 sort_method
379              
380             Just like C<sort_attr>, but for methods.
381              
382              
383             =head2 sort_sub
384              
385             Just like C<sort_attr>, but for subroutines.
386              
387              
388             =head2 version
389              
390             The version number of the module. Used by VERSION.
391              
392              
393             =head2 version_desc
394              
395             The complete text of the VERSION section. Used by VERSION.
396              
397             =head1 METHODS
398              
399             =head2 section_NAME
400              
401             <module> - <abstract>
402              
403              
404             =head2 section_VERSION
405              
406             <version_desc>
407              
408             Or, if L</"version_desc"> is not set:
409              
410             version <version>
411              
412             If neither version_desc nor L</"version"> is set, no VERSION section
413             will be added.
414              
415              
416             =head2 section_ATTRIBUTES
417              
418             If the original document contains any C<=attr> commands, they will be
419             converted to C<=head2> commands in this section. If there are no
420             attributes, no ATTRIBUTES section will be added.
421              
422              
423             =head2 section_METHODS
424              
425             This is just like ATTRIBUTES, except it gathers C<=method> entries.
426              
427              
428             =head2 section_SUBROUTINES
429              
430             This is just like ATTRIBUTES, except it gathers C<=sub> entries.
431              
432              
433             =head2 section_DIAGNOSTICS
434              
435             If the original document contains any C<=diag> commands, they will be
436             converted to an C<=item> list in this section. If there are no
437             diagnostics, no DIAGNOSTICS section will be added.
438              
439              
440             =head2 section_CONFIGURATION_AND_ENVIRONMENT
441              
442             <module> requires no configuration files or environment variables.
443              
444              
445             =head2 section_INCOMPATIBILITIES
446              
447             None reported.
448              
449              
450             =head2 section_BUGS_AND_LIMITATIONS
451              
452             No bugs have been reported.
453              
454              
455             =head2 section_AUTHOR
456              
457             First, it lists the authors from the L</"authors"> attribute
458             (converting @ to AT in email addresses). Then it directs bug reports
459             to the distribution's queue at rt.cpan.org (using the L</"dist"> attribute):
460              
461             Please report any bugs or feature requests to
462             S<C<< <bug-<dist> AT rt.cpan.org> >>>,
463             or through the web interface at
464             L<http://rt.cpan.org/Public/Bug/Report.html?Queue=<dist>>
465              
466             And, if L</"repository"> is set:
467              
468             You can follow or contribute to <dist>'s development at
469             <repository>.
470              
471              
472             =head2 section_COPYRIGHT_AND_LICENSE
473              
474             <license_notice>
475              
476              
477             =head2 section_DISCLAIMER_OF_WARRANTY
478              
479             See L</"DISCLAIMER OF WARRANTY">.
480              
481             =head1 CONFIGURATION AND ENVIRONMENT
482              
483             Pod::Loom::Template::Default requires no configuration files or environment variables.
484              
485             =head1 INCOMPATIBILITIES
486              
487             None reported.
488              
489             =head1 BUGS AND LIMITATIONS
490              
491             No bugs have been reported.
492              
493             =head1 AUTHOR
494              
495             Christopher J. Madsen S<C<< <perl AT cjmweb.net> >>>
496              
497             Please report any bugs or feature requests
498             to S<C<< <bug-Pod-Loom AT rt.cpan.org> >>>
499             or through the web interface at
500             L<< http://rt.cpan.org/Public/Bug/Report.html?Queue=Pod-Loom >>.
501              
502             You can follow or contribute to Pod-Loom's development at
503             L<< https://github.com/madsen/pod-loom >>.
504              
505             =head1 COPYRIGHT AND LICENSE
506              
507             This software is copyright (c) 2014 by Christopher J. Madsen.
508              
509             This is free software; you can redistribute it and/or modify it under
510             the same terms as the Perl 5 programming language system itself.
511              
512             =head1 DISCLAIMER OF WARRANTY
513              
514             BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
515             FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
516             OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
517             PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
518             EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
519             WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
520             ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
521             YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
522             NECESSARY SERVICING, REPAIR, OR CORRECTION.
523              
524             IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
525             WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
526             REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENSE, BE
527             LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL,
528             OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
529             THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
530             RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
531             FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
532             SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
533             SUCH DAMAGES.
534              
535             =cut