-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
195 lines (133 loc) · 4.52 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
NAME
License::SPDX - Object for SPDX licenses handling.
SYNOPSIS
use License::SPDX;
my $obj = License::SPDX->new;
my $checked = $obj->check_exception($check_string, $opts_hr);
my $checked = $obj->check_license($check_string, $opts_hr);
my $exception_hr = $obj->exception($exception_id);
my @exceptions = $obj->exceptions;
my $license_hr = $obj->license($license_id);
my @licenses = $obj->licenses;
my $spdx_release_date = $obj->spdx_release_date;
my $spdx_version = $obj->spdx_version;
DESCRIPTION
Object for SPDX licenses handling is using license data from
<https://github.com/spdx/license-list-data> repository. Actual version
is 3.20.
METHODS
"new"
my $obj = License::SPDX->new;
Constructor.
Returns instance of object.
"check_exception"
my $checked = $obj->check_exception($check_string, $opts_hr);
Check if license exception exists. Argument $opts_hr is reference to
hash with parameter 'check_type' for definition of "check_exception()"
type.
Possible 'check_type' values:
'id' - Check license exception id.
'name' - Check license exception name.
Default value of 'check_type' is 'id'. If 'check_type' is bad, fail with
error.
Returns 1 (license exist) or 0 (license doesn't exist).
"check_license"
my $checked = $obj->check_license($check_string, $opts_hr);
Check if license exists. Argument $opts_hr is reference to hash with
parameter 'check_type' for definition of "check_license()" type.
Possible 'check_type' values:
'id' - Check license id.
'name' - Check license name.
Default value of 'check_type' is 'id'. If 'check_type' is bad, fail with
error.
Returns 1 (license exist) or 0 (license doesn't exist).
"exception"
my $exception_hr = $obj->exception($exception_id);
Get license exception structure.
Returns reference to hash.
"exceptions"
my @exceptions = $obj->exceptions;
Get all license exception structures.
Returns array of references to hash.
"license"
my $license_hr = $obj->license($license_id);
Get license structure.
Returns reference to hash.
"licenses"
my @licenses = $obj->licenses;
Get all license structures.
Returns array of references to hash.
"spdx_release_date"
my $spdx_release_date = $obj->spdx_release_date;
Get release date of data structure with SPDX license.
Returns string.
"spdx_version"
my $spdx_version = $obj->spdx_version;
Get version of data structure with SPDX license.
Returns string.
ERRORS
new():
From Class::Utils::set_params():
Unknown parameter '%s'.
check_exception():
Check type '%s' doesn't supported.
check_license():
Check type '%s' doesn't supported.
EXAMPLE1
use strict;
use warnings;
use License::SPDX;
if (@ARGV < 1) {
print STDERR "Usage: $0 license_id\n";
exit 1;
}
my $license_id = $ARGV[0];
# Object.
my $obj = License::SPDX->new;
print 'License with id \''.$license_id.'\' is ';
if ($obj->check_license($license_id)) {
print "supported.\n";
} else {
print "not supported.\n";
}
# Output for 'MIT':
# License with id 'MIT' is supported.
# Output for 'BAD':
# License with id 'BAD' is not supported.
EXAMPLE2
use strict;
use warnings;
use License::SPDX;
if (@ARGV < 1) {
print STDERR "Usage: $0 license_exception_id\n";
exit 1;
}
my $license_exception_id = $ARGV[0];
# Object.
my $obj = License::SPDX->new;
print 'License exception with id \''.$license_exception_id.'\' is ';
if ($obj->check_exception($license_exception_id)) {
print "supported.\n";
} else {
print "not supported.\n";
}
# Output for 'LGPL-3.0-linking-exception':
# License exception with id 'LGPL-3.0-linking-exception' is supported.
# Output for 'BAD':
# License exception with id 'BAD' is not supported.
DEPENDENCIES
Class::Utils, Cpanel::JSON::XS, Error::Pure. File::Share, List::Util,
Perl6::Slurp.
SEE ALSO
rpm-spec-license
Tool for working with RPM spec file licenses.
REPOSITORY
<https://github.com/michal-josef-spacek/License-SPDX>
AUTHOR
Michal Josef Špaček <mailto:skim@cpan.org>
<http://skim.cz>
LICENSE AND COPYRIGHT
© 2023 Michal Josef Špaček
BSD 2-Clause License
VERSION
0.07