File Coverage

lib/Pod/Weaver/PluginBundle/Author/AJNN/License.pm
Criterion Covered Total %
statement 31 35 88.5
branch 1 4 25.0
condition 1 3 33.3
subroutine 10 10 100.0
pod 0 2 0.0
total 43 54 79.6


line stmt bran cond sub pod time code
1 3     3   1403 use 5.026;
  3         17  
2 3     3   26 use warnings;
  3         9  
  3         187  
3              
4             package Pod::Weaver::PluginBundle::Author::AJNN::License;
5             # ABSTRACT: Pod section for copyright and license statement
6             $Pod::Weaver::PluginBundle::Author::AJNN::License::VERSION = '0.05';
7              
8 3     3   20 use Carp qw(croak);
  3         17  
  3         193  
9 3     3   20 use Moose;
  3         7  
  3         34  
10 3     3   22164 use namespace::autoclean;
  3         7  
  3         41  
11 3     3   1422 use Pod::Elemental::Element::Nested;
  3         118996  
  3         114  
12 3     3   37 use Pod::Elemental::Element::Pod5::Ordinary;
  3         8  
  3         106  
13 3     3   556 use Software::License 0.103014; # for spdx_expression
  3         9326  
  3         1069  
14              
15             with 'Pod::Weaver::Role::Section';
16              
17              
18             our $HEADER = 'COPYRIGHT AND LICENSE';
19              
20              
21             sub weave_section {
22 3     3 0 1756 my ($self, $document, $input) = @_;
23            
24             my $notice = $self->notice_maybe_mangled(
25             $input->{license},
26             $input->{authors},
27 3         38 );
28            
29 3         133 push $document->children->@*, Pod::Elemental::Element::Nested->new({
30             command => 'head1',
31             content => $HEADER,
32             children => [ Pod::Elemental::Element::Pod5::Ordinary->new({
33             content => $notice,
34             })],
35             });
36             }
37              
38              
39             sub notice_maybe_mangled {
40 6     6 0 349 my (undef, $license, $authors) = @_;
41            
42 6         62 my $notice = $license->notice;
43 6         9856 $notice =~ s/^\s+//;
44 6         108 $notice =~ s/\s+$//;
45            
46             # I prefer artistic_2 because I find the perl_5 terms too limiting.
47             # At the same time, I'm aware that some people don't consider perl_5
48             # to match the definition in section (4) (c) (ii) of artistic_2.
49             # I would tend to disagree, but IANAL. To avoid any possible doubt
50             # about my intentions, I choose to explicitly offer both licenses.
51            
52 6 50 33     47 return $notice if $license->spdx_expression ne 'Artistic-2.0'
53             || $authors->[0] !~ m/<ajnn.cpan\.org>/;
54 0 0         croak "Unsupported declaration of multiple authors in dist.ini" if @$authors > 1;
55            
56 0           $notice =~ s/This is free software, licensed under.*//s;
57 0           $notice .= <<END;
58             This is free software; you can redistribute it and/or modify it under
59             the terms of the Artistic License 2.0 or (at your option) the same terms
60             as the Perl 5 programming language system itself.
61             END
62 0           return $notice;
63             }
64              
65              
66             __PACKAGE__->meta->make_immutable;
67              
68             1;
69              
70             __END__
71              
72             =pod
73              
74             =encoding UTF-8
75              
76             =head1 NAME
77              
78             Pod::Weaver::PluginBundle::Author::AJNN::License - Pod section for copyright and license statement
79              
80             =head1 VERSION
81              
82             version 0.05
83              
84             =head1 SYNOPSIS
85              
86             package Pod::Weaver::PluginBundle::Author::AJNN;
87            
88             use Pod::Weaver::PluginBundle::Author::AJNN::License;
89            
90             sub mvp_bundle_config {
91             return (
92             ...,
93             [ '@AJNN/License', __PACKAGE__ . '::License', {}, ],
94             )
95             }
96              
97             =head1 DESCRIPTION
98              
99             This package provides AJNN's customised copyright and license statement.
100              
101             In particular, for distributions which declare their license as Artistic-2.0
102             I<and> which declare AJNN as their only author, the license statement is
103             modified to I<explicitly> allow reuse under the same terms as the S<Perl 5>
104             programming language system itself as well. Effectively, this results in
105             triple-licensing under (Artistic-2.0 OR Artistic-1.0-Perl OR GPL-1.0-or-later),
106             at the choice of the user.
107              
108             Reuse under Perl 5 terms might already be allowed under S<section (4) (c) (ii)>
109             of Artistic-2.0, but I like to state this explicitly for the avoidance of doubt.
110              
111             =head1 BUGS
112              
113             Multiple authors are unsupported.
114              
115             =head1 SEE ALSO
116              
117             L<Pod::Weaver::PluginBundle::Author::AJNN>
118              
119             L<Pod::Weaver::Section::Legal>
120              
121             =head1 AUTHOR
122              
123             Arne Johannessen <ajnn@cpan.org>
124              
125             If you contact me by email, please make sure you include the word
126             "Perl" in your subject header to help beat the spam filters.
127              
128             =head1 COPYRIGHT AND LICENSE
129              
130             Arne Johannessen has dedicated the work to the Commons by waiving all of his
131             or her rights to the work worldwide under copyright law and all related or
132             neighboring legal rights he or she had in the work, to the extent allowable by
133             law.
134              
135             Works under CC0 do not require attribution. When citing the work, you should
136             not imply endorsement by the author.
137              
138             =cut