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.009'; |
11
|
3
|
|
|
3
|
|
1678
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
72
|
|
12
|
3
|
|
|
3
|
|
12
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
60
|
|
13
|
3
|
|
|
3
|
|
27
|
use 5.10.1; |
|
3
|
|
|
|
|
9
|
|
14
|
|
|
|
|
|
|
|
15
|
3
|
|
|
3
|
|
1172
|
use Try::Tiny; |
|
3
|
|
|
|
|
4974
|
|
|
3
|
|
|
|
|
130
|
|
16
|
3
|
|
|
3
|
|
17
|
use Carp; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
112
|
|
17
|
3
|
|
|
3
|
|
1080
|
use Software::LicenseMoreUtils::LicenseWithSummary; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
125
|
|
18
|
3
|
|
|
3
|
|
1172
|
use Software::License 0.103014; |
|
3
|
|
|
|
|
45905
|
|
|
3
|
|
|
|
|
83
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# ABSTRACT: More utilities and a summary for Software::License |
21
|
|
|
|
|
|
|
|
22
|
3
|
|
|
3
|
|
27
|
use base qw/Software::LicenseUtils/; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
1275
|
|
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-2' => 'Software::License::Apache_2_0', |
28
|
|
|
|
|
|
|
'Artistic' => 'Software::License::Artistic_1_0', |
29
|
|
|
|
|
|
|
'Artistic-1' => 'Software::License::Artistic_1_0', |
30
|
|
|
|
|
|
|
'Artistic-2' => 'Software::License::Artistic_2_0', |
31
|
|
|
|
|
|
|
'BSD-3-clause' => 'Software::License::BSD', |
32
|
|
|
|
|
|
|
'Expat' => 'Software::License::MIT', |
33
|
|
|
|
|
|
|
'LGPL-2' => 'Software::LicenseMoreUtils::LGPL_2', |
34
|
|
|
|
|
|
|
'LGPL_2' => 'Software::LicenseMoreUtils::LGPL_2', |
35
|
|
|
|
|
|
|
'LGPL-3' => 'Software::License::LGPL_3_0', |
36
|
|
|
|
|
|
|
'MPL-1.0' => 'Software::License::Mozilla_1_0', |
37
|
|
|
|
|
|
|
'MPL-1.1' => 'Software::License::Mozilla_1_1', |
38
|
|
|
|
|
|
|
'MPL-2.0' => 'Software::License::Mozilla_2_0', |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# GPL SPDX identifiers have another convention for GPL version number |
41
|
|
|
|
|
|
|
'LGPL-2.0' => 'Software::LicenseMoreUtils::LGPL_2', |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
'GPL-1.0' => 'Software::License::GPL_1', |
44
|
|
|
|
|
|
|
'GPL-2.0' => 'Software::License::GPL_2', |
45
|
|
|
|
|
|
|
'GPL-3.0' => 'Software::License::GPL_3', |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _create_license { |
49
|
53
|
|
|
53
|
|
87
|
my ( $class, $arg ) = @_; |
50
|
|
|
|
|
|
|
croak "no license short name specified" |
51
|
53
|
50
|
|
|
|
140
|
unless defined $arg->{short_name}; |
52
|
|
|
|
|
|
|
|
53
|
53
|
|
|
|
|
69
|
my $lic_obj; |
54
|
|
|
|
|
|
|
try { |
55
|
53
|
|
|
53
|
|
1969
|
$lic_obj = SUPER::new_from_short_name($arg); |
56
|
53
|
|
|
|
|
261
|
}; |
57
|
|
|
|
|
|
|
|
58
|
53
|
50
|
|
|
|
702
|
return $lic_obj if $lic_obj; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
try { |
61
|
53
|
|
|
53
|
|
1478
|
$lic_obj = SUPER::new_from_spdx_expression($arg); |
62
|
53
|
|
|
|
|
203
|
}; |
63
|
|
|
|
|
|
|
|
64
|
53
|
50
|
|
|
|
597
|
return $lic_obj if $lic_obj; |
65
|
|
|
|
|
|
|
|
66
|
53
|
|
|
|
|
93
|
my $short = $arg->{short_name}; |
67
|
53
|
|
|
|
|
137
|
$short =~ s/-(only|or-later)$//; |
68
|
53
|
|
|
|
|
105
|
$short =~ s/\+$//; |
69
|
|
|
|
|
|
|
|
70
|
53
|
|
|
|
|
67
|
my $subclass = $short; |
71
|
53
|
|
|
|
|
184
|
$subclass =~ s/[\-.]/_/g; |
72
|
|
|
|
|
|
|
|
73
|
53
|
|
66
|
|
|
174
|
my $info = $more_short_names{$short} || "Software::License::$subclass"; |
74
|
53
|
|
|
|
|
79
|
my $lic_file = my $lic_class = $info; |
75
|
53
|
|
|
|
|
150
|
$lic_file =~ s!::!/!g; |
76
|
|
|
|
|
|
|
try { |
77
|
|
|
|
|
|
|
## no critic (Modules::RequireBarewordIncludes) |
78
|
53
|
|
|
53
|
|
3668
|
require "$lic_file.pm"; |
79
|
|
|
|
|
|
|
} catch { |
80
|
1
|
|
|
1
|
|
33
|
Carp::croak "Unknow license with short name $short ($_)"; |
81
|
53
|
|
|
|
|
258
|
} ; |
82
|
52
|
|
|
|
|
600
|
delete $arg->{short_name}; |
83
|
|
|
|
|
|
|
# the holder default value fits well with BSD license text |
84
|
52
|
|
|
|
|
369
|
$lic_obj = $lic_class->new( { holder => 'the copyright holder', %$arg } ); |
85
|
|
|
|
|
|
|
|
86
|
52
|
|
|
|
|
334
|
return $lic_obj; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub new_license_with_summary { |
90
|
0
|
|
|
0
|
0
|
0
|
carp "new_license_with_summary is deprecated. Please use new_from_short_name"; |
91
|
0
|
|
|
|
|
0
|
goto & new_from_short_name; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub new_from_short_name { |
95
|
53
|
|
|
53
|
1
|
34490
|
my ( $class, $arg ) = @_; |
96
|
|
|
|
|
|
|
croak "no license short name specified" |
97
|
53
|
50
|
|
|
|
136
|
unless defined $arg->{short_name}; |
98
|
|
|
|
|
|
|
|
99
|
53
|
|
|
|
|
80
|
my $short = $arg->{short_name}; |
100
|
|
|
|
|
|
|
|
101
|
53
|
|
100
|
|
|
148
|
my $info = $more_short_names{$short} || ''; |
102
|
53
|
100
|
|
|
|
238
|
my $or_later = $short =~ /(\+|-or-later)$/ ? 1 : 0; |
103
|
53
|
|
|
|
|
124
|
my $lic = $class->_create_license($arg); |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
my $xlic = Software::LicenseMoreUtils::LicenseWithSummary->new({ |
106
|
|
|
|
|
|
|
license => $lic, |
107
|
|
|
|
|
|
|
or_later => $or_later, |
108
|
|
|
|
|
|
|
holder => $arg->{holder}, |
109
|
52
|
|
|
|
|
229
|
}); |
110
|
52
|
|
|
|
|
134
|
return $xlic; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
1; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
__END__ |