| 1 | 14 | ▶ | use v5.40; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 14 | ▶ | use utf8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 14 | ▶ | use feature 'class'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 14 | ▶ | no warnings 'experimental::class'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | =head1 NAME | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | String::License::Naming - base class for names of licenses and license naming schemes | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | =head1 VERSION | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | Version v0.1.1 | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | L<String::License::Naming> is a base class | ||||||||||||||||||||||||||||
| 18 | for how to constrain, enumerate, and present licenses. | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | This class cannot be instantiated on its own. | ||||||||||||||||||||||||||||
| 21 | Please use a subclass instead, | ||||||||||||||||||||||||||||
| 22 | e.g. L<String::License::Naming::SPDX>. | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | =cut | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | package String::License::Naming v0.1.1; | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 14 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | class String::License::Naming; | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 0 | ▶ | method list_schemes () { ...; } | ||||||||||||||||||||||||||
|
Subroutine
list_schemes: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 0 | ▶ | method list_licenses () { ...; } | ||||||||||||||||||||||||||
|
Subroutine
list_licenses: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 29 | ▶ | sub resolve_shortnames ( $keys, $schemes, $bootstrap = undef ) | ||||||||||||||||||||||||||
|
Subroutine
resolve_shortnames: called CC=22 SCAR=32.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 37 | 29 | { | |||||||||||||||||||||||||||
| 38 | 29 | my ( @schemes, $fallback, %names, @result ); | |||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 29 | ▶ | $keys = [ sort keys %Regexp::Pattern::License::RE ] | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
defined $keys and scalar @$keys
MC/DC100%1/1
defined $keys and scalar @$keys
defined $keys
Truth table100%2/2
A
A= defined $keys
| |||||||||||||||||||||||||||||
| 41 | unless defined $keys and scalar @$keys; | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 29 | for (@$schemes) { | |||||||||||||||||||||||||||
| 44 | 31 | ▶ | if ( $_ eq 'internal' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 4 | $fallback = 1; | |||||||||||||||||||||||||||
| 46 | 4 | last; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | 27 | push @schemes, $_; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | KEY: | ||||||||||||||||||||||||||||
| 52 | 29 | for my $key (@$keys) { | |||||||||||||||||||||||||||
| 53 | 16090 | ▶ | for my $key2 ( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | @schemes | ||||||||||||||||||||||||||||
| 55 | 13384 | ? sort keys %{ $Regexp::Pattern::License::RE{$key} } | |||||||||||||||||||||||||||
| 56 | : () | ||||||||||||||||||||||||||||
| 57 | ) | ||||||||||||||||||||||||||||
| 58 | { | ||||||||||||||||||||||||||||
| 59 | 249776 | my ( %attr, @attr ); | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 249776 | @attr = split /[.]/, $key2; | |||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 249776 | ▶ | next unless $attr[0] eq 'name'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | # TODO: simplify, and require R::P::License v3.8.1 | ||||||||||||||||||||||||||||
| 66 | 39418 | ▶ | if ( $Regexp::Pattern::License::VERSION < v3.8.1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | 0 | ▶ | push @attr, undef | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | if @attr % 2; | ||||||||||||||||||||||||||||
| 69 | 0 | %attr = @attr[ 2 .. $#attr ]; | |||||||||||||||||||||||||||
| 70 | 0 | ▶ | next if exists $attr{version}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | 0 | ▶ | next if exists $attr{until}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | else { | ||||||||||||||||||||||||||||
| 74 | 39418 | %attr = @attr[ 2 .. $#attr ]; | |||||||||||||||||||||||||||
| 75 | 39418 | ▶ | next if exists $attr{until}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | 36880 | for my $org (@schemes) { | |||||||||||||||||||||||||||
| 78 | 41059 | ▶ | if ( exists $attr{org} and $attr{org} eq $org ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
exists $attr{"org"} and $attr{"org"} eq $org
MC/DC100%2/2
exists $attr{"org"} and $attr{"org"} eq $org
exists $attr{"org"}
$attr{"org"} eq $org
Truth table100%3/3
A and B
A= exists $attr{"org"}B= $attr{"org"} eq $org
| |||||||||||||||||||||||||||||
| 79 | 6627 | $names{$key} = $Regexp::Pattern::License::RE{$key}{$key2}; | |||||||||||||||||||||||||||
| 80 | 6627 | next KEY; | |||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | 9463 | ▶ | if ($fallback) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 85 | 1328 | ▶ | $names{$key} = $Regexp::Pattern::License::RE{$key}{name} // $key; | ||||||||||||||||||||||||||
|
Condition66%2/3
$Regexp::Pattern::License::RE{$key}{"name"} // $key
MC/DC0%0/2
$Regexp::Pattern::License::RE{$key}{"name"} // $key
$Regexp::Pattern::License::RE{$key}{"name"}
$key
Truth table66%2/3
A // B
A= $Regexp::Pattern::License::RE{$key}{"name"}B= $key
| |||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | elsif ( exists $Regexp::Pattern::License::RE{$key}{name} ) { | ||||||||||||||||||||||||||||
| 88 | 7056 | $names{$key} = $Regexp::Pattern::License::RE{$key}{name}; | |||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 29 | ▶ | @result = $bootstrap ? sort keys %names : sort { lc $a cmp lc $b } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | values %names; | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 29 | return @result; | |||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | =encoding UTF-8 | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | Jonas Smedegaard C<< <dr@jones.dk> >> | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | Copyright © 2023 Jonas Smedegaard | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | This program is free software: | ||||||||||||||||||||||||||||
| 109 | you can redistribute it and/or modify it | ||||||||||||||||||||||||||||
| 110 | under the terms of the GNU Affero General Public License | ||||||||||||||||||||||||||||
| 111 | as published by the Free Software Foundation, | ||||||||||||||||||||||||||||
| 112 | either version 3, or (at your option) any later version. | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | This program is distributed in the hope that it will be useful, | ||||||||||||||||||||||||||||
| 115 | but WITHOUT ANY WARRANTY; | ||||||||||||||||||||||||||||
| 116 | without even the implied warranty | ||||||||||||||||||||||||||||
| 117 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||||||||||||||||||||||||||||
| 118 | See the GNU Affero General Public License for more details. | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | You should have received a copy | ||||||||||||||||||||||||||||
| 121 | of the GNU Affero General Public License along with this program. | ||||||||||||||||||||||||||||
| 122 | If not, see <https://www.gnu.org/licenses/>. | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | =cut | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | 14 | 1; | |||||||||||||||||||||||||||