GPL_2/or_later.pm

filter: Statementstmt 100% 38 / 38 Branchbran 100% 2 / 2 Conditioncond 100% 12 / 12 MC/DCmcdc 100% 5 / 5 Subroutinesub 100% 14 / 14 Podpod 100% 7 / 7 totaltotal 100% 78 / 78 CC 7 SCAR 5.9
CC
7
Cov
100%
program
3.0
Program
3.0
base
2.0
CRAP 1.8
« GPL_1/or_later.pm ↑ Summary GPL_3/or_later.pm »
1 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2 #
3 # file: lib/Software/License/GPL_2/or_later.pm
4 #
5 # Copyright © 2015 Van de Bugger
6 #
7 # This file is part of perl-Software-License-OrLaterPack.
8 #
9 # perl-Software-License-OrLaterPack is free software: you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by the Free Software Foundation,
11 # either version 3 of the License, or (at your option) any later version.
12 #
13 # perl-Software-License-OrLaterPack is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
15 # PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License along with
18 # perl-Software-License-OrLaterPack. If not, see <http://www.gnu.org/licenses/>.
19 #
20 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
21  
22 #tt
23 #tt
24 #tt
25 #tt
26 #tt
27 #tt
28 #tt
29 #tt
30 #tt
31 #tt
32 #tt
33 #tt
34 #tt
35 #tt
36 #tt
37 #tt
38 #tt
39  
40  
41 #pod =for :this This is C<Software::License::GPL_2::or_later> module documentation. Read this if you
42 #pod are going to hack or extend the module, or use the module directly.
43 #pod
44 #pod =for :those If you want to use GNU license with "or later" clause read the L<user
45 #pod manual|Software::License::OrLaterPack>. General topics like getting source, building, installing,
46 #pod bug reporting and some others are covered in the F<README> file.
47 #pod
48 #pod =head1 SYNOPSIS
49 #pod
50 #pod my $lic = Software::License::GPL_2::or_later->new( {
51 #pod holder => 'John Doe',
52 #pod year => '2010',
53 #pod program => 'Assa'
54 #pod } );
55 #pod
56 #pod $lic->_abbr; # 'GPL'
57 #pod $lic->abbr; # 'GPLv2+'
58 #pod $lic->_name; # 'GNU General Public License'
59 #pod $lic->name; # 'The GNU General Public License version 2 or later'
60 #pod
61 #pod $lic->notice;
62 #pod # Copyright statement and
63 #pod # standard GNU 3-paragraph license notice.
64 #pod $lic->notice( 'short' );
65 #pod # Copyright statement, license name and
66 #pod # two sentences about free software and warranties.
67 #pod
68 #pod # …and other methods inherited from Software::License::GPL_2
69 #pod # and Software::License.
70 #pod
71 #pod =head1 DESCRIPTION
72 #pod
73 #pod C<Software::License::GPL_2::or_later> is a subclass of C<Software::License::GPL_2>.
74 #pod It overrides few parent methods and introduces few own methods.
75 #pod
76 #pod See documentation on L<Software::License> for a general description of the class interface.
77 #pod
78 #pod =cut
79  
80 package Software::License::GPL_2::or_later;
81  
82 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
83 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
84 2 ▶use version 0.77;
Subroutine BEGIN: called CC=1 SCAR=0.0
85  
86 # ABSTRACT: GPLv2+ license for Software::License infrastructure
87 2 our $VERSION = 'v0.10.2'; # VERSION
88  
89 2 ▶use parent 'Software::License::GPL_2';
Subroutine BEGIN: called CC=1 SCAR=0.0
90 2 ▶use Text::Wrap;
Subroutine BEGIN: called CC=1 SCAR=0.0
91  
92 #pod =attr _abbr
93 #pod
94 #pod Bare abbreviated license name, "GPL".
95 #pod
96 #pod Note: this attribute is I<not> inherited from the base class.
97 #pod
98 #pod =cut
99  
100 3 ▶sub _abbr {
Subroutine _abbr: called CC=1 SCAR=0.0
101 3 return 'GPL';
102 };
103  
104 #pod =attr abbr
105 #pod
106 #pod Abbreviated license name: concatenated bare abbreviated license name, 'v' character, and license
107 #pod version (with trailing plus sign).
108 #pod
109 #pod Note: this attribute is I<not> inherited from the base class.
110 #pod
111 #pod =cut
112  
113 2 ▶sub abbr {
Subroutine abbr: called CC=1 SCAR=0.0
Pod documented
114 2 my ( $self ) = @_;
115 2 return $self->_abbr . 'v' . $self->version;
116 };
117  
118 #pod =attr base
119 #pod
120 #pod A reference to base license object, i. e. license without "or later" clause.
121 #pod
122 #pod Note: this attribute is I<not> inherited from the base class.
123 #pod
124 #pod =cut
125  
126 10 ▶sub base {
Subroutine base: called CC=2 SCAR=6.9
Pod documented
127 10 my ( $self ) = @_;
128 10 ▶ if ( not $self->{ base } ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"base"}) 1 9 10
129 1 my %base = %$self; # Create a copy, because `new` (re)blesses passed `HashRef`.
130 1 $self->{ base } = Software::License::GPL_2->new( \%base );
131 };
132 10 return $self->{ base };
133 };
134  
135 #pod =attr _name
136 #pod
137 #pod Bare name of the license, which is also bare name of the base license, because it does
138 #pod include neither definitive article ("The"), nor license version nor "or later" clause:
139 #pod "GNU General Public License".
140 #pod
141 #pod Note: this attribute is I<not> inherited from the base class.
142 #pod
143 #pod =cut
144  
145 15 ▶sub _name {
Subroutine _name: called CC=1 SCAR=0.0
146 15 return 'GNU General Public License';
147 };
148  
149 #pod =attr name
150 #pod
151 #pod This attribute meets C<Software::License> specification: returned name starts with definitive
152 #pod capitalized article ("The"). Returned name also includes the base license version (like other
153 #pod C<Software::License> classes do) (without trailing plus sign) and "or later" clause.
154 #pod
155 #pod =cut
156  
157 2 ▶sub name {
Subroutine name: called CC=1 SCAR=0.0
Pod documented
158 2 my ( $self ) = @_;
159 2 return sprintf( "The %s version %s or later", $self->_name, $self->base->version );
160 };
161  
162 #pod =attr program
163 #pod
164 #pod A program name as specified by the C<program> option in constructor, or the C<Program> option in
165 #pod constructor, or "this program". This form of program name is intended to be used in the middle of
166 #pod sentence.
167 #pod
168 #pod Note: this attribute is I<not> inherited from the base class.
169 #pod
170 #pod =cut
171  
172 8 ▶sub program {
Subroutine program: called CC=3 SCAR=11.0
Pod documented
173 8 my ( $self ) = @_;
174 8 ▶ return $self->{ program } || $self->{ Program } || 'this program';
Condition100%5/5
$self->{'program'} || $self->{'Program'} || 'this program'
l!l
62
$self->{"program"} or $self->{"Program"}
l!l&&r!l&&!r
512
MC/DC100%2/2
$self->{'program'} || $self->{'Program'} || 'this program'
$self->{"program"} $self->{"Program"}
Truth table100%3/3
A or B
A= $self->{"program"}B= $self->{"Program"}
ABresult
1X1
011
000
175 };
176  
177 #pod =attr Program
178 #pod
179 #pod A program name as specified by the C<Program> option in constructor, or the C<program> option in
180 #pod constructor, or "This program". This form of program name is intended to be used in the beginning
181 #pod of sentence.
182 #pod
183 #pod Note: this attribute is I<not> inherited from the base class.
184 #pod
185 #pod =cut
186  
187 12 ▶sub Program {
Subroutine Program: called CC=3 SCAR=11.0
Pod documented
188 12 my ( $self ) = @_;
189 12 ▶ return $self->{ Program } || $self->{ program } || 'This program';
Condition100%5/5
$self->{'Program'} || $self->{'program'} || 'This program'
l!l
93
$self->{"Program"} or $self->{"program"}
l!l&&r!l&&!r
453
MC/DC100%2/2
$self->{'Program'} || $self->{'program'} || 'This program'
$self->{"Program"} $self->{"program"}
Truth table100%3/3
A or B
A= $self->{"Program"}B= $self->{"program"}
ABresult
1X1
011
000
190 };
191  
192 #pod =method notice
193 #pod
194 #pod This method overrides L<Software::License>'s C<notice>. Differences are:
195 #pod
196 #pod =for :list
197 #pod * If the license object was created with C<program> or C<Program> or both options, notice will
198 #pod include real program name instead of generic "this program".
199 #pod * It returns copyright statement followed by standard GNU 3-paragraph license notice.
200 #pod * Result is formatted with L<Text::Wrap::fill|Text::Wrap>.
201 #pod
202 #pod The method can be called with C<'short'> argument to get short version of notice. Short version
203 #pod includes: copyright statement, license name, and two sentences about free software and warranties.
204 #pod Note: This is experimental feature.
205 #pod
206 #pod =cut
207  
208 5 ▶sub notice {
Subroutine notice: called CC=2 SCAR=6.9
Pod documented
209 5 my ( $self, $arg ) = @_;
210 5 ▶ my $notice = Text::Wrap::fill( '', '', $self->_fill_in( $arg || 'NOTICE' ) );
Condition100%2/2
$arg || 'NOTICE'
l!l
14
MC/DC100%1/1
$arg || 'NOTICE'
$arg
Truth table100%2/2
A
A= $arg
Aresult
11
00
211 # Documentation on `fill` says it deletes all trailing whitespace, but it looks like it
212 # may leave one space. Let us make sure notice ends with one newline.
213 5 $notice =~ s{\s*\z}{\n}x;
214 5 return $notice;
215 };
216  
217 #pod =attr version
218 #pod
219 #pod License version (base license version with appended plus sign to denote "or later" clause).
220 #pod
221 #pod =cut
222  
223 3 ▶sub version {
Subroutine version: called CC=1 SCAR=0.0
Pod documented
224 3 my ( $self ) = @_;
225 3 return $self->base->version . '+';
226 };
227  
228 2 1;
229  
230 #pod =head1 COPYRIGHT AND LICENSE
231 #pod
232 #pod Copyright (C) 2015 Van de Bugger
233 #pod
234 #pod License GPLv3+: The GNU General Public License version 3 or later
235 #pod <http://www.gnu.org/licenses/gpl-3.0.txt>.
236 #pod
237 #pod This is free software: you are free to change and redistribute it. There is
238 #pod NO WARRANTY, to the extent permitted by law.
239 #pod
240 #pod
241 #pod =cut
242  
243 # doc/what.pod #
244  
245 #pod =encoding UTF-8
246 #pod
247 #pod =head1 WHAT?
248 #pod
249 #pod C<Software-License-OrLaterPack> (or just C<OrLaterPack> for brevity) is an add-on for C<Software-License>, a set
250 #pod of licenses with "or later" clause (like C<GPL_3::or_later>). It allows Perl developers (who use
251 #pod C<Dist-Zilla>) to release their work under the terms of a I<License> version I<N> or (at user
252 #pod option) any later version.
253 #pod
254 #pod =cut
255  
256 # end of file #
257  
258 =pod
259  
260 =encoding UTF-8
261  
262 =head1 NAME
263  
264 Software::License::GPL_2::or_later - GPLv2+ license for Software::License infrastructure
265  
266 =head1 VERSION
267  
268 Version v0.10.2, released on 2016-10-10 22:17 UTC.
269  
270 =head1 WHAT?
271  
272 C<Software-License-OrLaterPack> (or just C<OrLaterPack> for brevity) is an add-on for C<Software-License>, a set
273 of licenses with "or later" clause (like C<GPL_3::or_later>). It allows Perl developers (who use
274 C<Dist-Zilla>) to release their work under the terms of a I<License> version I<N> or (at user
275 option) any later version.
276  
277 This is C<Software::License::GPL_2::or_later> module documentation. Read this if you
278 are going to hack or extend the module, or use the module directly.
279  
280 If you want to use GNU license with "or later" clause read the L<user
281 manual|Software::License::OrLaterPack>. General topics like getting source, building, installing,
282 bug reporting and some others are covered in the F<README> file.
283  
284 =head1 SYNOPSIS
285  
286 my $lic = Software::License::GPL_2::or_later->new( {
287 holder => 'John Doe',
288 year => '2010',
289 program => 'Assa'
290 } );
291  
292 $lic->_abbr; # 'GPL'
293 $lic->abbr; # 'GPLv2+'
294 $lic->_name; # 'GNU General Public License'
295 $lic->name; # 'The GNU General Public License version 2 or later'
296  
297 $lic->notice;
298 # Copyright statement and
299 # standard GNU 3-paragraph license notice.
300 $lic->notice( 'short' );
301 # Copyright statement, license name and
302 # two sentences about free software and warranties.
303  
304 # …and other methods inherited from Software::License::GPL_2
305 # and Software::License.
306  
307 =head1 DESCRIPTION
308  
309 C<Software::License::GPL_2::or_later> is a subclass of C<Software::License::GPL_2>.
310 It overrides few parent methods and introduces few own methods.
311  
312 See documentation on L<Software::License> for a general description of the class interface.
313  
314 =head1 OBJECT ATTRIBUTES
315  
316 =head2 _abbr
317  
318 Bare abbreviated license name, "GPL".
319  
320 Note: this attribute is I<not> inherited from the base class.
321  
322 =head2 abbr
323  
324 Abbreviated license name: concatenated bare abbreviated license name, 'v' character, and license
325 version (with trailing plus sign).
326  
327 Note: this attribute is I<not> inherited from the base class.
328  
329 =head2 base
330  
331 A reference to base license object, i. e. license without "or later" clause.
332  
333 Note: this attribute is I<not> inherited from the base class.
334  
335 =head2 _name
336  
337 Bare name of the license, which is also bare name of the base license, because it does
338 include neither definitive article ("The"), nor license version nor "or later" clause:
339 "GNU General Public License".
340  
341 Note: this attribute is I<not> inherited from the base class.
342  
343 =head2 name
344  
345 This attribute meets C<Software::License> specification: returned name starts with definitive
346 capitalized article ("The"). Returned name also includes the base license version (like other
347 C<Software::License> classes do) (without trailing plus sign) and "or later" clause.
348  
349 =head2 program
350  
351 A program name as specified by the C<program> option in constructor, or the C<Program> option in
352 constructor, or "this program". This form of program name is intended to be used in the middle of
353 sentence.
354  
355 Note: this attribute is I<not> inherited from the base class.
356  
357 =head2 Program
358  
359 A program name as specified by the C<Program> option in constructor, or the C<program> option in
360 constructor, or "This program". This form of program name is intended to be used in the beginning
361 of sentence.
362  
363 Note: this attribute is I<not> inherited from the base class.
364  
365 =head2 version
366  
367 License version (base license version with appended plus sign to denote "or later" clause).
368  
369 =head1 OBJECT METHODS
370  
371 =head2 notice
372  
373 This method overrides L<Software::License>'s C<notice>. Differences are:
374  
375 =over 4
376  
377 =item *
378  
379 If the license object was created with C<program> or C<Program> or both options, notice will include real program name instead of generic "this program".
380  
381 =item *
382  
383 It returns copyright statement followed by standard GNU 3-paragraph license notice.
384  
385 =item *
386  
387 Result is formatted with L<Text::Wrap::fill|Text::Wrap>.
388  
389 =back
390  
391 The method can be called with C<'short'> argument to get short version of notice. Short version
392 includes: copyright statement, license name, and two sentences about free software and warranties.
393 Note: This is experimental feature.
394  
395 =head1 AUTHOR
396  
397 Van de Bugger <van.de.bugger@gmail.com>
398  
399 =head1 COPYRIGHT AND LICENSE
400  
401 Copyright (C) 2015 Van de Bugger
402  
403 License GPLv3+: The GNU General Public License version 3 or later
404 <http://www.gnu.org/licenses/gpl-3.0.txt>.
405  
406 This is free software: you are free to change and redistribute it. There is
407 NO WARRANTY, to the extent permitted by law.
408  
409 =cut
410  
411 __DATA__
« GPL_1/or_later.pm ↑ Summary GPL_3/or_later.pm »