| 1 | package URI::PackageURL::Type; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 9 | ▶ | use feature ':5.10'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 9 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 9 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 9 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 9 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 9 | ▶ | use File::Basename qw(dirname); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 9 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 9 | ▶ | use JSON::PP qw(decode_json); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 9 | ▶ | use List::Util qw(first); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 9 | ▶ | use constant DEBUG => $ENV{PURL_DEBUG}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 9 | our $VERSION = '2.25'; | |||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 9 | my %ALGO_LENGTH = ('md5' => 32, 'sha1' => 40, 'sha256' => 64, 'sha384' => 96, 'sha512' => 128); | |||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 9 | my %CACHE = (); | |||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 1626 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 1626 | my ($class, $type) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 1626 | ▶ | Carp::croak 'Missing PURL type' unless $type; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 1626 | $type = lc $type; | |||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 1626 | ▶ | my $self = {type => $type, definition => _load_definition($type) || {}}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
_load_definition($type) || {}
MC/DC100%1/1
_load_definition($type) || {}
_load_definition($type)
Truth table100%2/2
A
A= _load_definition($type)
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 1626 | return bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 89 | ▶ | sub definition_dir { File::Spec->catfile(dirname(__FILE__), 'types') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
definition_dir: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 89 | ▶ | sub _file_content { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_file_content: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 89 | my $path = shift; | |||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 89 | ▶ | return unless -e $path; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 82 | ▶ | open my $fh, '<', $path or Carp::croak "Can't open file: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 82 | my $content = do { local $/; <$fh> }; | |||||||||||||||||||||||||||||||||||||||||
| 47 | 82 | close $fh; | |||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 82 | return $content; | |||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 1626 | ▶ | sub _load_definition { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_definition: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 1626 | my $purl_type = shift; | |||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | 1626 | ▶ | return $CACHE{$purl_type} if defined $CACHE{$purl_type}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 89 | my $content = _file_content(File::Spec->catfile(definition_dir, "$purl_type-definition.json")); | |||||||||||||||||||||||||||||||||||||||||
| 60 | 89 | ▶ | return unless $content; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 82 | DEBUG and say STDERR "-- Loaded '$purl_type' definition schema"; | |||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 82 | my $data = eval { decode_json($content) }; | |||||||||||||||||||||||||||||||||||||||||
| 65 | 82 | ▶ | Carp::croak "Failed to decode '$purl_type' PURL type definition: $@" if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 82 | $CACHE{$purl_type} = $data; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 82 | return $data; | |||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 40501 | ▶ | sub definition { shift->{definition} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
definition: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 19440 | ▶ | sub _property { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_property: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 19440 | my ($self, $property, $sub_property) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 19440 | ▶ | return unless $self->definition; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 19440 | ▶ | return $self->definition->{$property} unless defined $sub_property; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 11498 | return $self->definition->{$property}->{$sub_property}; | |||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | sub schema_id { shift->_property('$id') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
schema_id: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | sub type_name { shift->_property('type_name') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
type_name: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | sub description { shift->_property('description') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
description: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 1859 | ▶ | sub default_repository_url { shift->_property('repository', 'default_repository_url') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_repository_url: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | sub examples { shift->_property('examples') || [] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
examples: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | sub repository { shift->_property('repository') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
repository: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | sub note { shift->_property('note') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
note: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | sub reference_urls { shift->_property('reference_urls') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reference_urls: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | sub namespace_definition { shift->component_definition('namespace') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
namespace_definition: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | sub name_definition { shift->component_definition('name') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name_definition: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | sub version_definition { shift->component_definition('version') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
version_definition: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 1582 | ▶ | sub qualifiers_definition { shift->component_definition('qualifiers') || [] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
qualifiers_definition: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | sub subpath_definition { shift->component_definition('subpath') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subpath_definition: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | 6360 | ▶ | sub component_have_definition { defined shift->component_definition(shift) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
component_have_definition: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 7942 | ▶ | sub component_definition { shift->_property(shift . '_definition') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
component_definition: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | sub component_case_sensitive { shift->_property(shift . '_definition', 'case_sensitive') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
component_case_sensitive: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | sub component_is_case_sensitive { shift->component_case_sensitive(shift) == 1 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
component_is_case_sensitive: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | sub component_is_optional { shift->component_requirement(shift) eq 'optional' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
component_is_optional: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 4438 | ▶ | sub component_is_prohibited { shift->component_requirement(shift) eq 'prohibited' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
component_is_prohibited: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 377 | ▶ | sub component_is_required { shift->component_requirement(shift) eq 'required' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
component_is_required: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | sub component_native_name { shift->_property(shift . '_definition', 'native_name') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
component_native_name: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | sub component_normalization_rules { shift->_property(shift . '_definition', 'normalization_rules') || [] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
component_normalization_rules: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | sub component_note { shift->_property(shift . '_definition', 'note') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
component_note: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | sub component_permitted_characters { shift->_property(shift . '_definition', 'permitted_characters') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
component_permitted_characters: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 9639 | ▶ | sub component_requirement { shift->_property(shift . '_definition', 'requirement') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
component_requirement: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | 1626 | ▶ | sub normalize { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
normalize: called CC=16 SCAR=27.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 1626 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | 1626 | my %components = ( | |||||||||||||||||||||||||||||||||||||||||
| 118 | type => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 119 | namespace => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 120 | name => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 121 | version => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 122 | version => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 123 | qualifiers => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 124 | subpath => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 125 | @_ | ||||||||||||||||||||||||||||||||||||||||||
| 126 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | # Common normalizations | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 1626 | $components{type} = lc $components{type}; | |||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 1626 | ▶ | if (grep { $_ eq $components{type} } qw(alpm apk bitbucket composer deb github gitlab hex npm oci pypi)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | 150 | $components{name} = lc $components{name}; | |||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 1626 | ▶ | if (defined $components{namespace}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 1330 | ▶ | if (grep { $_ eq $components{type} } qw(alpm apk bitbucket composer deb github gitlab golang hex rpm)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 126 | $components{namespace} = lc $components{namespace}; | |||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | # The namespace is the CPAN id of the author/publisher. It MUST be written uppercase and is required. | ||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | 1330 | ▶ | if ($components{type} eq 'cpan') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | 997 | $components{namespace} = uc $components{namespace}; | |||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | # Force checksum into ARRAY | ||||||||||||||||||||||||||||||||||||||||||
| 150 | 1626 | ▶ | if (defined $components{qualifiers}->{checksum} and ref $components{qualifiers}->{checksum} ne 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $components{"qualifiers"}{"checksum"} and ref $components{"qualifiers"}{"checksum"} ne "ARRAY"
MC/DC100%2/2
defined $components{"qualifiers"}{"checksum"} and ref $components{"qualifiers"}{"checksum"} ne "ARRAY"
defined $components{"qualifiers"}{"checksum"}
ref $components{"qualifiers"}{"checksum"} ne "ARRAY"
Truth table100%3/3
A and B
A= defined $components{"qualifiers"}{"checksum"}B= ref $components{"qualifiers"}{"checksum"} ne "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | 2 | $components{qualifiers}->{checksum} = [$components{qualifiers}->{checksum}]; | |||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | # PURL type specific normalization | ||||||||||||||||||||||||||||||||||||||||||
| 155 | 1626 | TYPE: for ($components{type}) { | |||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | 1626 | ▶ | if (/huggingface/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | # The version is the model revision Git commit hash. It is case insensitive and | ||||||||||||||||||||||||||||||||||||||||||
| 160 | # must be lowercased in the package URL. | ||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | 27 | $components{version} = lc $components{version}; | |||||||||||||||||||||||||||||||||||||||||
| 163 | 27 | last TYPE; | |||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | 1599 | ▶ | if (/mlflow/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | # The "name" case sensitivity depends on the server implementation: | ||||||||||||||||||||||||||||||||||||||||||
| 169 | # - Azure ML: it is case sensitive and must be kept as-is in the package URL. | ||||||||||||||||||||||||||||||||||||||||||
| 170 | # - Databricks: it is case insensitive and must be lowercased in the package URL. | ||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | 27 | ▶ | last TYPE unless $components{qualifiers}->{repository_url}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | 27 | ▶ | if ($components{qualifiers}->{repository_url} =~ /azuredatabricks/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | 17 | $components{name} = lc $components{name}; | |||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||
| 177 | 27 | last TYPE; | |||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 1572 | ▶ | if (/pypi/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | # A PyPI package name must be lowercased and underscore "_" replaced with a dash "-". | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 21 | $components{name} =~ s/_/-/g; | |||||||||||||||||||||||||||||||||||||||||
| 184 | 21 | last TYPE; | |||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | 1551 | ▶ | if (/cpan/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | 1011 | ▶ | if (defined $components{qualifiers}->{author}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | # CPAN ID. It MUST be written uppercase. | ||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | $components{qualifiers}->{author} = uc $components{qualifiers}->{author}; | |||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||
| 193 | 1011 | last TYPE; | |||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | 1626 | ▶ | return wantarray ? %components : \%components; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 1626 | ▶ | sub validate { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
validate: called CC=48 SCAR=40.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | 1626 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | 1626 | my %components = ( | |||||||||||||||||||||||||||||||||||||||||
| 207 | type => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 208 | namespace => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 209 | name => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 210 | version => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 211 | version => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 212 | qualifiers => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 213 | subpath => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 214 | @_ | ||||||||||||||||||||||||||||||||||||||||||
| 215 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | 1626 | my $purl_type = $components{type}; | |||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | # Check PURL components requirements | ||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | 1626 | ▶ | Carp::croak "Invalid PURL: '$components{scheme}' is not a valid scheme" unless ($components{scheme} eq 'pkg'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | 1626 | foreach my $qualifier (keys %{$components{qualifiers}}) { | |||||||||||||||||||||||||||||||||||||||||
| 225 | 1378 | ▶ | Carp::croak "Invalid PURL: '$qualifier' is not a valid qualifier" if ($qualifier =~ /(\s|\%)/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | # Check checksum qualifier | ||||||||||||||||||||||||||||||||||||||||||
| 229 | 1621 | ▶ | if (defined $components{qualifiers}->{checksum} and ref $components{qualifiers}->{checksum} eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $components{"qualifiers"}{"checksum"} and ref $components{"qualifiers"}{"checksum"} eq "ARRAY"
MC/DC50%1/2
defined $components{"qualifiers"}{"checksum"} and ref $components{"qualifiers"}{"checksum"} eq "ARRAY"
defined $components{"qualifiers"}{"checksum"}
ref $components{"qualifiers"}{"checksum"} eq "ARRAY"
Truth table66%2/3
A and B
A= defined $components{"qualifiers"}{"checksum"}B= ref $components{"qualifiers"}{"checksum"} eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | 7 | foreach (@{$components{qualifiers}->{checksum}}) { | |||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | 10 | my ($algo, $checksum) = split ':', $_; | |||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | 10 | ▶ | if (defined $ALGO_LENGTH{$algo}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | 10 | ▶ | if (length($checksum) != $ALGO_LENGTH{$algo}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | 10 | DEBUG and say STDERR "-- Malformed '$algo' checksum qualifier (invalid length)"; | |||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | 10 | ▶ | if ($checksum !~ m/^[0-9a-f]+$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | 1 | DEBUG and say STDERR "-- Malformed '$algo' checksum qualifier (invalid characters)"; | |||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | # Fallback | ||||||||||||||||||||||||||||||||||||||||||
| 248 | elsif ($checksum !~ /^[0-9a-f]{32,}$/) { | ||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | DEBUG and say STDERR "-- Malformed '$algo' checksum qualifier (invalid characters or length)"; | |||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | # PURL type definition validation | ||||||||||||||||||||||||||||||||||||||||||
| 257 | 1621 | ▶ | if (%{$self->definition}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||
| 259 | # Check components using PURL type definition | ||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | 1614 | for my $component (qw[namespace name version subpath]) { | |||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | 6360 | ▶ | next unless $self->component_have_definition($component); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | 4824 | my $requirement = $self->component_requirement($component); | |||||||||||||||||||||||||||||||||||||||||
| 266 | 4824 | ▶ | next unless $requirement; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | 4815 | DEBUG and say STDERR "-- Validation - $component is $requirement"; | |||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||
| 270 | 4815 | ▶ | if (defined $components{$component} && $self->component_is_prohibited($component)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $components{$component} and $self->component_is_prohibited($component)
MC/DC100%2/2
defined $components{$component} and $self->component_is_prohibited($component)
defined $components{$component}
$self->component_is_prohibited($component)
Truth table100%3/3
A and B
A= defined $components{$component}B= $self->component_is_prohibited($component)
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | 2 | Carp::croak sprintf("Invalid PURL: '%s' is prohibited for '%s' PURL type", $component, $purl_type); | |||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | 4813 | ▶ | if (!defined $components{$component} && $self->component_is_required($component)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not defined $components{$component} and $self->component_is_required($component)
MC/DC100%2/2
not defined $components{$component} and $self->component_is_required($component)
not defined $components{$component}
$self->component_is_required($component)
Truth table100%3/3
not(A) and B
A= not defined $components{$component}B= $self->component_is_required($component)
| |||||||||||||||||||||||||||||||||||||||||||
| 275 | 30 | Carp::croak sprintf("Invalid PURL: '%s' is required for '%s' PURL type", $component, $purl_type); | |||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | # Default known qualifiers | ||||||||||||||||||||||||||||||||||||||||||
| 281 | # TODO: "checksums" legacy qualifier | ||||||||||||||||||||||||||||||||||||||||||
| 282 | 1582 | my @known_qualifiers = (qw[ | |||||||||||||||||||||||||||||||||||||||||
| 283 | vers | ||||||||||||||||||||||||||||||||||||||||||
| 284 | repository_url | ||||||||||||||||||||||||||||||||||||||||||
| 285 | download_url | ||||||||||||||||||||||||||||||||||||||||||
| 286 | vcs_url | ||||||||||||||||||||||||||||||||||||||||||
| 287 | file_name | ||||||||||||||||||||||||||||||||||||||||||
| 288 | checksum | ||||||||||||||||||||||||||||||||||||||||||
| 289 | checksums | ||||||||||||||||||||||||||||||||||||||||||
| 290 | ]); | ||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | 1582 | foreach my $rule (@{$self->qualifiers_definition}) { | |||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||
| 294 | 4682 | my $key = $rule->{key}; | |||||||||||||||||||||||||||||||||||||||||
| 295 | 4682 | push @known_qualifiers, $key; | |||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | 4682 | my $requirement = $rule->{requirement}; | |||||||||||||||||||||||||||||||||||||||||
| 298 | 4682 | ▶ | next unless $requirement; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | 4440 | DEBUG and say STDERR "-- Validation - '$key' qualifier is $requirement"; | |||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | 4440 | ▶ | if (defined $components{qualifiers}->{$key} and $requirement eq 'prohibited') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $components{"qualifiers"}{$key} and $requirement eq "prohibited"
MC/DC0%0/2
defined $components{"qualifiers"}{$key} and $requirement eq "prohibited"
defined $components{"qualifiers"}{$key}
$requirement eq "prohibited"
Truth table66%2/3
A and B
A= defined $components{"qualifiers"}{$key}B= $requirement eq "prohibited"
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | Carp::croak sprintf("Invalid PURL: '%s' qualifier is prohibited for '%s' PURL type", $key, $purl_type); | |||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | 4440 | ▶ | if (not defined $components{qualifiers}->{$key} and $requirement eq 'required') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not defined $components{"qualifiers"}{$key} and $requirement eq "required"
MC/DC100%2/2
not defined $components{"qualifiers"}{$key} and $requirement eq "required"
not defined $components{"qualifiers"}{$key}
$requirement eq "required"
Truth table100%3/3
not(A) and B
A= not defined $components{"qualifiers"}{$key}B= $requirement eq "required"
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | 1 | Carp::croak sprintf("Invalid PURL: '%s' qualifier is required for '%s' PURL type", $key, $purl_type); | |||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | # Check unknown qualifiers | ||||||||||||||||||||||||||||||||||||||||||
| 313 | 1581 | foreach my $key (keys %{$components{qualifiers}}) { | |||||||||||||||||||||||||||||||||||||||||
| 314 | DEBUG and say STDERR "-- '$key' is known qualifier for '$purl_type' PURL type" | ||||||||||||||||||||||||||||||||||||||||||
| 315 | 1373 | ▶ | unless (first { $key eq $_ } @known_qualifiers); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||
| 321 | # PURL type specific validation | ||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||
| 323 | 1588 | TYPE: for ($purl_type) { | |||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||
| 325 | 1588 | ▶ | if (/conan/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 326 | 29 | ▶ | if (!$components{namespace} && defined $components{qualifiers}->{channel}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $components{"namespace"} and defined $components{"qualifiers"}{"channel"}
MC/DC100%2/2
not $components{"namespace"} and defined $components{"qualifiers"}{"channel"}
not $components{"namespace"}
defined $components{"qualifiers"}{"channel"}
Truth table100%3/3
not(A) and B
A= not $components{"namespace"}B= defined $components{"qualifiers"}{"channel"}
| |||||||||||||||||||||||||||||||||||||||||||
| 327 | 3 | Carp::croak "Invalid PURL: Conan 'channel' qualifier without 'namespace'"; | |||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||
| 329 | 26 | last TYPE; | |||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | 1559 | ▶ | if (/cpan/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||
| 334 | # Use legacy CPAN PURL type SPEC | ||||||||||||||||||||||||||||||||||||||||||
| 335 | 997 | ▶ | if ($ENV{PURL_LEGACY_CPAN_TYPE}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||
| 337 | 6 | ▶ | if ((defined $components{namespace} && defined $components{name}) && $components{namespace} =~ /\:/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $components{"namespace"} and defined $components{"name"} and $components{"namespace"} =~ /\:/
defined $components{"namespace"} and defined $components{"name"}
MC/DC0%0/3
defined $components{"namespace"} and defined $components{"name"} and $components{"namespace"} =~ /\:/
defined $components{"namespace"}
defined $components{"name"}
$components{"namespace"} =~ /\:/
Truth table25%1/4
A and B and C
A= defined $components{"namespace"}B= defined $components{"name"}C= $components{"namespace"} =~ /\:/
| |||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | Carp::croak "Invalid PURL: CPAN 'namespace' component must have the distribution author"; | |||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | 6 | ▶ | if ((defined $components{namespace} && defined $components{name}) && $components{name} =~ /\:/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
defined $components{"namespace"} and defined $components{"name"} and $components{"name"} =~ /\:/
defined $components{"namespace"} and defined $components{"name"}
MC/DC33%1/3
defined $components{"namespace"} and defined $components{"name"} and $components{"name"} =~ /\:/
defined $components{"namespace"}
defined $components{"name"}
$components{"name"} =~ /\:/
Truth table50%2/4
A and B and C
A= defined $components{"namespace"}B= defined $components{"name"}C= $components{"name"} =~ /\:/
| |||||||||||||||||||||||||||||||||||||||||||
| 342 | 3 | Carp::croak "Invalid PURL: CPAN 'name' component must have the distribution name"; | |||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | 3 | ▶ | if (!defined $components{namespace} && $components{name} =~ /\-/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $components{"namespace"} and $components{"name"} =~ /\-/
MC/DC0%0/2
not defined $components{"namespace"} and $components{"name"} =~ /\-/
not defined $components{"namespace"}
$components{"name"} =~ /\-/
Truth table33%1/3
not(A) and B
A= not defined $components{"namespace"}B= $components{"name"} =~ /\-/
| |||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | Carp::croak "Invalid PURL: CPAN 'name' component must have the module name"; | |||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||
| 349 | 3 | last TYPE; | |||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||
| 353 | 991 | ▶ | if ($components{name} =~ /\:/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 354 | 2 | Carp::croak "Invalid PURL: The CPAN 'name' component must have the distribution name"; | |||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | 989 | last TYPE; | |||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||
| 361 | 562 | ▶ | if (/cran/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 362 | 19 | ▶ | Carp::croak "Invalid PURL: Cran 'version' is required" unless defined $components{version}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 363 | 16 | last TYPE; | |||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||
| 366 | 543 | ▶ | if (/swift/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||
| 368 | # TODO remove after spec FIX | ||||||||||||||||||||||||||||||||||||||||||
| 369 | 23 | ▶ | Carp::croak "Invalid PURL: Swift 'version' is required" unless defined $components{version}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||
| 371 | 17 | ▶ | if (defined $components{namespace}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 372 | 17 | my ($source, $user_org) = split '/', $components{namespace}; | |||||||||||||||||||||||||||||||||||||||||
| 373 | 17 | ▶ | Carp::croak "Invalid PURL: Swift user/organization is required in 'namespace'" unless $user_org; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | 13 | last TYPE; | |||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | 1567 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||
| 387 | 9 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||
| 389 | __END__ | ||||||||||||||||||||||||||||||||||||||||||