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.018;
2             # ABSTRACT: a section for the copyright and license
3              
4 6     6   22814 use Moose;
  6         19  
  6         51  
5             with 'Pod::Weaver::Role::Section';
6              
7             # BEGIN BOILERPLATE
8 6     6   40633 use v5.20.0;
  6         23  
9 6     6   38 use warnings;
  6         18  
  6         242  
10 6     6   44 use utf8;
  6         16  
  6         75  
11 6     6   200 no feature 'switch';
  6         14  
  6         741  
12 6     6   44 use experimental qw(postderef postderef_qq); # This experiment gets mainlined.
  6         17  
  6         51  
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 36 my ($self, $document, $input) = @_;
59              
60 9 50       87 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         85 my $notice = $input->{license}->notice;
66 9         43436 chomp $notice;
67              
68 9 100       459 if ( $self->_has_license_file ) {
69 1         5 $notice .= "\n\nThe full text of the license can be found in the\nF<";
70 1         31 $notice .= $self->license_file . "> file included with this distribution.";
71             }
72              
73 9         283 $self->log_debug('adding ' . $self->header . ' section');
74              
75 9         503 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.018
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 SUPPORT
117              
118             This module has the same support period as perl itself: it supports the two
119             most recent versions of perl. (That is, if the most recently released version
120             is v5.40, then this module should work on both v5.40 and v5.38.)
121              
122             Although it may work on older versions of perl, no guarantee is made that the
123             minimum required version will not be increased. The version may be increased
124             for any reason, and there is no promise that patches will be accepted to lower
125             the minimum required perl.
126              
127             =head1 ATTRIBUTES
128              
129             =head2 license_file
130              
131             Specify the name of the license file and an extra line of text will be added
132             telling users to check the file for the full text of the license.
133              
134             Defaults to none.
135              
136             =head2 header
137              
138             The title of the header to be added.
139             (default: "COPYRIGHT AND LICENSE")
140              
141             =head1 AUTHOR
142              
143             Ricardo SIGNES <rjbs@semiotic.systems>
144              
145             =head1 COPYRIGHT AND LICENSE
146              
147             This software is copyright (c) 2021 by Ricardo SIGNES.
148              
149             This is free software; you can redistribute it and/or modify it under
150             the same terms as the Perl 5 programming language system itself.
151              
152             =cut