File Coverage

blib/lib/Pod/Weaver/Section/Legal.pm
Criterion Covered Total %
statement 13 15 86.6
branch 3 4 75.0
condition n/a
subroutine 2 2 100.0
pod 0 1 0.0
total 18 22 81.8


line stmt bran cond sub pod time code
1             package Pod::Weaver::Section::Legal;
2             # ABSTRACT: a section for the copyright and license
3             $Pod::Weaver::Section::Legal::VERSION = '4.017';
4 6     6   24191 use Moose;
  6         16  
  6         55  
5             with 'Pod::Weaver::Role::Section';
6              
7             #pod =head1 OVERVIEW
8             #pod
9             #pod This section plugin will produce a hunk of Pod giving the copyright and license
10             #pod information for the document, like this:
11             #pod
12             #pod =head1 COPYRIGHT AND LICENSE
13             #pod
14             #pod This document is copyright (C) 1991, Ricardo Signes.
15             #pod
16             #pod This document is available under the blah blah blah.
17             #pod
18             #pod This plugin will do nothing if no C<license> input parameter is available. The
19             #pod C<license> is expected to be a L<Software::License> object.
20             #pod
21             #pod =cut
22              
23             #pod =attr license_file
24             #pod
25             #pod Specify the name of the license file and an extra line of text will be added
26             #pod telling users to check the file for the full text of the license.
27             #pod
28             #pod Defaults to none.
29             #pod
30             #pod =attr header
31             #pod
32             #pod The title of the header to be added.
33             #pod (default: "COPYRIGHT AND LICENSE")
34             #pod
35             #pod =cut
36              
37             has header => (
38             is => 'ro',
39             isa => 'Str',
40             default => 'COPYRIGHT AND LICENSE',
41             );
42              
43             has license_file => (
44             is => 'ro',
45             isa => 'Str',
46             predicate => '_has_license_file',
47             );
48              
49             sub weave_section {
50 9     9 0 40 my ($self, $document, $input) = @_;
51              
52 9 50       84 unless ($input->{license}) {
53 0         0 $self->log_debug('no license specified, not adding a ' . $self->header . ' section');
54 0         0 return;
55             }
56              
57 9         115 my $notice = $input->{license}->notice;
58 9         46109 chomp $notice;
59              
60 9 100       429 if ( $self->_has_license_file ) {
61 1         5 $notice .= "\n\nThe full text of the license can be found in the\nF<";
62 1         30 $notice .= $self->license_file . "> file included with this distribution.";
63             }
64              
65 9         280 $self->log_debug('adding ' . $self->header . ' section');
66              
67 9         276 push @{ $document->children },
  9         262  
68             Pod::Elemental::Element::Nested->new({
69             command => 'head1',
70             content => $self->header,
71             children => [
72             Pod::Elemental::Element::Pod5::Ordinary->new({ content => $notice }),
73             ],
74             });
75             }
76              
77             __PACKAGE__->meta->make_immutable;
78             1;
79              
80             __END__
81              
82             =pod
83              
84             =encoding UTF-8
85              
86             =head1 NAME
87              
88             Pod::Weaver::Section::Legal - a section for the copyright and license
89              
90             =head1 VERSION
91              
92             version 4.017
93              
94             =head1 OVERVIEW
95              
96             This section plugin will produce a hunk of Pod giving the copyright and license
97             information for the document, like this:
98              
99             =head1 COPYRIGHT AND LICENSE
100              
101             This document is copyright (C) 1991, Ricardo Signes.
102              
103             This document is available under the blah blah blah.
104              
105             This plugin will do nothing if no C<license> input parameter is available. The
106             C<license> is expected to be a L<Software::License> object.
107              
108             =head1 ATTRIBUTES
109              
110             =head2 license_file
111              
112             Specify the name of the license file and an extra line of text will be added
113             telling users to check the file for the full text of the license.
114              
115             Defaults to none.
116              
117             =head2 header
118              
119             The title of the header to be added.
120             (default: "COPYRIGHT AND LICENSE")
121              
122             =head1 AUTHOR
123              
124             Ricardo SIGNES <rjbs@cpan.org>
125              
126             =head1 COPYRIGHT AND LICENSE
127              
128             This software is copyright (c) 2021 by Ricardo SIGNES.
129              
130             This is free software; you can redistribute it and/or modify it under
131             the same terms as the Perl 5 programming language system itself.
132              
133             =cut