line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# This file is part of Software-LicenseMoreUtils |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# This software is copyright (c) 2018, 2022 by Dominique Dumont. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under |
7
|
|
|
|
|
|
|
# the same terms as the Perl 5 programming language system itself. |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
package Software::LicenseMoreUtils; |
10
|
|
|
|
|
|
|
$Software::LicenseMoreUtils::VERSION = '1.007'; |
11
|
3
|
|
|
3
|
|
1685
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
71
|
|
12
|
3
|
|
|
3
|
|
12
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
67
|
|
13
|
3
|
|
|
3
|
|
30
|
use 5.10.1; |
|
3
|
|
|
|
|
22
|
|
14
|
|
|
|
|
|
|
|
15
|
3
|
|
|
3
|
|
1098
|
use Try::Tiny; |
|
3
|
|
|
|
|
4683
|
|
|
3
|
|
|
|
|
130
|
|
16
|
3
|
|
|
3
|
|
15
|
use Carp; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
104
|
|
17
|
3
|
|
|
3
|
|
1058
|
use Software::LicenseMoreUtils::LicenseWithSummary; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
133
|
|
18
|
3
|
|
|
3
|
|
1187
|
use Software::License 0.103014; |
|
3
|
|
|
|
|
42249
|
|
|
3
|
|
|
|
|
87
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# ABSTRACT: More utilities and a summary for Software::License |
21
|
|
|
|
|
|
|
|
22
|
3
|
|
|
3
|
|
24
|
use base qw/Software::LicenseUtils/; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
1404
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# a short name with '+' at the end of the short name implies an |
25
|
|
|
|
|
|
|
# "or later" clause. i.e. GPL-1+ is "GPL-1 or any later version" |
26
|
|
|
|
|
|
|
my %more_short_names = ( |
27
|
|
|
|
|
|
|
'Apache-1.1' => 'Software::License::Apache_1_1', |
28
|
|
|
|
|
|
|
'Apache-2' => 'Software::License::Apache_2_0', |
29
|
|
|
|
|
|
|
'Artistic' => 'Software::License::Artistic_1_0', |
30
|
|
|
|
|
|
|
'Artistic-1' => 'Software::License::Artistic_1_0', |
31
|
|
|
|
|
|
|
'Artistic-2' => 'Software::License::Artistic_2_0', |
32
|
|
|
|
|
|
|
'BSD-3-clause' => 'Software::License::BSD', |
33
|
|
|
|
|
|
|
'Expat' => 'Software::License::MIT', |
34
|
|
|
|
|
|
|
'LGPL-2' => 'Software::LicenseMoreUtils::LGPL_2', |
35
|
|
|
|
|
|
|
'LGPL_2' => 'Software::LicenseMoreUtils::LGPL_2', |
36
|
|
|
|
|
|
|
'LGPL-2.1' => 'Software::License::LGPL_2_1', |
37
|
|
|
|
|
|
|
'GPL-1+' => 'Software::License::GPL_1', |
38
|
|
|
|
|
|
|
'GPL-2+' => 'Software::License::GPL_2', |
39
|
|
|
|
|
|
|
'GPL-3+' => 'Software::License::GPL_3', |
40
|
|
|
|
|
|
|
'LGPL-2+' => 'Software::LicenseMoreUtils::LGPL_2', |
41
|
|
|
|
|
|
|
'LGPL_2+' => 'Software::LicenseMoreUtils::LGPL_2', |
42
|
|
|
|
|
|
|
'LGPL-2.1+' => 'Software::License::LGPL_2_1', |
43
|
|
|
|
|
|
|
'LGPL-3+' => 'Software::License::LGPL_3_0', |
44
|
|
|
|
|
|
|
'LGPL-3.0+' => 'Software::License::LGPL_3_0', |
45
|
|
|
|
|
|
|
'MPL-1.0' => 'Software::License::Mozilla_1_0', |
46
|
|
|
|
|
|
|
'MPL-1.1' => 'Software::License::Mozilla_1_1', |
47
|
|
|
|
|
|
|
'MPL-2.0' => 'Software::License::Mozilla_2_0', |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# Some SPDX v3 identifiers |
50
|
|
|
|
|
|
|
'LGPL-2.0-or-later' => 'Software::LicenseMoreUtils::LGPL_2', |
51
|
|
|
|
|
|
|
'LGPL-2.1-or-later' => 'Software::License::LGPL_2_1', |
52
|
|
|
|
|
|
|
'LGPL-3.0-or-later' => 'Software::License::LGPL_3_0', |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
'GPL-1.0-or-later' => 'Software::LicenseMoreUtils::GPL_1', |
55
|
|
|
|
|
|
|
'GPL-2.0-or-later' => 'Software::License::GPL_2', |
56
|
|
|
|
|
|
|
'GPL-3.0-or-later' => 'Software::License::GPL_3', |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _create_license { |
60
|
23
|
|
|
23
|
|
36
|
my ( $class, $arg ) = @_; |
61
|
|
|
|
|
|
|
croak "no license short name specified" |
62
|
23
|
50
|
|
|
|
50
|
unless defined $arg->{short_name}; |
63
|
|
|
|
|
|
|
|
64
|
23
|
|
|
|
|
28
|
my $lic_obj; |
65
|
|
|
|
|
|
|
try { |
66
|
23
|
|
|
23
|
|
800
|
$lic_obj = SUPER::new_from_short_name($arg); |
67
|
23
|
|
|
|
|
109
|
}; |
68
|
|
|
|
|
|
|
|
69
|
23
|
50
|
|
|
|
307
|
return $lic_obj if $lic_obj; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
try { |
72
|
23
|
|
|
23
|
|
560
|
$lic_obj = SUPER::new_from_spdx_expression($arg); |
73
|
23
|
|
|
|
|
86
|
}; |
74
|
|
|
|
|
|
|
|
75
|
23
|
50
|
|
|
|
234
|
return $lic_obj if $lic_obj; |
76
|
|
|
|
|
|
|
|
77
|
23
|
|
|
|
|
39
|
my $subclass = my $short = $arg->{short_name}; |
78
|
23
|
|
|
|
|
73
|
$subclass =~ s/[\-.]/_/g; |
79
|
|
|
|
|
|
|
|
80
|
23
|
|
66
|
|
|
76
|
my $info = $more_short_names{$short} || "Software::License::$subclass"; |
81
|
23
|
|
|
|
|
35
|
my $lic_file = my $lic_class = $info; |
82
|
23
|
|
|
|
|
78
|
$lic_file =~ s!::!/!g; |
83
|
|
|
|
|
|
|
try { |
84
|
|
|
|
|
|
|
## no critic (Modules::RequireBarewordIncludes) |
85
|
23
|
|
|
23
|
|
2085
|
require "$lic_file.pm"; |
86
|
|
|
|
|
|
|
} catch { |
87
|
1
|
|
|
1
|
|
34
|
Carp::croak "Unknow license with short name $short ($_)"; |
88
|
23
|
|
|
|
|
109
|
} ; |
89
|
22
|
|
|
|
|
233
|
delete $arg->{short_name}; |
90
|
22
|
|
|
|
|
184
|
$lic_obj = $lic_class->new( { %$arg } ); |
91
|
|
|
|
|
|
|
|
92
|
22
|
|
|
|
|
167
|
return $lic_obj; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub new_license_with_summary { |
96
|
0
|
|
|
0
|
0
|
0
|
carp "new_license_with_summary is deprecated. Please use new_from_short_name"; |
97
|
0
|
|
|
|
|
0
|
goto & new_from_short_name; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub new_from_short_name { |
101
|
23
|
|
|
23
|
1
|
22926
|
my ( $class, $arg ) = @_; |
102
|
|
|
|
|
|
|
croak "no license short name specified" |
103
|
23
|
50
|
|
|
|
56
|
unless defined $arg->{short_name}; |
104
|
|
|
|
|
|
|
|
105
|
23
|
|
|
|
|
32
|
my $short = $arg->{short_name}; |
106
|
|
|
|
|
|
|
|
107
|
23
|
|
100
|
|
|
80
|
my $info = $more_short_names{$short} || ''; |
108
|
23
|
100
|
|
|
|
97
|
my $or_later = $short =~ /(\+|-or-later)$/ ? 1 : 0; |
109
|
23
|
|
|
|
|
56
|
my $lic = $class->_create_license($arg); |
110
|
|
|
|
|
|
|
|
111
|
22
|
|
|
|
|
88
|
my $xlic = Software::LicenseMoreUtils::LicenseWithSummary->new({ |
112
|
|
|
|
|
|
|
license => $lic, |
113
|
|
|
|
|
|
|
or_later => $or_later |
114
|
|
|
|
|
|
|
}); |
115
|
22
|
|
|
|
|
50
|
return $xlic; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
1; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
__END__ |