| 1 | 13 | ▶ | use v5.40; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 2 | 13 | ▶ | use utf8; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | |||
| 4 | 13 | ▶ | use feature 'class'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 13 | ▶ | no warnings 'experimental::class'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | =head1 NAME | ||
| 8 | |||
| 9 | String::License::Naming::SPDX - licenses as named by SPDX | ||
| 10 | |||
| 11 | =head1 VERSION | ||
| 12 | |||
| 13 | Version v0.1.1 | ||
| 14 | |||
| 15 | =head1 SYNOPSIS | ||
| 16 | |||
| 17 | use String::License::Naming::SPDX; | ||
| 18 | |||
| 19 | my $spdx = String::License::Naming::SPDX->new; | ||
| 20 | |||
| 21 | my $license = [ grep { /^(Expat|Perl)$/ } $spdx->list_licenses ]; # => is_deeply ['Perl'] | ||
| 22 | |||
| 23 | =head1 DESCRIPTION | ||
| 24 | |||
| 25 | L<String::License::Naming> enumerates supported licenses | ||
| 26 | matching an ordered set of naming schemes, | ||
| 27 | or enumerates the names of supported license naming schemes. | ||
| 28 | |||
| 29 | Some licenses are known by different names. | ||
| 30 | E.g. the license "MIT" according to SPDX | ||
| 31 | is named "Expat" in Debian. | ||
| 32 | |||
| 33 | Some licenses are not always represented. | ||
| 34 | E.g. "Perl" is a (discouraged) license in Debian | ||
| 35 | while it is a relationship of several licenses with SPDX | ||
| 36 | (and that expression is recommended in Debian as well). | ||
| 37 | |||
| 38 | By default, | ||
| 39 | licenses are matched using naming schemes C<[ 'spdx', 'internal' ]>, | ||
| 40 | which lists all supported licenses, | ||
| 41 | preferrably by their SPDX name | ||
| 42 | or as fallback by an internal name. | ||
| 43 | |||
| 44 | =cut | ||
| 45 | |||
| 46 | package String::License::Naming::SPDX v0.1.1; | ||
| 47 | |||
| 48 | 13 | ▶ | use Carp qw(croak); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 49 | 13 | ▶ | use Log::Any (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 50 | 13 | ▶ | use List::Util qw(uniq); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 51 | 13 | ▶ | use Regexp::Pattern::License 3.4.0; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 52 | |||
| 53 | 13 | ▶ | use namespace::clean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 54 | |||
| 55 | 1 | ▶ | class String::License::Naming::SPDX : isa(String::License::Naming); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 56 | |||
| 57 | 13 | field $log; | |
| 58 | |||
| 59 | =head1 CONSTRUCTOR | ||
| 60 | |||
| 61 | =over | ||
| 62 | |||
| 63 | =item new | ||
| 64 | |||
| 65 | Constructs and returns a String::License::Naming object. | ||
| 66 | |||
| 67 | Includes all licenses defined by SPDX, | ||
| 68 | and presents them by their SPDX shortname. | ||
| 69 | |||
| 70 | =back | ||
| 71 | |||
| 72 | =cut | ||
| 73 | |||
| 74 | 13 | field $schemes; | |
| 75 | |||
| 76 | # TODO: maybe support seeding explicit keys | ||
| 77 | 13 | field $keys; | |
| 78 | |||
| 79 | 14 | ▶ | ADJUST { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 80 | 14 | $log = Log::Any->get_logger; | |
| 81 | |||
| 82 | 14 | $schemes = ['spdx']; | |
| 83 | |||
| 84 | 14 | $keys = [ | |
| 85 | String::License::Naming::resolve_shortnames( $keys, $schemes, 1 ) ]; | ||
| 86 | } | ||
| 87 | |||
| 88 | =head1 FUNCTIONS | ||
| 89 | |||
| 90 | =item list_schemes | ||
| 91 | |||
| 92 | Returns a list of license naming schemes in use. | ||
| 93 | |||
| 94 | =cut | ||
| 95 | |||
| 96 | 6241 | ▶ | method list_schemes () |
|
Subroutine
list_schemes: called CC=1 SCAR=0.0
Pod
documented
| |||
| 97 | { | ||
| 98 | 6241 | return @$schemes; | |
| 99 | } | ||
| 100 | |||
| 101 | =item list_licenses | ||
| 102 | |||
| 103 | Returns a list of all licensing patterns covered by SPDX, | ||
| 104 | each labeled by SPDX shortname. | ||
| 105 | |||
| 106 | =cut | ||
| 107 | |||
| 108 | 1 | ▶ | method list_licenses () |
|
Subroutine
list_licenses: called CC=1 SCAR=0.0
Pod
documented
| |||
| 109 | { | ||
| 110 | 1 | return String::License::Naming::resolve_shortnames( $keys, $schemes ); | |
| 111 | } | ||
| 112 | |||
| 113 | =back | ||
| 114 | |||
| 115 | =encoding UTF-8 | ||
| 116 | |||
| 117 | =head1 AUTHOR | ||
| 118 | |||
| 119 | Jonas Smedegaard C<< <dr@jones.dk> >> | ||
| 120 | |||
| 121 | =head1 COPYRIGHT AND LICENSE | ||
| 122 | |||
| 123 | Copyright © 2023 Jonas Smedegaard | ||
| 124 | |||
| 125 | This program is free software: | ||
| 126 | you can redistribute it and/or modify it | ||
| 127 | under the terms of the GNU Affero General Public License | ||
| 128 | as published by the Free Software Foundation, | ||
| 129 | either version 3, or (at your option) any later version. | ||
| 130 | |||
| 131 | This program is distributed in the hope that it will be useful, | ||
| 132 | but WITHOUT ANY WARRANTY; | ||
| 133 | without even the implied warranty | ||
| 134 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
| 135 | See the GNU Affero General Public License for more details. | ||
| 136 | |||
| 137 | You should have received a copy | ||
| 138 | of the GNU Affero General Public License along with this program. | ||
| 139 | If not, see <https://www.gnu.org/licenses/>. | ||
| 140 | |||
| 141 | =cut | ||
| 142 | |||
| 143 | 13 | 1; | |