License::SPDX - Object for SPDX licenses handling.
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;
Object for SPDX licenses handling is using license data from https://github.com/spdx/license-list-data repository. Actual version is 3.20.
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.
$opts_hr
check_exception()
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.
check_license()
'id' - Check license id. 'name' - Check license name.
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.
licenses
my @licenses = $obj->licenses;
Get all license structures.
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.
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.
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.
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.
Class::Utils, Cpanel::JSON::XS, Error::Pure. File::Share, List::Util, Perl6::Slurp.
Tool for working with RPM spec file licenses.
https://github.com/michal-josef-spacek/License-SPDX
Michal Josef Špaček mailto:skim@cpan.org
http://skim.cz
© 2023 Michal Josef Špaček
BSD 2-Clause License
0.05
To install License::SPDX, copy and paste the appropriate command in to your terminal.
cpanm
cpanm License::SPDX
CPAN shell
perl -MCPAN -e shell install License::SPDX
For more information on module installation, please visit the detailed CPAN module installation guide.