« /usr/local/lib/perl5/5.44.0/Symbol.pm
↑ Summary
/usr/local/lib/perl5/site_perl/5.44.0/x86_64-linux/Cpanel/JSON/XS.pm »
| 1 | 7 | ▶ | use 5.008001; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | package CPAN::Meta::Converter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 7 | our $VERSION = '2.150013'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | #pod =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | #pod my $struct = decode_json_file('META.json'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | #pod my $cmc = CPAN::Meta::Converter->new( $struct ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | #pod my $new_struct = $cmc->convert( version => "2" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | #pod =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | #pod This module converts CPAN Meta structures from one form to another. The | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | #pod primary use is to convert older structures to the most modern version of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | #pod the specification, but other transformations may be implemented in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | #pod future as needed. (E.g. stripping all custom fields or stripping all | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | #pod optional fields.) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | #pod =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 7 | ▶ | use CPAN::Meta::Validator; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 7 | ▶ | use CPAN::Meta::Requirements; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 7 | ▶ | use Parse::CPAN::Meta 1.4400 (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # To help ExtUtils::MakeMaker bootstrap CPAN::Meta::Requirements on perls | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | # before 5.10, we fall back to the EUMM bundled compatibility version module if | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # that's the only thing available. This shouldn't ever happen in a normal CPAN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | # install of CPAN::Meta::Requirements, as version.pm will be picked up from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | # prereqs and be available at runtime. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 7 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=3 SCAR=12.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 7 | ▶ | eval "use version ()"; ## no critic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 7 | ▶ | if ( my $err = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | eval "use ExtUtils::MakeMaker::version" or die $err; ## no critic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | # Perl 5.10.0 didn't have "is_qv" in version.pm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | *_is_qv = version->can('is_qv') ? sub { $_[0]->is_qv } : sub { exists $_[0]->{qv} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.6
Subroutine
__ANON__: not called CC=1 SCAR=0.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | # We limit cloning to a maximum depth to bail out on circular data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | # structures. While actual cycle detection might be technically better, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | # we expect circularity in META data structures to be rare and generally | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | # the result of user error. Therefore, a depth counter is lower overhead. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 7 | our $DCLONE_MAXDEPTH = 1024; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 7 | our $_CLONE_DEPTH; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 10129 | ▶ | sub _dclone { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dclone: called CC=9 SCAR=23.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 10129 | my ( $ref ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 10129 | ▶ | return $ref unless my $reftype = ref $ref; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 3143 | ▶ | local $_CLONE_DEPTH = defined $_CLONE_DEPTH ? $_CLONE_DEPTH - 1 : $DCLONE_MAXDEPTH; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 3143 | ▶ | die "Depth Limit $DCLONE_MAXDEPTH Exceeded" if $_CLONE_DEPTH == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 3143 | ▶ | return [ map { _dclone( $_ ) } @{$ref} ] if 'ARRAY' eq $reftype; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 2793 | ▶ | return { map { $_ => _dclone( $ref->{$_} ) } keys %{$ref} } if 'HASH' eq $reftype; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 7 | ▶ | if ( 'SCALAR' eq $reftype ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | my $new = _dclone(${$ref}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | return \$new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | # We can't know if TO_JSON gives us cloned data, so refs must recurse | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 7 | ▶ | if ( eval { $ref->can('TO_JSON') } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 7 | my $data = $ref->TO_JSON; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 7 | ▶ | return ref $data ? _dclone( $data ) : $data; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | # Just stringify everything else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | return "$ref"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 7 | my %known_specs = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | '2' => 'http://search.cpan.org/perldoc?CPAN::Meta::Spec', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | '1.4' => 'http://module-build.sourceforge.net/META-spec-v1.4.html', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | '1.3' => 'http://module-build.sourceforge.net/META-spec-v1.3.html', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | '1.2' => 'http://module-build.sourceforge.net/META-spec-v1.2.html', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | '1.1' => 'http://module-build.sourceforge.net/META-spec-v1.1.html', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | '1.0' => 'http://module-build.sourceforge.net/META-spec-v1.0.html' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 7 | my @spec_list = sort { $a <=> $b } keys %known_specs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 7 | my ($LOWEST, $HIGHEST) = @spec_list[0,-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | #--------------------------------------------------------------------------# | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | # converters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | # called as $converter->($element, $field_name, $full_meta, $to_version) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | # defined return value used for field | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | # undef return value means field is skipped | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | #--------------------------------------------------------------------------# | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 903 | ▶ | sub _keep { $_[0] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_keep: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 7 | ▶ | sub _keep_or_one { defined($_[0]) ? $_[0] : 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_keep_or_one: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | sub _keep_or_zero { defined($_[0]) ? $_[0] : 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_keep_or_zero: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 7 | ▶ | sub _keep_or_unknown { defined($_[0]) && length($_[0]) ? $_[0] : "unknown" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_keep_or_unknown: called CC=3 SCAR=14.2
Branch: 1 branch
Condition33%1/3
defined $_[0] and length $_[0]
MC/DC0%0/2
defined $_[0] and length $_[0]
defined $_[0]
length $_[0]
Truth table33%1/3
A and B
A= defined $_[0]B= length $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 7 | ▶ | sub _generated_by { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generated_by: called CC=5 SCAR=19.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 7 | my $gen = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 7 | ▶ | my $sig = __PACKAGE__ . " version " . (__PACKAGE__->VERSION || "<dev>"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
__PACKAGE__->VERSION || '<dev>'
MC/DC0%0/1
__PACKAGE__->VERSION || '<dev>'
__PACKAGE__->VERSION
Truth table50%1/2
A
A= __PACKAGE__->VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 7 | ▶ | return $sig unless defined $gen and length $gen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $gen and length $gen
MC/DC0%0/2
defined $gen and length $gen
defined $gen
length $gen
Truth table33%1/3
A and B
A= defined $genB= length $gen
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 7 | ▶ | return $gen if $gen =~ /\Q$sig/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | return "$gen, $sig"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 7 | ▶ | sub _listify { ! defined $_[0] ? undef : ref $_[0] eq 'ARRAY' ? $_[0] : [$_[0]] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_listify: called CC=3 SCAR=12.7
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 42 | ▶ | sub _prefix_custom { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_prefix_custom: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 42 | my $key = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 42 | $key =~ s/^(?!x_) # Unless it already starts with x_ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | (?:x-?)? # Remove leading x- or x (if present) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | /x_/ix; # and prepend x_ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 42 | return $key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | sub _ucfirst_custom { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ucfirst_custom: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | my $key = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | $key = ucfirst $key unless $key =~ /[A-Z]/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | return $key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | sub _no_prefix_ucfirst_custom { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_no_prefix_ucfirst_custom: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | my $key = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | $key =~ s/^x_//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | return _ucfirst_custom($key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 7 | ▶ | sub _change_meta_spec { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_change_meta_spec: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 7 | my ($element, undef, undef, $version) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | version => $version, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 7 | url => $known_specs{$version}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 7 | my @open_source = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 'perl', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 'gpl', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 'apache', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 'artistic', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 'artistic_2', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 'lgpl', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 'bsd', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 'gpl', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 'mit', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 'mozilla', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 'open_source', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 7 | my %is_open_source = map {; $_ => 1 } @open_source; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 7 | my @valid_licenses_1 = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | @open_source, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 'unrestricted', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 'restrictive', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 'unknown', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | my %license_map_1 = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 7 | ( map { $_ => $_ } @valid_licenses_1 ), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | artistic2 => 'artistic_2', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | sub _license_1 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_license_1: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | my ($element) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | return 'unknown' unless defined $element; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | if ( $license_map_1{lc $element} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | return $license_map_1{lc $element}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | return 'unknown'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 7 | my @valid_licenses_2 = qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | agpl_3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | apache_1_1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | apache_2_0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | artistic_1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | artistic_2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | bsd | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | freebsd | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | gfdl_1_2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | gfdl_1_3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | gpl_1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | gpl_2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | gpl_3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | lgpl_2_1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | lgpl_3_0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | mit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | mozilla_1_0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | mozilla_1_1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | openssl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | perl_5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | qpl_1_0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | ssleay | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | sun | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | zlib | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | open_source | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | restricted | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | unrestricted | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | unknown | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | # The "old" values were defined by Module::Build, and were often vague. I have | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | # made the decisions below based on reading Module::Build::API and how clearly | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | # it specifies the version of the license. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | my %license_map_2 = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 7 | (map { $_ => $_ } @valid_licenses_2), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | apache => 'apache_2_0', # clearly stated as 2.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | artistic => 'artistic_1', # clearly stated as 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | artistic2 => 'artistic_2', # clearly stated as 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | gpl => 'open_source', # we don't know which GPL; punt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | lgpl => 'open_source', # we don't know which LGPL; punt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | mozilla => 'open_source', # we don't know which MPL; punt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | perl => 'perl_5', # clearly Perl 5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | restrictive => 'restricted', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 7 | ▶ | sub _license_2 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_license_2: called CC=7 SCAR=20.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 7 | my ($element) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 7 | ▶ | return [ 'unknown' ] unless defined $element; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 7 | ▶ | $element = [ $element ] unless ref $element eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 7 | my @new_list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 7 | for my $lic ( @$element ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 7 | ▶ | next unless defined $lic; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 7 | ▶ | if ( my $new = $license_map_2{lc $lic} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 7 | push @new_list, $new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 7 | ▶ | return @new_list ? \@new_list : [ 'unknown' ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 7 | my %license_downgrade_map = qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | agpl_3 open_source | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | apache_1_1 apache | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | apache_2_0 apache | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | artistic_1 artistic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | artistic_2 artistic_2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | bsd bsd | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | freebsd open_source | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | gfdl_1_2 open_source | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | gfdl_1_3 open_source | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | gpl_1 gpl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | gpl_2 gpl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | gpl_3 gpl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | lgpl_2_1 lgpl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | lgpl_3_0 lgpl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | mit mit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | mozilla_1_0 mozilla | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | mozilla_1_1 mozilla | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | openssl open_source | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | perl_5 perl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | qpl_1_0 open_source | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | ssleay open_source | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | sun open_source | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | zlib open_source | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | open_source open_source | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | restricted restrictive | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | unrestricted unrestricted | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | unknown unknown | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | sub _downgrade_license { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_downgrade_license: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | my ($element) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | if ( ! defined $element ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | return "unknown"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | elsif( ref $element eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | if ( @$element > 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | if (grep { !$is_open_source{ $license_downgrade_map{lc $_} || 'unknown' } } @$element) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$license_downgrade_map{lc $_} || 'unknown'
MC/DC0%0/1
$license_downgrade_map{lc $_} || 'unknown'
$license_downgrade_map{lc $_}
Truth table0%0/2
A
A= $license_downgrade_map{lc $_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | return 'unknown'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | return 'open_source'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | elsif ( @$element == 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | return $license_downgrade_map{lc $element->[0]} || "unknown"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$license_downgrade_map{lc $element->[0]} || 'unknown'
MC/DC0%0/1
$license_downgrade_map{lc $element->[0]} || 'unknown'
$license_downgrade_map{lc $element->[0]}
Truth table0%0/2
A
A= $license_downgrade_map{lc $element->[0]}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | elsif ( ! ref $element ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | return $license_downgrade_map{lc $element} || "unknown"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$license_downgrade_map{lc $element} || 'unknown'
MC/DC0%0/1
$license_downgrade_map{lc $element} || 'unknown'
$license_downgrade_map{lc $element}
Truth table0%0/2
A
A= $license_downgrade_map{lc $element}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | return "unknown"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 7 | my $no_index_spec_1_2 = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 'file' => \&_listify, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 'dir' => \&_listify, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 'package' => \&_listify, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 'namespace' => \&_listify, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 7 | my $no_index_spec_1_3 = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 'file' => \&_listify, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 'directory' => \&_listify, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 'package' => \&_listify, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 'namespace' => \&_listify, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 7 | my $no_index_spec_2 = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 'file' => \&_listify, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 'directory' => \&_listify, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 'package' => \&_listify, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 'namespace' => \&_listify, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | ':custom' => \&_prefix_custom, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | sub _no_index_1_2 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_no_index_1_2: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | my (undef, undef, $meta) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | my $no_index = $meta->{no_index} || $meta->{private}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$meta->{'no_index'} || $meta->{'private'}
MC/DC0%0/2
$meta->{'no_index'} || $meta->{'private'}
$meta->{'no_index'}
$meta->{'private'}
Truth table0%0/3
A || B
A= $meta->{'no_index'}B= $meta->{'private'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | return unless $no_index; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | # cleanup wrong format | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | ▶ | if ( ! ref $no_index ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | my $item = $no_index; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | $no_index = { dir => [ $item ], file => [ $item ] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | elsif ( ref $no_index eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | my $list = $no_index; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | $no_index = { dir => [ @$list ], file => [ @$list ] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | # common mistake: files -> file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | if ( exists $no_index->{files} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | $no_index->{file} = delete $no_index->{files}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | # common mistake: modules -> module | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | if ( exists $no_index->{modules} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | $no_index->{module} = delete $no_index->{modules}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | return _convert($no_index, $no_index_spec_1_2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 7 | ▶ | sub _no_index_directory { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_no_index_directory: called CC=8 SCAR=39.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 7 | my ($element, $key, $meta, $version) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 7 | ▶ | return unless $element; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | # clean up wrong format | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | ▶ | if ( ! ref $element ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | my $item = $element; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | $element = { directory => [ $item ], file => [ $item ] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | elsif ( ref $element eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | my $list = $element; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | $element = { directory => [ @$list ], file => [ @$list ] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | if ( exists $element->{dir} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | $element->{directory} = delete $element->{dir}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | # common mistake: files -> file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | if ( exists $element->{files} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | $element->{file} = delete $element->{files}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | # common mistake: modules -> module | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | if ( exists $element->{modules} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | $element->{module} = delete $element->{modules}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | my $spec = $version == 2 ? $no_index_spec_2 : $no_index_spec_1_3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | return _convert($element, $spec); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 532 | ▶ | sub _is_module_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_module_name: called CC=3 SCAR=12.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 532 | my $mod = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 532 | ▶ | return unless defined $mod && length $mod; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $mod and length $mod
MC/DC0%0/2
defined $mod and length $mod
defined $mod
length $mod
Truth table33%1/3
A and B
A= defined $modB= length $mod
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 532 | return $mod =~ m{^[A-Za-z][A-Za-z0-9_]*(?:::[A-Za-z0-9_]+)*$}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 434 | ▶ | sub _clean_version { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_clean_version: called CC=7 SCAR=21.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 434 | my ($element) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 434 | ▶ | return 0 if ! defined $element; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 434 | $element =~ s{^\s*}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 434 | $element =~ s{\s*$}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 434 | $element =~ s{^\.}{0.}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 434 | ▶ | return 0 if ! length $element; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 434 | ▶ | return 0 if ( $element eq 'undef' || $element eq '<undef>' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$element eq "undef" or $element eq "<undef>"
MC/DC0%0/2
$element eq "undef" or $element eq "<undef>"
$element eq "undef"
$element eq "<undef>"
Truth table33%1/3
A or B
A= $element eq "undef"B= $element eq "<undef>"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 434 | my $v = eval { version->new($element) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | # XXX check defined $v and not just $v because version objects leak memory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | # in boolean context -- dagolden, 2012-02-03 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 434 | ▶ | if ( defined $v ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 434 | ▶ | return _is_qv($v) ? $v->normal : $element; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | sub _bad_version_hook { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_bad_version_hook: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | my ($v) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | $v =~ s{^\s*}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | $v =~ s{\s*$}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | $v =~ s{[a-z]+$}{}; # strip trailing alphabetics | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | my $vobj = eval { version->new($v) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | ▶ | return defined($vobj) ? $vobj : version->new(0); # or give up | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 140 | ▶ | sub _version_map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_version_map: called CC=14 SCAR=38.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 140 | my ($element) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 140 | ▶ | return unless defined $element; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 42 | ▶ | if ( ref $element eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | # XXX turn this into CPAN::Meta::Requirements with bad version hook | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | # and then turn it back into a hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 42 | my $new_map = CPAN::Meta::Requirements->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | { bad_version_hook => \&_bad_version_hook } # punt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 42 | ▶ | while ( my ($k,$v) = each %$element ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 266 | ▶ | next unless _is_module_name($k); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 266 | ▶ | if ( !defined($v) || !length($v) || $v eq 'undef' || $v eq '<undef>' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
not defined $v && length $v or $v eq "undef" or $v eq "<undef>"
not defined $v && length $v or $v eq "undef"
defined $v && length $v
MC/DC0%0/4
not defined $v && length $v or $v eq "undef" or $v eq "<undef>"
defined $v
length $v
$v eq "undef"
$v eq "<undef>"
Truth table20%1/5
not(A && B) or C or D
A= defined $vB= length $vC= $v eq "undef"D= $v eq "<undef>"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | $v = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | # some weird, old META have bad yml with module => module | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | # so check if value is like a module name and not like a version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 266 | ▶ | if ( _is_module_name($v) && ! version::is_lax($v) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
_is_module_name($v) and not version::is_lax($v)
MC/DC0%0/2
_is_module_name($v) and not version::is_lax($v)
_is_module_name($v)
not version::is_lax($v)
Truth table33%1/3
A and not(B)
A= _is_module_name($v)B= not version::is_lax($v)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | $new_map->add_minimum($k => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | $new_map->add_minimum($v => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 266 | $new_map->add_string_requirement($k => $v); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 42 | return $new_map->as_string_hash; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | elsif ( ref $element eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | my $hashref = { map { $_ => 0 } @$element }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | return _version_map($hashref); # clean up any weird stuff | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | ▶ | elsif ( ref $element eq '' && length $element ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $element eq "" and length $element
MC/DC0%0/2
ref $element eq "" and length $element
ref $element eq ""
length $element
Truth table0%0/3
A and B
A= ref $element eq ""B= length $element
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | return { $element => 0 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | ▶ | sub _prereqs_from_1 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_prereqs_from_1: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | my (undef, undef, $meta) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | my $prereqs = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | for my $phase ( qw/build configure/ ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | my $key = "${phase}_requires"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | $prereqs->{$phase}{requires} = _version_map($meta->{$key}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | ▶ | if $meta->{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | for my $rel ( qw/requires recommends conflicts/ ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | $prereqs->{runtime}{$rel} = _version_map($meta->{$rel}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | ▶ | if $meta->{$rel}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | return $prereqs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 7 | my $prereqs_spec = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | configure => \&_prereqs_rel, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | build => \&_prereqs_rel, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | test => \&_prereqs_rel, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | runtime => \&_prereqs_rel, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | develop => \&_prereqs_rel, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | ':custom' => \&_prefix_custom, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 7 | my $relation_spec = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | requires => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | recommends => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | suggests => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | conflicts => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | ':custom' => \&_prefix_custom, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 7 | ▶ | sub _cleanup_prereqs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cleanup_prereqs: called CC=3 SCAR=12.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 7 | my ($prereqs, $key, $meta, $to_version) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 7 | ▶ | return unless $prereqs && ref $prereqs eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$prereqs and ref $prereqs eq "HASH"
MC/DC0%0/2
$prereqs and ref $prereqs eq "HASH"
$prereqs
ref $prereqs eq "HASH"
Truth table33%1/3
A and B
A= $prereqsB= ref $prereqs eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 7 | return _convert( $prereqs, $prereqs_spec, $to_version ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 35 | ▶ | sub _prereqs_rel { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_prereqs_rel: called CC=3 SCAR=12.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 35 | my ($relation, $key, $meta, $to_version) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 35 | ▶ | return unless $relation && ref $relation eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$relation and ref $relation eq "HASH"
MC/DC0%0/2
$relation and ref $relation eq "HASH"
$relation
ref $relation eq "HASH"
Truth table33%1/3
A and B
A= $relationB= ref $relation eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 35 | return _convert( $relation, $relation_spec, $to_version ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 7 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 7 | my @old_prereqs = qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | requires | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | configure_requires | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | recommends | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | conflicts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 7 | for ( @old_prereqs ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 28 | my $sub = "_get_$_"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 28 | my ($phase,$type) = split qr/_/, $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 28 | ▶ | if ( ! defined $type ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 21 | $type = $phase; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 21 | $phase = 'runtime'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 7 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | *{$sub} = sub { _extract_prereqs($_[2]->{prereqs},$phase,$type) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | ▶ | sub _get_build_requires { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_build_requires: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | my ($data, $key, $meta) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | ▶ | my $test_h = _extract_prereqs($_[2]->{prereqs}, qw(test requires)) || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
_extract_prereqs($_[2]{'prereqs'}, ('test', 'requires')) || {}
MC/DC0%0/1
_extract_prereqs($_[2]{'prereqs'}, ('test', 'requires')) || {}
_extract_prereqs($_[2]{'prereqs'}, ('test', 'requires'))
Truth table0%0/2
A
A= _extract_prereqs($_[2]{'prereqs'}, ('test', 'requires'))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | ▶ | my $build_h = _extract_prereqs($_[2]->{prereqs}, qw(build requires)) || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
_extract_prereqs($_[2]{'prereqs'}, ('build', 'requires')) || {}
MC/DC0%0/1
_extract_prereqs($_[2]{'prereqs'}, ('build', 'requires')) || {}
_extract_prereqs($_[2]{'prereqs'}, ('build', 'requires'))
Truth table0%0/2
A
A= _extract_prereqs($_[2]{'prereqs'}, ('build', 'requires'))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | my $test_req = CPAN::Meta::Requirements->from_string_hash($test_h); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | my $build_req = CPAN::Meta::Requirements->from_string_hash($build_h); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | $test_req->add_requirements($build_req)->as_string_hash; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | ▶ | sub _extract_prereqs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_extract_prereqs: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | my ($prereqs, $phase, $type) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | ▶ | return unless ref $prereqs eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | return scalar _version_map($prereqs->{$phase}{$type}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | ▶ | sub _downgrade_optional_features { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_downgrade_optional_features: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | my (undef, undef, $meta) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | ▶ | return unless exists $meta->{optional_features}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | my $origin = $meta->{optional_features}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | my $features = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | for my $name ( keys %$origin ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | $features->{$name} = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | description => $origin->{$name}{description}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | requires => _extract_prereqs($origin->{$name}{prereqs},'runtime','requires'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | configure_requires => _extract_prereqs($origin->{$name}{prereqs},'runtime','configure_requires'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | build_requires => _extract_prereqs($origin->{$name}{prereqs},'runtime','build_requires'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | recommends => _extract_prereqs($origin->{$name}{prereqs},'runtime','recommends'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | conflicts => _extract_prereqs($origin->{$name}{prereqs},'runtime','conflicts'), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | for my $k (keys %{$features->{$name}} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | ▶ | delete $features->{$name}{$k} unless defined $features->{$name}{$k}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | return $features; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | ▶ | sub _upgrade_optional_features { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_upgrade_optional_features: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | my (undef, undef, $meta) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | ▶ | return unless exists $meta->{optional_features}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | my $origin = $meta->{optional_features}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | my $features = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | for my $name ( keys %$origin ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | $features->{$name} = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | description => $origin->{$name}{description}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | prereqs => _prereqs_from_1(undef, undef, $origin->{$name}), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | delete $features->{$name}{prereqs}{configure}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | return $features; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 7 | my $optional_features_2_spec = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | description => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | prereqs => \&_cleanup_prereqs, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | ':custom' => \&_prefix_custom, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | ▶ | sub _feature_2 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_feature_2: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | my ($element, $key, $meta, $to_version) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | ▶ | return unless $element && ref $element eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$element and ref $element eq "HASH"
MC/DC0%0/2
$element and ref $element eq "HASH"
$element
ref $element eq "HASH"
Truth table0%0/3
A and B
A= $elementB= ref $element eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | _convert( $element, $optional_features_2_spec, $to_version ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 7 | ▶ | sub _cleanup_optional_features_2 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cleanup_optional_features_2: called CC=5 SCAR=26.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 7 | my ($element, $key, $meta, $to_version) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 7 | ▶ | return unless $element && ref $element eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$element and ref $element eq "HASH"
MC/DC0%0/2
$element and ref $element eq "HASH"
$element
ref $element eq "HASH"
Truth table33%1/3
A and B
A= $elementB= ref $element eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | my $new_data = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | for my $k ( keys %$element ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | $new_data->{$k} = _feature_2( $element->{$k}, $k, $meta, $to_version ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | ▶ | return unless keys %$new_data; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | return $new_data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | ▶ | sub _optional_features_1_4 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_optional_features_1_4: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | my ($element) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | ▶ | return unless $element; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | $element = _optional_features_as_map($element); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | for my $name ( keys %$element ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | for my $drop ( qw/requires_packages requires_os excluded_os/ ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | delete $element->{$name}{$drop}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | return $element; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | ▶ | sub _optional_features_as_map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_optional_features_as_map: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | my ($element) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | ▶ | return unless $element; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | ▶ | if ( ref $element eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | my %map; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | for my $feature ( @$element ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | my (@parts) = %$feature; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | $map{$parts[0]} = $parts[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | $element = \%map; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | return $element; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 28 | ▶ | sub _is_urlish { defined $_[0] && $_[0] =~ m{\A[-+.a-z0-9]+:.+}i } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_urlish: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 28 | ▶ | sub _url_or_drop { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_url_or_drop: called CC=2 SCAR=8.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 28 | my ($element) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 28 | ▶ | return $element if _is_urlish($element); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 7 | ▶ | sub _url_list { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_url_list: called CC=3 SCAR=18.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 7 | my ($element) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 7 | ▶ | return unless $element; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | $element = _listify( $element ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | $element = [ grep { _is_urlish($_) } @$element ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | ▶ | return unless @$element; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | return $element; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 7 | ▶ | sub _author_list { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_author_list: called CC=5 SCAR=17.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 7 | my ($element) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 7 | ▶ | return [ 'unknown' ] unless $element; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 7 | $element = _listify( $element ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 7 | ▶ | $element = [ map { defined $_ && length $_ ? $_ : 'unknown' } @$element ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $_ and length $_
MC/DC0%0/2
defined $_ and length $_
defined $_
length $_
Truth table33%1/3
A and B
A= defined $_B= length $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 7 | ▶ | return [ 'unknown' ] unless @$element; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 7 | return $element; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | my $resource2_upgrade = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | ▶ | license => sub { return _is_urlish($_[0]) ? _listify( $_[0] ) : undef }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | homepage => \&_url_or_drop, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | ▶ | bugtracker => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | my ($item) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | ▶ | return unless $item; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | ▶ | if ( $item =~ m{^mailto:(.*)$} ) { return { mailto => $1 } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | elsif( _is_urlish($item) ) { return { web => $item } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | else { return } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | ▶ | repository => sub { return _is_urlish($_[0]) ? { url => $_[0] } : undef }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 7 | ':custom' => \&_prefix_custom, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | ▶ | sub _upgrade_resources_2 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_upgrade_resources_2: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | my (undef, undef, $meta, $version) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | ▶ | return unless exists $meta->{resources}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | return _convert($meta->{resources}, $resource2_upgrade); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 7 | my $bugtracker2_spec = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | web => \&_url_or_drop, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | mailto => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | ':custom' => \&_prefix_custom, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 7 | ▶ | sub _repo_type { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_repo_type: called CC=5 SCAR=28.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 7 | my ($element, $key, $meta, $to_version) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 7 | ▶ | return $element if defined $element; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | ▶ | return unless exists $meta->{url}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | my $repo_url = $meta->{url}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | for my $type ( qw/git svn/ ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 0 | ▶ | return $type if $repo_url =~ m{\A$type}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 7 | my $repository2_spec = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | web => \&_url_or_drop, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | url => \&_url_or_drop, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | type => \&_repo_type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | ':custom' => \&_prefix_custom, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | my $resources2_cleanup = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | license => \&_url_list, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | homepage => \&_url_or_drop, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 7 | ▶ | bugtracker => sub { ref $_[0] ? _convert( $_[0], $bugtracker2_spec ) : undef }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 7 | ▶ | repository => sub { my $data = shift; ref $data ? _convert( $data, $repository2_spec ) : undef }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 7 | ':custom' => \&_prefix_custom, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 7 | ▶ | sub _cleanup_resources_2 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cleanup_resources_2: called CC=3 SCAR=12.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 7 | my ($resources, $key, $meta, $to_version) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 7 | ▶ | return unless $resources && ref $resources eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$resources and ref $resources eq "HASH"
MC/DC0%0/2
$resources and ref $resources eq "HASH"
$resources
ref $resources eq "HASH"
Truth table33%1/3
A and B
A= $resourcesB= ref $resources eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 7 | return _convert($resources, $resources2_cleanup, $to_version); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 7 | my $resource1_spec = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | license => \&_url_or_drop, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | homepage => \&_url_or_drop, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | bugtracker => \&_url_or_drop, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | repository => \&_url_or_drop, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | ':custom' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 0 | ▶ | sub _resources_1_3 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resources_1_3: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 0 | my (undef, undef, $meta, $version) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 0 | ▶ | return unless exists $meta->{resources}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 0 | return _convert($meta->{resources}, $resource1_spec); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 7 | *_resources_1_4 = *_resources_1_3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | ▶ | sub _resources_1_2 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resources_1_2: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | my (undef, undef, $meta) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | ▶ | my $resources = $meta->{resources} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$meta->{'resources'} || {}
MC/DC0%0/1
$meta->{'resources'} || {}
$meta->{'resources'}
Truth table0%0/2
A
A= $meta->{'resources'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 0 | ▶ | if ( $meta->{license_url} && ! $resources->{license} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$meta->{"license_url"} and not $resources->{"license"}
MC/DC0%0/2
$meta->{"license_url"} and not $resources->{"license"}
$meta->{"license_url"}
not $resources->{"license"}
Truth table0%0/3
A and not(B)
A= $meta->{"license_url"}B= not $resources->{"license"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | $resources->{license} = $meta->{license_url} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 0 | ▶ | if _is_urlish($meta->{license_url}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 0 | ▶ | return unless keys %$resources; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | return _convert($resources, $resource1_spec); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | my $resource_downgrade_spec = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | ▶ | license => sub { return ref $_[0] ? $_[0]->[0] : $_[0] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | homepage => \&_url_or_drop, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | ▶ | bugtracker => sub { return $_[0]->{web} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 0 | ▶ | repository => sub { return $_[0]->{url} || $_[0]->{web} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Condition0%0/3
$_[0]{'url'} || $_[0]{'web'}
MC/DC0%0/2
$_[0]{'url'} || $_[0]{'web'}
$_[0]{'url'}
$_[0]{'web'}
Truth table0%0/3
A || B
A= $_[0]{'url'}B= $_[0]{'web'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 7 | ':custom' => \&_no_prefix_ucfirst_custom, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | ▶ | sub _downgrade_resources { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_downgrade_resources: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 0 | my (undef, undef, $meta, $version) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 0 | ▶ | return unless exists $meta->{resources}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | return _convert($meta->{resources}, $resource_downgrade_spec); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 7 | ▶ | sub _release_status { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_release_status: called CC=3 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 7 | my ($element, undef, $meta) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 7 | ▶ | return $element if $element && $element =~ m{\A(?:stable|testing|unstable)\z}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$element and $element =~ /\A(?:stable|testing|unstable)\z/
MC/DC0%0/2
$element and $element =~ /\A(?:stable|testing|unstable)\z/
$element
$element =~ /\A(?:stable|testing|unstable)\z/
Truth table33%1/3
A and B
A= $elementB= $element =~ /\A(?:stable|testing|unstable)\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | return _release_status_from_version(undef, undef, $meta); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | ▶ | sub _release_status_from_version { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_release_status_from_version: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 0 | my (undef, undef, $meta) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 0 | ▶ | my $version = $meta->{version} || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$meta->{'version'} || ''
MC/DC0%0/1
$meta->{'version'} || ''
$meta->{'version'}
Truth table0%0/2
A
A= $meta->{'version'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 0 | ▶ | return ( $version =~ /_/ ) ? 'testing' : 'stable'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 7 | my $provides_spec = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | file => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | version => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 7 | my $provides_spec_2 = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | file => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | version => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | ':custom' => \&_prefix_custom, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 7 | ▶ | sub _provides { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_provides: called CC=6 SCAR=19.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 7 | my ($element, $key, $meta, $to_version) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 7 | ▶ | return unless defined $element && ref $element eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $element and ref $element eq "HASH"
MC/DC0%0/2
defined $element and ref $element eq "HASH"
defined $element
ref $element eq "HASH"
Truth table33%1/3
A and B
A= defined $elementB= ref $element eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 7 | ▶ | my $spec = $to_version == 2 ? $provides_spec_2 : $provides_spec; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 7 | my $new_data = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 7 | for my $k ( keys %$element ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 434 | $new_data->{$k} = _convert($element->{$k}, $spec, $to_version); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | $new_data->{$k}{version} = _clean_version($element->{$k}{version}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 434 | ▶ | if exists $element->{$k}{version}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 7 | return $new_data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 504 | ▶ | sub _convert { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_convert: called CC=15 SCAR=28.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 504 | my ($data, $spec, $to_version, $is_fragment) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 504 | my $new_data = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 504 | for my $key ( keys %$spec ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 1729 | ▶ | next if $key eq ':custom' || $key eq ':drop'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$key eq ":custom" or $key eq ":drop"
MC/DC100%2/2
$key eq ":custom" or $key eq ":drop"
$key eq ":custom"
$key eq ":drop"
Truth table100%3/3
A or B
A= $key eq ":custom"B= $key eq ":drop"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 1218 | ▶ | next unless my $fcn = $spec->{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 1218 | ▶ | if ( $is_fragment && $key eq 'generated_by' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$is_fragment and $key eq "generated_by"
MC/DC0%0/2
$is_fragment and $key eq "generated_by"
$is_fragment
$key eq "generated_by"
Truth table33%1/3
A and B
A= $is_fragmentB= $key eq "generated_by"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 0 | $fcn = \&_keep; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 1218 | ▶ | die "spec for '$key' is not a coderef" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $fcn and ref $fcn eq "CODE"
MC/DC0%0/2
ref $fcn and ref $fcn eq "CODE"
ref $fcn
ref $fcn eq "CODE"
Truth table33%1/3
A and B
A= ref $fcnB= ref $fcn eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | unless ref $fcn && ref $fcn eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 1218 | my $new_value = $fcn->($data->{$key}, $key, $data, $to_version); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 1218 | ▶ | $new_data->{$key} = $new_value if defined $new_value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 504 | my $drop_list = $spec->{':drop'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 504 | ▶ | my $customizer = $spec->{':custom'} || \&_keep; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$spec->{':custom'} || \&CPAN::Meta::Converter::_keep
MC/DC0%0/1
$spec->{':custom'} || \&CPAN::Meta::Converter::_keep
$spec->{':custom'}
Truth table50%1/2
A
A= $spec->{':custom'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 504 | for my $key ( keys %$data ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 1120 | ▶ | next if $drop_list && grep { $key eq $_ } @$drop_list; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$drop_list and grep {$key eq $_;} @$drop_list
MC/DC0%0/2
$drop_list and grep {$key eq $_;} @$drop_list
$drop_list
grep {$key eq $_;} @$drop_list
Truth table66%2/3
A and B
A= $drop_listB= grep {$key eq $_;} @$drop_list
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 1120 | ▶ | next if exists $spec->{$key}; # we handled it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 42 | $new_data->{ $customizer->($key) } = $data->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 504 | return $new_data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | #--------------------------------------------------------------------------# | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | # define converters for each conversion | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | #--------------------------------------------------------------------------# | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | # each converts from prior version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | # special ":custom" field is used for keys not recognized in spec | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 7 | my %up_convert = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | '2-from-1.4' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | # PRIOR MANDATORY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 'abstract' => \&_keep_or_unknown, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 'author' => \&_author_list, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 'generated_by' => \&_generated_by, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 'license' => \&_license_2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 'meta-spec' => \&_change_meta_spec, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 'name' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 'version' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | # CHANGED TO MANDATORY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 'dynamic_config' => \&_keep_or_one, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | # ADDED MANDATORY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 'release_status' => \&_release_status, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | # PRIOR OPTIONAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 'keywords' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 'no_index' => \&_no_index_directory, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 'optional_features' => \&_upgrade_optional_features, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 'provides' => \&_provides, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 'resources' => \&_upgrade_resources_2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | # ADDED OPTIONAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 'description' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 'prereqs' => \&_prereqs_from_1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | # drop these deprecated fields, but only after we convert | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | ':drop' => [ qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | build_requires | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | configure_requires | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | conflicts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | distribution_type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | license_url | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | private | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | recommends | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | requires | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | ) ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | # other random keys need x_ prefixing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | ':custom' => \&_prefix_custom, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | '1.4-from-1.3' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | # PRIOR MANDATORY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 'abstract' => \&_keep_or_unknown, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 'author' => \&_author_list, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 'generated_by' => \&_generated_by, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 'license' => \&_license_1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 'meta-spec' => \&_change_meta_spec, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 'name' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 'version' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | # PRIOR OPTIONAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 'build_requires' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 'conflicts' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 'distribution_type' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 'dynamic_config' => \&_keep_or_one, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 'keywords' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 'no_index' => \&_no_index_directory, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 'optional_features' => \&_optional_features_1_4, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 'provides' => \&_provides, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 'recommends' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 'requires' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 'resources' => \&_resources_1_4, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | # ADDED OPTIONAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 'configure_requires' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | # drop these deprecated fields, but only after we convert | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | ':drop' => [ qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | license_url | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | private | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | # other random keys are OK if already valid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | ':custom' => \&_keep | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | '1.3-from-1.2' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | # PRIOR MANDATORY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 'abstract' => \&_keep_or_unknown, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 'author' => \&_author_list, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 'generated_by' => \&_generated_by, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | 'license' => \&_license_1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 'meta-spec' => \&_change_meta_spec, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | 'name' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 'version' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | # PRIOR OPTIONAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 'build_requires' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 'conflicts' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 'distribution_type' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 'dynamic_config' => \&_keep_or_one, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 'keywords' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 'no_index' => \&_no_index_directory, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 'optional_features' => \&_optional_features_as_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 'provides' => \&_provides, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 'recommends' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 'requires' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 'resources' => \&_resources_1_3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | # drop these deprecated fields, but only after we convert | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | ':drop' => [ qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | license_url | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | private | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | # other random keys are OK if already valid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | ':custom' => \&_keep | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | '1.2-from-1.1' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | # PRIOR MANDATORY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 'version' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | # CHANGED TO MANDATORY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 'license' => \&_license_1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 'name' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | 'generated_by' => \&_generated_by, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | # ADDED MANDATORY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 'abstract' => \&_keep_or_unknown, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 'author' => \&_author_list, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 'meta-spec' => \&_change_meta_spec, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | # PRIOR OPTIONAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 'build_requires' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 'conflicts' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 'distribution_type' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 'dynamic_config' => \&_keep_or_one, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | 'recommends' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 'requires' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | # ADDED OPTIONAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 'keywords' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 'no_index' => \&_no_index_1_2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | 'optional_features' => \&_optional_features_as_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | 'provides' => \&_provides, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 'resources' => \&_resources_1_2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | # drop these deprecated fields, but only after we convert | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | ':drop' => [ qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | license_url | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | private | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | # other random keys are OK if already valid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | ':custom' => \&_keep | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | '1.1-from-1.0' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | # CHANGED TO MANDATORY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 'version' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | # IMPLIED MANDATORY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | 'name' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | # PRIOR OPTIONAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 'build_requires' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 'conflicts' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 'distribution_type' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 'dynamic_config' => \&_keep_or_one, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 'generated_by' => \&_generated_by, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 'license' => \&_license_1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | 'recommends' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 'requires' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | # ADDED OPTIONAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 'license_url' => \&_url_or_drop, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 'private' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | # other random keys are OK if already valid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | ':custom' => \&_keep | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 7 | my %down_convert = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | '1.4-from-2' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | # MANDATORY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | 'abstract' => \&_keep_or_unknown, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | 'author' => \&_author_list, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 'generated_by' => \&_generated_by, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 'license' => \&_downgrade_license, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | 'meta-spec' => \&_change_meta_spec, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 'name' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | 'version' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | # OPTIONAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | 'build_requires' => \&_get_build_requires, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | 'configure_requires' => \&_get_configure_requires, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 'conflicts' => \&_get_conflicts, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 'distribution_type' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 'dynamic_config' => \&_keep_or_one, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 'keywords' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | 'no_index' => \&_no_index_directory, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | 'optional_features' => \&_downgrade_optional_features, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 'provides' => \&_provides, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | 'recommends' => \&_get_recommends, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | 'requires' => \&_get_requires, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | 'resources' => \&_downgrade_resources, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | # drop these unsupported fields (after conversion) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | ':drop' => [ qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | prereqs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | release_status | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | # custom keys will be left unchanged | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | ':custom' => \&_keep | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | '1.3-from-1.4' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | # MANDATORY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | 'abstract' => \&_keep_or_unknown, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | 'author' => \&_author_list, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | 'generated_by' => \&_generated_by, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | 'license' => \&_license_1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | 'meta-spec' => \&_change_meta_spec, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | 'name' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | 'version' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | # OPTIONAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | 'build_requires' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | 'conflicts' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | 'distribution_type' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | 'dynamic_config' => \&_keep_or_one, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | 'keywords' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | 'no_index' => \&_no_index_directory, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | 'optional_features' => \&_optional_features_as_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | 'provides' => \&_provides, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | 'recommends' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 'requires' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | 'resources' => \&_resources_1_3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | # drop these unsupported fields, but only after we convert | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | ':drop' => [ qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | configure_requires | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | # other random keys are OK if already valid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | ':custom' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | '1.2-from-1.3' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | # MANDATORY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | 'abstract' => \&_keep_or_unknown, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | 'author' => \&_author_list, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | 'generated_by' => \&_generated_by, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | 'license' => \&_license_1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | 'meta-spec' => \&_change_meta_spec, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | 'name' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | 'version' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | # OPTIONAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | 'build_requires' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | 'conflicts' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | 'distribution_type' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | 'dynamic_config' => \&_keep_or_one, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | 'keywords' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | 'no_index' => \&_no_index_1_2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | 'optional_features' => \&_optional_features_as_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | 'provides' => \&_provides, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | 'recommends' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | 'requires' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 'resources' => \&_resources_1_3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | # other random keys are OK if already valid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | ':custom' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | '1.1-from-1.2' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | # MANDATORY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | 'version' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | # IMPLIED MANDATORY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | 'name' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | 'meta-spec' => \&_change_meta_spec, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | # OPTIONAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | 'build_requires' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | 'conflicts' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | 'distribution_type' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | 'dynamic_config' => \&_keep_or_one, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | 'generated_by' => \&_generated_by, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | 'license' => \&_license_1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | 'private' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | 'recommends' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | 'requires' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | # drop unsupported fields | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | ':drop' => [ qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | abstract | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | author | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | provides | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | no_index | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | keywords | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | resources | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | # other random keys are OK if already valid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | ':custom' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | '1.0-from-1.1' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | # IMPLIED MANDATORY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | 'name' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | 'meta-spec' => \&_change_meta_spec, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | 'version' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | # PRIOR OPTIONAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | 'build_requires' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | 'conflicts' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | 'distribution_type' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | 'dynamic_config' => \&_keep_or_one, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | 'generated_by' => \&_generated_by, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | 'license' => \&_license_1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | 'recommends' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | 'requires' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | # other random keys are OK if already valid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | ':custom' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | 7 | my %cleanup = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | '2' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | # PRIOR MANDATORY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | 'abstract' => \&_keep_or_unknown, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | 'author' => \&_author_list, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | 'generated_by' => \&_generated_by, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | 'license' => \&_license_2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | 'meta-spec' => \&_change_meta_spec, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | 'name' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | 'version' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | # CHANGED TO MANDATORY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | 'dynamic_config' => \&_keep_or_one, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | # ADDED MANDATORY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | 'release_status' => \&_release_status, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | # PRIOR OPTIONAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | 'keywords' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | 'no_index' => \&_no_index_directory, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | 'optional_features' => \&_cleanup_optional_features_2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | 'provides' => \&_provides, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | 'resources' => \&_cleanup_resources_2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | # ADDED OPTIONAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | 'description' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | 'prereqs' => \&_cleanup_prereqs, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | # drop these deprecated fields, but only after we convert | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | ':drop' => [ qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | build_requires | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | configure_requires | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | conflicts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | distribution_type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | license_url | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | private | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | recommends | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | requires | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | ) ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | # other random keys need x_ prefixing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | ':custom' => \&_prefix_custom, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | '1.4' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | # PRIOR MANDATORY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | 'abstract' => \&_keep_or_unknown, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | 'author' => \&_author_list, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | 'generated_by' => \&_generated_by, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | 'license' => \&_license_1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | 'meta-spec' => \&_change_meta_spec, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | 'name' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | 'version' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | # PRIOR OPTIONAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | 'build_requires' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | 'conflicts' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | 'distribution_type' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | 'dynamic_config' => \&_keep_or_one, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | 'keywords' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | 'no_index' => \&_no_index_directory, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | 'optional_features' => \&_optional_features_1_4, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | 'provides' => \&_provides, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | 'recommends' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | 'requires' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | 'resources' => \&_resources_1_4, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | # ADDED OPTIONAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | 'configure_requires' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | # other random keys are OK if already valid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | ':custom' => \&_keep | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | '1.3' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | # PRIOR MANDATORY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | 'abstract' => \&_keep_or_unknown, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | 'author' => \&_author_list, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | 'generated_by' => \&_generated_by, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | 'license' => \&_license_1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | 'meta-spec' => \&_change_meta_spec, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | 'name' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | 'version' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | # PRIOR OPTIONAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | 'build_requires' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | 'conflicts' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | 'distribution_type' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | 'dynamic_config' => \&_keep_or_one, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | 'keywords' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | 'no_index' => \&_no_index_directory, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | 'optional_features' => \&_optional_features_as_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | 'provides' => \&_provides, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | 'recommends' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | 'requires' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | 'resources' => \&_resources_1_3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | # other random keys are OK if already valid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | ':custom' => \&_keep | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | '1.2' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | # PRIOR MANDATORY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | 'version' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | # CHANGED TO MANDATORY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | 'license' => \&_license_1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | 'name' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | 'generated_by' => \&_generated_by, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | # ADDED MANDATORY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | 'abstract' => \&_keep_or_unknown, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | 'author' => \&_author_list, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | 'meta-spec' => \&_change_meta_spec, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | # PRIOR OPTIONAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | 'build_requires' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | 'conflicts' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | 'distribution_type' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | 'dynamic_config' => \&_keep_or_one, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | 'recommends' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | 'requires' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | # ADDED OPTIONAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | 'keywords' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | 'no_index' => \&_no_index_1_2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | 'optional_features' => \&_optional_features_as_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | 'provides' => \&_provides, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | 'resources' => \&_resources_1_2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | # other random keys are OK if already valid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | ':custom' => \&_keep | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | '1.1' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | # CHANGED TO MANDATORY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | 'version' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | # IMPLIED MANDATORY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | 'name' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | 'meta-spec' => \&_change_meta_spec, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | # PRIOR OPTIONAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | 'build_requires' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | 'conflicts' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | 'distribution_type' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | 'dynamic_config' => \&_keep_or_one, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | 'generated_by' => \&_generated_by, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | 'license' => \&_license_1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | 'recommends' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | 'requires' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | # ADDED OPTIONAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | 'license_url' => \&_url_or_drop, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | 'private' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | # other random keys are OK if already valid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | ':custom' => \&_keep | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | '1.0' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | # IMPLIED MANDATORY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | 'name' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | 'meta-spec' => \&_change_meta_spec, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | 'version' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | # IMPLIED OPTIONAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | 'build_requires' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | 'conflicts' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | 'distribution_type' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | 'dynamic_config' => \&_keep_or_one, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | 'generated_by' => \&_generated_by, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | 'license' => \&_license_1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | 'recommends' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | 'requires' => \&_version_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | # other random keys are OK if already valid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | ':custom' => \&_keep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | # for a given field in a spec version, what fields will it feed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | # into in the *latest* spec (i.e. v2); meta-spec omitted because | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | # we always expect a meta-spec to be generated | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | 7 | my %fragments_generate = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | '2' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | 'abstract' => 'abstract', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | 'author' => 'author', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | 'generated_by' => 'generated_by', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | 'license' => 'license', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | 'name' => 'name', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | 'version' => 'version', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | 'dynamic_config' => 'dynamic_config', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | 'release_status' => 'release_status', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | 'keywords' => 'keywords', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | 'no_index' => 'no_index', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | 'optional_features' => 'optional_features', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | 'provides' => 'provides', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | 'resources' => 'resources', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | 'description' => 'description', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | 'prereqs' => 'prereqs', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | '1.4' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | 'abstract' => 'abstract', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | 'author' => 'author', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | 'generated_by' => 'generated_by', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | 'license' => 'license', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | 'name' => 'name', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | 'version' => 'version', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | 'build_requires' => 'prereqs', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | 'conflicts' => 'prereqs', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | 'distribution_type' => 'distribution_type', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | 'dynamic_config' => 'dynamic_config', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | 'keywords' => 'keywords', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | 'no_index' => 'no_index', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | 'optional_features' => 'optional_features', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | 'provides' => 'provides', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | 'recommends' => 'prereqs', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | 'requires' => 'prereqs', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | 'resources' => 'resources', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | 'configure_requires' => 'prereqs', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | # this is not quite true but will work well enough | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | # as 1.4 is a superset of earlier ones | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | 7 | $fragments_generate{$_} = $fragments_generate{'1.4'} for qw/1.3 1.2 1.1 1.0/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | #--------------------------------------------------------------------------# | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | # Code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | #--------------------------------------------------------------------------# | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | #pod =method new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | #pod my $cmc = CPAN::Meta::Converter->new( $struct ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | #pod The constructor should be passed a valid metadata structure but invalid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | #pod structures are accepted. If no meta-spec version is provided, version 1.0 will | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | #pod be assumed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | #pod Optionally, you can provide a C<default_version> argument after C<$struct>: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | #pod my $cmc = CPAN::Meta::Converter->new( $struct, default_version => "1.4" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | #pod This is only needed when converting a metadata fragment that does not include a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | #pod C<meta-spec> field. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | #pod =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | 7 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | 7 | my ($class,$data,%args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | # create an attributes hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | my $self = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | 'data' => $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | 7 | 'spec' => _extract_spec_version($data, $args{default_version}), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | # create the object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | 7 | return bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | 7 | ▶ | sub _extract_spec_version { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_extract_spec_version: called CC=13 SCAR=41.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | 7 | my ($data, $default) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | 7 | my $spec = $data->{'meta-spec'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | # is meta-spec there and valid? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | 7 | ▶ | return( $default || "1.0" ) unless defined $spec && ref $spec eq 'HASH'; # before meta-spec? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition20%1/5
defined $spec and ref $spec eq "HASH"
$default || '1.0'
MC/DC0%0/2
defined $spec and ref $spec eq "HASH"
defined $spec
ref $spec eq "HASH"
MC/DC0%0/1
$default || '1.0'
$default
Truth table33%1/3
A and B
A= defined $specB= ref $spec eq "HASH"
Truth table0%0/2
A
A= $default
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | # does the version key look like a valid version? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | 7 | my $v = $spec->{version}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | 7 | ▶ | if ( defined $v && $v =~ /^\d+(?:\.\d+)?$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $v and $v =~ /^\d+(?:\.\d+)?$/
MC/DC0%0/2
defined $v and $v =~ /^\d+(?:\.\d+)?$/
defined $v
$v =~ /^\d+(?:\.\d+)?$/
Truth table33%1/3
A and B
A= defined $vB= $v =~ /^\d+(?:\.\d+)?$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | 7 | ▶ | return $v if defined $v && grep { $v eq $_ } keys %known_specs; # known spec | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $v and grep {$v eq $_;} keys %known_specs
MC/DC0%0/2
defined $v and grep {$v eq $_;} keys %known_specs
defined $v
grep {$v eq $_;} keys %known_specs
Truth table33%1/3
A and B
A= defined $vB= grep {$v eq $_;} keys %known_specs
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | 0 | ▶ | return $v+0 if defined $v && grep { $v == $_ } keys %known_specs; # 2.0 => 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $v and grep {$v == $_;} keys %known_specs
MC/DC0%0/2
defined $v and grep {$v == $_;} keys %known_specs
defined $v
grep {$v == $_;} keys %known_specs
Truth table0%0/3
A and B
A= defined $vB= grep {$v == $_;} keys %known_specs
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | # otherwise, use heuristics: look for 1.x vs 2.0 fields | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | 0 | ▶ | return "2" if exists $data->{prereqs}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | 0 | ▶ | return "1.4" if exists $data->{configure_requires}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | 0 | ▶ | return( $default || "1.2" ); # when meta-spec was first defined | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$default || '1.2'
MC/DC0%0/1
$default || '1.2'
$default
Truth table0%0/2
A
A= $default
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | #pod =method convert | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | #pod my $new_struct = $cmc->convert( version => "2" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | #pod Returns a new hash reference with the metadata converted to a different form. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | #pod C<convert> will die if any conversion/standardization still results in an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | #pod invalid structure. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | #pod Valid parameters include: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | #pod =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | #pod =item * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | #pod C<version> -- Indicates the desired specification version (e.g. "1.0", "1.1" ... "1.4", "2"). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | #pod Defaults to the latest version of the CPAN Meta Spec. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | #pod =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | #pod Conversion proceeds through each version in turn. For example, a version 1.2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | #pod structure might be converted to 1.3 then 1.4 then finally to version 2. The | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | #pod conversion process attempts to clean-up simple errors and standardize data. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | #pod For example, if C<author> is given as a scalar, it will converted to an array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | #pod reference containing the item. (Converting a structure to its own version will | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | #pod also clean-up and standardize.) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | #pod When data are cleaned and standardized, missing or invalid fields will be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | #pod replaced with sensible defaults when possible. This may be lossy or imprecise. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | #pod For example, some badly structured META.yml files on CPAN have prerequisite | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | #pod modules listed as both keys and values: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | #pod requires => { 'Foo::Bar' => 'Bam::Baz' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | #pod These would be split and each converted to a prerequisite with a minimum | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | #pod version of zero. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | #pod When some mandatory fields are missing or invalid, the conversion will attempt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | #pod to provide a sensible default or will fill them with a value of 'unknown'. For | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | #pod example a missing or unrecognized C<license> field will result in a C<license> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | #pod field of 'unknown'. Fields that may get an 'unknown' include: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | #pod =for :list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | #pod * abstract | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | #pod * author | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | #pod * license | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | #pod =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | 7 | ▶ | sub convert { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
convert: called CC=16 SCAR=48.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | 7 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | 7 | my $args = { %args }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | 7 | ▶ | my $new_version = $args->{version} || $HIGHEST; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$args->{'version'} || $HIGHEST
MC/DC0%0/2
$args->{'version'} || $HIGHEST
$args->{'version'}
$HIGHEST
Truth table33%1/3
A || B
A= $args->{'version'}B= $HIGHEST
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | 7 | my $is_fragment = $args->{is_fragment}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | 7 | my ($old_version) = $self->{spec}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | 7 | my $converted = _dclone($self->{data}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | 7 | ▶ | if ( $old_version == $new_version ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | 7 | $converted = _convert( $converted, $cleanup{$old_version}, $old_version, $is_fragment ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | 7 | ▶ | unless ( $args->{is_fragment} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | 7 | my $cmv = CPAN::Meta::Validator->new( $converted ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | 7 | ▶ | unless ( $cmv->is_valid ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | 0 | my $errs = join("\n", $cmv->errors); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | 0 | die "Failed to clean-up $old_version metadata. Errors:\n$errs\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | 7 | return $converted; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | elsif ( $old_version > $new_version ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | 0 | my @vers = sort { $b <=> $a } keys %known_specs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | 0 | for my $i ( 0 .. $#vers-1 ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | 0 | ▶ | next if $vers[$i] > $old_version; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | 0 | ▶ | last if $vers[$i+1] < $new_version; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | 0 | my $spec_string = "$vers[$i+1]-from-$vers[$i]"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | 0 | $converted = _convert( $converted, $down_convert{$spec_string}, $vers[$i+1], $is_fragment ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | 0 | ▶ | unless ( $args->{is_fragment} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | 0 | my $cmv = CPAN::Meta::Validator->new( $converted ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | 0 | ▶ | unless ( $cmv->is_valid ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | 0 | my $errs = join("\n", $cmv->errors); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | 0 | die "Failed to downconvert metadata to $vers[$i+1]. Errors:\n$errs\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | 0 | return $converted; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | 0 | my @vers = sort { $a <=> $b } keys %known_specs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | 0 | for my $i ( 0 .. $#vers-1 ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | 0 | ▶ | next if $vers[$i] < $old_version; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | 0 | ▶ | last if $vers[$i+1] > $new_version; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | 0 | my $spec_string = "$vers[$i+1]-from-$vers[$i]"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | 0 | $converted = _convert( $converted, $up_convert{$spec_string}, $vers[$i+1], $is_fragment ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | 0 | ▶ | unless ( $args->{is_fragment} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | 0 | my $cmv = CPAN::Meta::Validator->new( $converted ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | 0 | ▶ | unless ( $cmv->is_valid ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | 0 | my $errs = join("\n", $cmv->errors); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | 0 | die "Failed to upconvert metadata to $vers[$i+1]. Errors:\n$errs\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | 0 | return $converted; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | #pod =method upgrade_fragment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | #pod my $new_struct = $cmc->upgrade_fragment; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | #pod Returns a new hash reference with the metadata converted to the latest version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | #pod of the CPAN Meta Spec. No validation is done on the result -- you must | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | #pod validate after merging fragments into a complete metadata document. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | #pod Available since version 2.141170. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | #pod =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | 0 | ▶ | sub upgrade_fragment { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
upgrade_fragment: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | 0 | my ($old_version) = $self->{spec}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | my %expected = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | 0 | map {; $_ => 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | 0 | grep { defined } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | 0 | map { $fragments_generate{$old_version}{$_} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | 0 | keys %{ $self->{data} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | 0 | my $converted = $self->convert( version => $HIGHEST, is_fragment => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | 0 | for my $key ( keys %$converted ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | 0 | ▶ | next if $key =~ /^x_/i || $key eq 'meta-spec'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$key =~ /^x_/i or $key eq "meta-spec"
MC/DC0%0/2
$key =~ /^x_/i or $key eq "meta-spec"
$key =~ /^x_/i
$key eq "meta-spec"
Truth table0%0/3
A or B
A= $key =~ /^x_/iB= $key eq "meta-spec"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | 0 | ▶ | delete $converted->{$key} unless $expected{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | 0 | return $converted; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | 7 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | # ABSTRACT: Convert CPAN distribution metadata structures | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | =encoding UTF-8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1511 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1512 | CPAN::Meta::Converter - Convert CPAN distribution metadata structures | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1516 | version 2.150013 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1517 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1518 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | my $struct = decode_json_file('META.json'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1522 | my $cmc = CPAN::Meta::Converter->new( $struct ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1523 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1524 | my $new_struct = $cmc->convert( version => "2" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1525 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1526 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1527 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1528 | This module converts CPAN Meta structures from one form to another. The | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1529 | primary use is to convert older structures to the most modern version of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1530 | the specification, but other transformations may be implemented in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1531 | future as needed. (E.g. stripping all custom fields or stripping all | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1532 | optional fields.) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1533 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1534 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1535 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1536 | =head2 new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1537 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1538 | my $cmc = CPAN::Meta::Converter->new( $struct ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1539 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1540 | The constructor should be passed a valid metadata structure but invalid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1541 | structures are accepted. If no meta-spec version is provided, version 1.0 will | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1542 | be assumed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1543 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1544 | Optionally, you can provide a C<default_version> argument after C<$struct>: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1545 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1546 | my $cmc = CPAN::Meta::Converter->new( $struct, default_version => "1.4" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1547 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1548 | This is only needed when converting a metadata fragment that does not include a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1549 | C<meta-spec> field. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1550 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1551 | =head2 convert | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1552 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1553 | my $new_struct = $cmc->convert( version => "2" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1554 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1555 | Returns a new hash reference with the metadata converted to a different form. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1556 | C<convert> will die if any conversion/standardization still results in an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1557 | invalid structure. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1559 | Valid parameters include: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1560 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1561 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1562 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1563 | =item * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1564 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1565 | C<version> -- Indicates the desired specification version (e.g. "1.0", "1.1" ... "1.4", "2"). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1566 | Defaults to the latest version of the CPAN Meta Spec. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1567 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1568 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1569 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1570 | Conversion proceeds through each version in turn. For example, a version 1.2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1571 | structure might be converted to 1.3 then 1.4 then finally to version 2. The | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1572 | conversion process attempts to clean-up simple errors and standardize data. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1573 | For example, if C<author> is given as a scalar, it will converted to an array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1574 | reference containing the item. (Converting a structure to its own version will | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1575 | also clean-up and standardize.) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1576 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1577 | When data are cleaned and standardized, missing or invalid fields will be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1578 | replaced with sensible defaults when possible. This may be lossy or imprecise. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1579 | For example, some badly structured META.yml files on CPAN have prerequisite | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1580 | modules listed as both keys and values: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1581 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1582 | requires => { 'Foo::Bar' => 'Bam::Baz' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1583 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1584 | These would be split and each converted to a prerequisite with a minimum | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1585 | version of zero. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1586 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1587 | When some mandatory fields are missing or invalid, the conversion will attempt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1588 | to provide a sensible default or will fill them with a value of 'unknown'. For | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1589 | example a missing or unrecognized C<license> field will result in a C<license> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1590 | field of 'unknown'. Fields that may get an 'unknown' include: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1591 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1592 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1593 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1594 | =item * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1595 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1596 | abstract | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1597 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1598 | =item * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1600 | author | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1601 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1602 | =item * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1603 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1604 | license | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1605 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1606 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1607 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1608 | =head2 upgrade_fragment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1609 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1610 | my $new_struct = $cmc->upgrade_fragment; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1611 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1612 | Returns a new hash reference with the metadata converted to the latest version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1613 | of the CPAN Meta Spec. No validation is done on the result -- you must | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1614 | validate after merging fragments into a complete metadata document. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1615 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1616 | Available since version 2.141170. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1617 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1618 | =head1 BUGS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1619 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1620 | Please report any bugs or feature using the CPAN Request Tracker. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1621 | Bugs can be submitted through the web interface at | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1622 | L<http://rt.cpan.org/Dist/Display.html?Queue=CPAN-Meta> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1623 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1624 | When submitting a bug or request, please include a test-file or a patch to an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1625 | existing test-file that illustrates the bug or desired feature. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1626 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1627 | =head1 AUTHORS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1628 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1629 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1630 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1631 | =item * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1632 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1633 | David Golden <dagolden@cpan.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1634 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1635 | =item * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1636 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1637 | Ricardo Signes <cpan@semiotic.systems> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1638 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1639 | =item * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1640 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1641 | Adam Kennedy <adamk@cpan.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1642 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1643 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1644 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1645 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1646 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1647 | This software is copyright (c) 2010 by David Golden, Ricardo Signes, Adam Kennedy and Contributors. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1648 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1649 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1650 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1651 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1652 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1653 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1654 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||