File Coverage

blib/lib/Pod/Weaver/Section/Legal.pm
Criterion Covered Total %
statement 26 28 92.8
branch 3 4 75.0
condition n/a
subroutine 7 7 100.0
pod 0 1 0.0
total 36 40 90.0


line stmt bran cond sub pod time code
1             package Pod::Weaver::Section::Legal 4.019;
2             # ABSTRACT: a section for the copyright and license
3              
4 6     6   23914 use Moose;
  6         17  
  6         53  
5             with 'Pod::Weaver::Role::Section';
6              
7             # BEGIN BOILERPLATE
8 6     6   43576 use v5.20.0;
  6         25  
9 6     6   49 use warnings;
  6         42  
  6         247  
10 6     6   45 use utf8;
  6         25  
  6         71  
11 6     6   243 no feature 'switch';
  6         15  
  6         773  
12 6     6   50 use experimental qw(postderef postderef_qq); # This experiment gets mainlined.
  6         18  
  6         72  
13             # END BOILERPLATE
14              
15             #pod =head1 OVERVIEW
16             #pod
17             #pod This section plugin will produce a hunk of Pod giving the copyright and license
18             #pod information for the document, like this:
19             #pod
20             #pod =head1 COPYRIGHT AND LICENSE
21             #pod
22             #pod This document is copyright (C) 1991, Ricardo Signes.
23             #pod
24             #pod This document is available under the blah blah blah.
25             #pod
26             #pod This plugin will do nothing if no C<license> input parameter is available. The
27             #pod C<license> is expected to be a L<Software::License> object.
28             #pod
29             #pod =cut
30              
31             #pod =attr license_file
32             #pod
33             #pod Specify the name of the license file and an extra line of text will be added
34             #pod telling users to check the file for the full text of the license.
35             #pod
36             #pod Defaults to none.
37             #pod
38             #pod =attr header
39             #pod
40             #pod The title of the header to be added.
41             #pod (default: "COPYRIGHT AND LICENSE")
42             #pod
43             #pod =cut
44              
45             has header => (
46             is => 'ro',
47             isa => 'Str',
48             default => 'COPYRIGHT AND LICENSE',
49             );
50              
51             has license_file => (
52             is => 'ro',
53             isa => 'Str',
54             predicate => '_has_license_file',
55             );
56              
57             sub weave_section {
58 9     9 0 31 my ($self, $document, $input) = @_;
59              
60 9 50       79 unless ($input->{license}) {
61 0         0 $self->log_debug('no license specified, not adding a ' . $self->header . ' section');
62 0         0 return;
63             }
64              
65 9         87 my $notice = $input->{license}->notice;
66 9         40443 chomp $notice;
67              
68 9 100       416 if ( $self->_has_license_file ) {
69 1         6 $notice .= "\n\nThe full text of the license can be found in the\nF<";
70 1         33 $notice .= $self->license_file . "> file included with this distribution.";
71             }
72              
73 9         294 $self->log_debug('adding ' . $self->header . ' section');
74              
75 9         525 push $document->children->@*,
76             Pod::Elemental::Element::Nested->new({
77             command => 'head1',
78             content => $self->header,
79             children => [
80             Pod::Elemental::Element::Pod5::Ordinary->new({ content => $notice }),
81             ],
82             });
83             }
84              
85             __PACKAGE__->meta->make_immutable;
86             1;
87              
88             __END__
89              
90             =pod
91              
92             =encoding UTF-8
93              
94             =head1 NAME
95              
96             Pod::Weaver::Section::Legal - a section for the copyright and license
97              
98             =head1 VERSION
99              
100             version 4.019
101              
102             =head1 OVERVIEW
103              
104             This section plugin will produce a hunk of Pod giving the copyright and license
105             information for the document, like this:
106              
107             =head1 COPYRIGHT AND LICENSE
108              
109             This document is copyright (C) 1991, Ricardo Signes.
110              
111             This document is available under the blah blah blah.
112              
113             This plugin will do nothing if no C<license> input parameter is available. The
114             C<license> is expected to be a L<Software::License> object.
115              
116             =head1 PERL VERSION
117              
118             This module should work on any version of perl still receiving updates from
119             the Perl 5 Porters. This means it should work on any version of perl released
120             in the last two to three years. (That is, if the most recently released
121             version is v5.40, then this module should work on both v5.40 and v5.38.)
122              
123             Although it may work on older versions of perl, no guarantee is made that the
124             minimum required version will not be increased. The version may be increased
125             for any reason, and there is no promise that patches will be accepted to lower
126             the minimum required perl.
127              
128             =head1 ATTRIBUTES
129              
130             =head2 license_file
131              
132             Specify the name of the license file and an extra line of text will be added
133             telling users to check the file for the full text of the license.
134              
135             Defaults to none.
136              
137             =head2 header
138              
139             The title of the header to be added.
140             (default: "COPYRIGHT AND LICENSE")
141              
142             =head1 AUTHOR
143              
144             Ricardo SIGNES <cpan@semiotic.systems>
145              
146             =head1 COPYRIGHT AND LICENSE
147              
148             This software is copyright (c) 2023 by Ricardo SIGNES.
149              
150             This is free software; you can redistribute it and/or modify it under
151             the same terms as the Perl 5 programming language system itself.
152              
153             =cut