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