File Coverage

blib/lib/Pod/Weaver/Section/ReplaceLegal.pm
Criterion Covered Total %
statement 8 8 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod 2 2 100.0
total 14 14 100.0


line stmt bran cond sub pod time code
1             package Pod::Weaver::Section::ReplaceLegal;
2              
3             # ABSTRACT: Add or replace a COPYRIGHT AND LICENSE section.
4              
5 3     3   119023 use Moose;
  3         6  
  3         23  
6              
7             extends 'Pod::Weaver::Section::Legal';
8             with 'Pod::Weaver::Role::SectionReplacer';
9              
10             our $VERSION = '0.99_02';
11              
12             has year => (
13             is => 'ro',
14             isa => 'Str',
15             );
16              
17             around weave_section => sub
18             {
19             my ( $orig, $self, $document, $input ) = @_;
20              
21             if( my $year = $self->year )
22             {
23             return unless $input->{license};
24             $year =~ s/current/(localtime)[ 5 ] + 1900/e;
25             $input->{ license }->{ year } = $year;
26             }
27              
28             return( $self->$orig( $document, $input ) );
29             };
30              
31 2     2 1 936 sub default_section_name { 'COPYRIGHT AND LICENSE' }
32             sub default_section_aliases
33             {
34             [
35 2     2 1 8122 'LICENSE AND COPYRIGHT',
36             'LICENSE & COPYRIGHT',
37             'COPYRIGHT & LICENSE',
38             ]
39             }
40              
41 3     3   14983 no Moose;
  3         7  
  3         16  
42             1;
43              
44             __END__
45              
46              
47             =pod
48              
49             =head1 NAME
50              
51             Pod::Weaver::Section::ReplaceLegal - Add or replace a COPYRIGHT AND LICENSE section.
52              
53             =head1 VERSION
54              
55             version 0.99_02
56              
57             =head1 OVERVIEW
58              
59             This section plugin provides the same behaviour as
60             L<Pod::Weaver::Section::Legal> but with the
61             L<Pod::Weaver::Role::SectionReplacer> role applied.
62              
63             It will produce a hunk of Pod giving the copyright and license
64             information for the document, like this:
65              
66             =head1 COPYRIGHT AND LICENSE
67              
68             This document is copyright (C) 1991, Ricardo Signes.
69              
70             This document is available under the blah blah blah.
71              
72             This plugin will do nothing if no C<license> input parameter is available. The
73             C<license> is expected to be a L<Software::License> object.
74              
75             =head1 CUSTOMIZATION
76              
77             In addition to the standard L<Pod::Weaver::Section::Legal> behaviour,
78             you may customize the behaviour of L<Pod::Weaver::Section::ReplaceLegal>
79             with the following options in your C<weaver.ini>:
80              
81             =over
82              
83             =item B<year> = I<year string>
84              
85             You may supply a copyright year, to be used by L<Software::License> via the
86             C<year> parameter.
87              
88             The year may be a number or it may be an arbitrary string.
89              
90             Within any string the word 'current' will be replaced by the current year.
91              
92             For example in your C<weaver.ini>:
93              
94             [ReplaceLegal]
95             year = 2005-current
96              
97             This will, in the year 2010, produce the year string 2005-2010 for use
98             within the L<Software::License> object.
99              
100             =back
101              
102             =for readme stop
103              
104             =begin :internal
105              
106             =head1 INTERNAL METHODS
107              
108             =over
109              
110             =item default_section_name
111              
112             Gives the name used as the heading for this section.
113              
114             =item default_section_aliases
115              
116             Gives alternative names that an existing section might be using.
117              
118             =back
119              
120             =end :internal
121              
122             =for readme continue
123              
124             =head1 AUTHOR
125              
126             Sam Graham <libpod-weaver-pluginbundle-replaceboilerplate-perl BLAHBLAH illusori.co.uk>
127              
128             =head1 COPYRIGHT AND LICENSE
129              
130             This software is copyright (c) 2010 by Sam Graham <libpod-weaver-pluginbundle-replaceboilerplate-perl BLAHBLAH illusori.co.uk>.
131              
132             This is free software; you can redistribute it and/or modify it under
133             the same terms as the Perl 5 programming language system itself.
134              
135             =cut