| Filename | C:/tmp64ng/perl/lib/CPAN/Meta.pm | 
| Statements | Executed 584 statements in 15.6ms | 
| Calls | P | F | Exclusive Time  | 
        Inclusive Time  | 
        Subroutine | 
|---|---|---|---|---|---|
| 1 | 1 | 1 | 31.2ms | 31.2ms | CPAN::Meta::BEGIN@58 | 
| 1 | 1 | 1 | 0s | 0s | CPAN::Meta::BEGIN@113 | 
| 1 | 1 | 1 | 0s | 0s | CPAN::Meta::BEGIN@120 | 
| 1 | 1 | 1 | 0s | 0s | CPAN::Meta::BEGIN@150 | 
| 1 | 1 | 1 | 0s | 0s | CPAN::Meta::BEGIN@161 | 
| 1 | 1 | 1 | 0s | 0s | CPAN::Meta::BEGIN@55 | 
| 1 | 1 | 1 | 0s | 0s | CPAN::Meta::BEGIN@56 | 
| 1 | 1 | 1 | 0s | 0s | CPAN::Meta::BEGIN@57 | 
| 1 | 1 | 1 | 0s | 0s | CPAN::Meta::BEGIN@59 | 
| 1 | 1 | 1 | 0s | 0s | CPAN::Meta::BEGIN@60 | 
| 1 | 1 | 1 | 0s | 0s | CPAN::Meta::BEGIN@616 | 
| 1 | 1 | 1 | 0s | 0s | CPAN::Meta::BEGIN@62 | 
| 1 | 1 | 1 | 0s | 0s | CPAN::Meta::BEGIN@81 | 
| 1 | 1 | 1 | 0s | 0s | CPAN::Meta::BEGIN@92 | 
| 6 | 1 | 1 | 0s | 0s | CPAN::Meta::CORE:close (opcode) | 
| 1 | 1 | 1 | 0s | 0s | CPAN::Meta::CORE:fteread (opcode) | 
| 6 | 2 | 1 | 0s | 0s | CPAN::Meta::CORE:match (opcode) | 
| 6 | 1 | 1 | 0s | 0s | CPAN::Meta::CORE:open (opcode) | 
| 6 | 1 | 1 | 0s | 0s | CPAN::Meta::CORE:print (opcode) | 
| 6 | 1 | 1 | 0s | 0s | CPAN::Meta::CORE:subst (opcode) | 
| 19 | 1 | 1 | 0s | 0s | CPAN::Meta::TO_JSON | 
| 0 | 0 | 0 | 0s | 0s | CPAN::Meta::__ANON__[:128] | 
| 18 | 1 | 1 | 0s | 0s | CPAN::Meta::__ANON__[:168] | 
| 0 | 0 | 0 | 0s | 0s | CPAN::Meta::__ANON__[:94] | 
| 7 | 3 | 1 | 0s | 109ms | CPAN::Meta::_new | 
| 18 | 5 | 2 | 0s | 140ms | CPAN::Meta::as_string | 
| 19 | 3 | 2 | 0s | 62.4ms | CPAN::Meta::as_struct | 
| 0 | 0 | 0 | 0s | 0s | CPAN::Meta::authors | 
| 3 | 1 | 1 | 0s | 46.8ms | CPAN::Meta::create | 
| 0 | 0 | 0 | 0s | 0s | CPAN::Meta::custom | 
| 0 | 0 | 0 | 0s | 0s | CPAN::Meta::custom_keys | 
| 0 | 0 | 0 | 0s | 0s | CPAN::Meta::effective_prereqs | 
| 0 | 0 | 0 | 0s | 0s | CPAN::Meta::feature | 
| 0 | 0 | 0 | 0s | 0s | CPAN::Meta::features | 
| 0 | 0 | 0 | 0s | 0s | CPAN::Meta::licenses | 
| 1 | 1 | 1 | 0s | 15.6ms | CPAN::Meta::load_file | 
| 0 | 0 | 0 | 0s | 0s | CPAN::Meta::load_json_string | 
| 0 | 0 | 0 | 0s | 0s | CPAN::Meta::load_string | 
| 0 | 0 | 0 | 0s | 0s | CPAN::Meta::load_yaml_string | 
| 18 | 1 | 1 | 0s | 0s | CPAN::Meta::meta_spec_version | 
| 3 | 1 | 1 | 0s | 46.8ms | CPAN::Meta::new | 
| 6 | 2 | 1 | 0s | 62.4ms | CPAN::Meta::save | 
| 0 | 0 | 0 | 0s | 0s | CPAN::Meta::should_index_file | 
| 0 | 0 | 0 | 0s | 0s | CPAN::Meta::should_index_package | 
| 1 | 1 | 1 | 0s | 0s | ExtUtils::MM_Any::BEGIN@1 | 
| 1 | 1 | 1 | 0s | 0s | ExtUtils::MM_Any::BEGIN@2 | 
| 1 | 1 | 1 | 0s | 0s | ExtUtils::MM_Any::BEGIN@3.3 | 
| Line | State ments  | 
      Time on line  | 
      Calls | Time in subs  | 
      Code | 
|---|---|---|---|---|---|
| 1 | 2 | 0s | 1 | 0s | # spent 0s within ExtUtils::MM_Any::BEGIN@1 which was called:
#    once (0s+0s) by ExtUtils::MM_Any::_has_cpan_meta at line 1 # spent     0s making 1 call to ExtUtils::MM_Any::BEGIN@1  | 
| 2 | 2 | 0s | 2 | 0s | # spent 0s within ExtUtils::MM_Any::BEGIN@2 which was called:
#    once (0s+0s) by ExtUtils::MM_Any::_has_cpan_meta at line 2 # spent     0s making 1 call to ExtUtils::MM_Any::BEGIN@2
# spent     0s making 1 call to strict::import  | 
| 3 | 2 | 0s | 2 | 0s | # spent 0s within ExtUtils::MM_Any::BEGIN@3.3 which was called:
#    once (0s+0s) by ExtUtils::MM_Any::_has_cpan_meta at line 3 # spent     0s making 1 call to ExtUtils::MM_Any::BEGIN@3.3
# spent     0s making 1 call to warnings::import  | 
| 4 | package CPAN::Meta; | ||||
| 5 | # VERSION | ||||
| 6 | 1 | 0s | $CPAN::Meta::VERSION = '2.143240'; | ||
| 7 | #pod =head1 SYNOPSIS | ||||
| 8 | #pod | ||||
| 9 | #pod use v5.10; | ||||
| 10 | #pod use strict; | ||||
| 11 | #pod use warnings; | ||||
| 12 | #pod use CPAN::Meta; | ||||
| 13 | #pod use Module::Load; | ||||
| 14 | #pod | ||||
| 15 | #pod my $meta = CPAN::Meta->load_file('META.json'); | ||||
| 16 | #pod | ||||
| 17 | #pod printf "testing requirements for %s version %s\n", | ||||
| 18 | #pod $meta->name, | ||||
| 19 | #pod $meta->version; | ||||
| 20 | #pod | ||||
| 21 | #pod my $prereqs = $meta->effective_prereqs; | ||||
| 22 | #pod | ||||
| 23 | #pod for my $phase ( qw/configure runtime build test/ ) { | ||||
| 24 | #pod say "Requirements for $phase:"; | ||||
| 25 | #pod my $reqs = $prereqs->requirements_for($phase, "requires"); | ||||
| 26 | #pod for my $module ( sort $reqs->required_modules ) { | ||||
| 27 | #pod my $status; | ||||
| 28 | #pod if ( eval { load $module unless $module eq 'perl'; 1 } ) { | ||||
| 29 | #pod my $version = $module eq 'perl' ? $] : $module->VERSION; | ||||
| 30 | #pod $status = $reqs->accepts_module($module, $version) | ||||
| 31 | #pod ? "$version ok" : "$version not ok"; | ||||
| 32 | #pod } else { | ||||
| 33 | #pod $status = "missing" | ||||
| 34 | #pod }; | ||||
| 35 | #pod say " $module ($status)"; | ||||
| 36 | #pod } | ||||
| 37 | #pod } | ||||
| 38 | #pod | ||||
| 39 | #pod =head1 DESCRIPTION | ||||
| 40 | #pod | ||||
| 41 | #pod Software distributions released to the CPAN include a F<META.json> or, for | ||||
| 42 | #pod older distributions, F<META.yml>, which describes the distribution, its | ||||
| 43 | #pod contents, and the requirements for building and installing the distribution. | ||||
| 44 | #pod The data structure stored in the F<META.json> file is described in | ||||
| 45 | #pod L<CPAN::Meta::Spec>. | ||||
| 46 | #pod | ||||
| 47 | #pod CPAN::Meta provides a simple class to represent this distribution metadata (or | ||||
| 48 | #pod I<distmeta>), along with some helpful methods for interrogating that data. | ||||
| 49 | #pod | ||||
| 50 | #pod The documentation below is only for the methods of the CPAN::Meta object. For | ||||
| 51 | #pod information on the meaning of individual fields, consult the spec. | ||||
| 52 | #pod | ||||
| 53 | #pod =cut | ||||
| 54 | |||||
| 55 | 2 | 0s | 2 | 0s | # spent 0s within CPAN::Meta::BEGIN@55 which was called:
#    once (0s+0s) by ExtUtils::MM_Any::_has_cpan_meta at line 55 # spent     0s making 1 call to CPAN::Meta::BEGIN@55
# spent     0s making 1 call to Exporter::import  | 
| 56 | 2 | 0s | 1 | 0s | # spent 0s within CPAN::Meta::BEGIN@56 which was called:
#    once (0s+0s) by ExtUtils::MM_Any::_has_cpan_meta at line 56 # spent     0s making 1 call to CPAN::Meta::BEGIN@56  | 
| 57 | 2 | 0s | 1 | 0s | # spent 0s within CPAN::Meta::BEGIN@57 which was called:
#    once (0s+0s) by ExtUtils::MM_Any::_has_cpan_meta at line 57 # spent     0s making 1 call to CPAN::Meta::BEGIN@57  | 
| 58 | 2 | 15.6ms | 1 | 31.2ms | # spent 31.2ms within CPAN::Meta::BEGIN@58 which was called:
#    once (31.2ms+0s) by ExtUtils::MM_Any::_has_cpan_meta at line 58 # spent  31.2ms making 1 call to CPAN::Meta::BEGIN@58  | 
| 59 | 2 | 0s | 1 | 0s | # spent 0s within CPAN::Meta::BEGIN@59 which was called:
#    once (0s+0s) by ExtUtils::MM_Any::_has_cpan_meta at line 59 # spent     0s making 1 call to CPAN::Meta::BEGIN@59  | 
| 60 | 3 | 0s | 2 | 0s | # spent 0s within CPAN::Meta::BEGIN@60 which was called:
#    once (0s+0s) by ExtUtils::MM_Any::_has_cpan_meta at line 60 # spent     0s making 1 call to CPAN::Meta::BEGIN@60
# spent     0s making 1 call to version::vxs::_VERSION  | 
| 61 | |||||
| 62 | 1 | 0s | 1 | 0s | # spent 0s within CPAN::Meta::BEGIN@62 which was called:
#    once (0s+0s) by ExtUtils::MM_Any::_has_cpan_meta at line 62 # spent     0s making 1 call to CPAN::Meta::BEGIN@62  | 
| 63 | |||||
| 64 | #pod =head1 STRING DATA | ||||
| 65 | #pod | ||||
| 66 | #pod The following methods return a single value, which is the value for the | ||||
| 67 | #pod corresponding entry in the distmeta structure. Values should be either undef | ||||
| 68 | #pod or strings. | ||||
| 69 | #pod | ||||
| 70 | #pod =for :list | ||||
| 71 | #pod * abstract | ||||
| 72 | #pod * description | ||||
| 73 | #pod * dynamic_config | ||||
| 74 | #pod * generated_by | ||||
| 75 | #pod * name | ||||
| 76 | #pod * release_status | ||||
| 77 | #pod * version | ||||
| 78 | #pod | ||||
| 79 | #pod =cut | ||||
| 80 | |||||
| 81 | # spent 0s within CPAN::Meta::BEGIN@81 which was called:
#    once (0s+0s) by ExtUtils::MM_Any::_has_cpan_meta at line 96  | ||||
| 82 | 1 | 0s | my @STRING_READERS = qw( | ||
| 83 | abstract | ||||
| 84 | description | ||||
| 85 | dynamic_config | ||||
| 86 | generated_by | ||||
| 87 | name | ||||
| 88 | release_status | ||||
| 89 | version | ||||
| 90 | ); | ||||
| 91 | |||||
| 92 | 2 | 0s | 2 | 0s | # spent 0s within CPAN::Meta::BEGIN@92 which was called:
#    once (0s+0s) by ExtUtils::MM_Any::_has_cpan_meta at line 92   # spent     0s making 1 call to CPAN::Meta::BEGIN@92
  # spent     0s making 1 call to strict::unimport  | 
| 93 | 1 | 0s | for my $attr (@STRING_READERS) { | ||
| 94 | 7 | 0s | *$attr = sub { $_[0]{ $attr } }; | ||
| 95 | } | ||||
| 96 | 1 | 0s | 1 | 0s | } # spent     0s making 1 call to CPAN::Meta::BEGIN@81  | 
| 97 | |||||
| 98 | #pod =head1 LIST DATA | ||||
| 99 | #pod | ||||
| 100 | #pod These methods return lists of string values, which might be represented in the | ||||
| 101 | #pod distmeta structure as arrayrefs or scalars: | ||||
| 102 | #pod | ||||
| 103 | #pod =for :list | ||||
| 104 | #pod * authors | ||||
| 105 | #pod * keywords | ||||
| 106 | #pod * licenses | ||||
| 107 | #pod | ||||
| 108 | #pod The C<authors> and C<licenses> methods may also be called as C<author> and | ||||
| 109 | #pod C<license>, respectively, to match the field name in the distmeta structure. | ||||
| 110 | #pod | ||||
| 111 | #pod =cut | ||||
| 112 | |||||
| 113 | # spent 0s within CPAN::Meta::BEGIN@113 which was called:
#    once (0s+0s) by ExtUtils::MM_Any::_has_cpan_meta at line 130  | ||||
| 114 | 1 | 0s | my @LIST_READERS = qw( | ||
| 115 | author | ||||
| 116 | keywords | ||||
| 117 | license | ||||
| 118 | ); | ||||
| 119 | |||||
| 120 | 2 | 0s | 2 | 0s | # spent 0s within CPAN::Meta::BEGIN@120 which was called:
#    once (0s+0s) by ExtUtils::MM_Any::_has_cpan_meta at line 120   # spent     0s making 1 call to CPAN::Meta::BEGIN@120
  # spent     0s making 1 call to strict::unimport  | 
| 121 | 1 | 0s | for my $attr (@LIST_READERS) { | ||
| 122 | *$attr = sub { | ||||
| 123 | my $value = $_[0]{ $attr }; | ||||
| 124 | croak "$attr must be called in list context" | ||||
| 125 | unless wantarray; | ||||
| 126 | return @{ _dclone($value) } if ref $value; | ||||
| 127 | return $value; | ||||
| 128 | 3 | 0s | }; | ||
| 129 | } | ||||
| 130 | 1 | 0s | 1 | 0s | } # spent     0s making 1 call to CPAN::Meta::BEGIN@113  | 
| 131 | |||||
| 132 | sub authors { $_[0]->author } | ||||
| 133 | sub licenses { $_[0]->license } | ||||
| 134 | |||||
| 135 | #pod =head1 MAP DATA | ||||
| 136 | #pod | ||||
| 137 | #pod These readers return hashrefs of arbitrary unblessed data structures, each | ||||
| 138 | #pod described more fully in the specification: | ||||
| 139 | #pod | ||||
| 140 | #pod =for :list | ||||
| 141 | #pod * meta_spec | ||||
| 142 | #pod * resources | ||||
| 143 | #pod * provides | ||||
| 144 | #pod * no_index | ||||
| 145 | #pod * prereqs | ||||
| 146 | #pod * optional_features | ||||
| 147 | #pod | ||||
| 148 | #pod =cut | ||||
| 149 | |||||
| 150 | # spent 0s within CPAN::Meta::BEGIN@150 which was called:
#    once (0s+0s) by ExtUtils::MM_Any::_has_cpan_meta at line 170  | ||||
| 151 | 1 | 0s | my @MAP_READERS = qw( | ||
| 152 | meta-spec | ||||
| 153 | resources | ||||
| 154 | provides | ||||
| 155 | no_index | ||||
| 156 | |||||
| 157 | prereqs | ||||
| 158 | optional_features | ||||
| 159 | ); | ||||
| 160 | |||||
| 161 | 2 | 0s | 2 | 0s | # spent 0s within CPAN::Meta::BEGIN@161 which was called:
#    once (0s+0s) by ExtUtils::MM_Any::_has_cpan_meta at line 161   # spent     0s making 1 call to CPAN::Meta::BEGIN@161
  # spent     0s making 1 call to strict::unimport  | 
| 162 | 1 | 0s | for my $attr (@MAP_READERS) { | ||
| 163 | 6 | 0s | 6 | 0s |     (my $subname = $attr) =~ s/-/_/;     # spent     0s making 6 calls to CPAN::Meta::CORE:subst, avg 0s/call  | 
| 164 | # spent 0s within CPAN::Meta::__ANON__[C:/tmp64ng/perl/lib/CPAN/Meta.pm:168] which was called 18 times, avg 0s/call:
# 18 times (0s+0s) by CPAN::Meta::meta_spec_version at line 433, avg 0s/call  | ||||
| 165 | 18 | 0s | my $value = $_[0]{ $attr }; | ||
| 166 | 18 | 0s | 18 | 0s |       return _dclone($value) if $value;       # spent     0s making 18 calls to CPAN::Meta::Converter::_dclone, avg 0s/call  | 
| 167 | return {}; | ||||
| 168 | 6 | 0s | }; | ||
| 169 | } | ||||
| 170 | 1 | 0s | 1 | 0s | } # spent     0s making 1 call to CPAN::Meta::BEGIN@150  | 
| 171 | |||||
| 172 | #pod =head1 CUSTOM DATA | ||||
| 173 | #pod | ||||
| 174 | #pod A list of custom keys are available from the C<custom_keys> method and | ||||
| 175 | #pod particular keys may be retrieved with the C<custom> method. | ||||
| 176 | #pod | ||||
| 177 | #pod say $meta->custom($_) for $meta->custom_keys; | ||||
| 178 | #pod | ||||
| 179 | #pod If a custom key refers to a data structure, a deep clone is returned. | ||||
| 180 | #pod | ||||
| 181 | #pod =cut | ||||
| 182 | |||||
| 183 | sub custom_keys { | ||||
| 184 | return grep { /^x_/i } keys %{$_[0]}; | ||||
| 185 | } | ||||
| 186 | |||||
| 187 | sub custom { | ||||
| 188 | my ($self, $attr) = @_; | ||||
| 189 | my $value = $self->{$attr}; | ||||
| 190 | return _dclone($value) if ref $value; | ||||
| 191 | return $value; | ||||
| 192 | } | ||||
| 193 | |||||
| 194 | #pod =method new | ||||
| 195 | #pod | ||||
| 196 | #pod my $meta = CPAN::Meta->new($distmeta_struct, \%options); | ||||
| 197 | #pod | ||||
| 198 | #pod Returns a valid CPAN::Meta object or dies if the supplied metadata hash | ||||
| 199 | #pod reference fails to validate. Older-format metadata will be up-converted to | ||||
| 200 | #pod version 2 if they validate against the original stated specification. | ||||
| 201 | #pod | ||||
| 202 | #pod It takes an optional hashref of options. Valid options include: | ||||
| 203 | #pod | ||||
| 204 | #pod =over | ||||
| 205 | #pod | ||||
| 206 | #pod =item * | ||||
| 207 | #pod | ||||
| 208 | #pod lazy_validation -- if true, new will attempt to convert the given metadata | ||||
| 209 | #pod to version 2 before attempting to validate it. This means than any | ||||
| 210 | #pod fixable errors will be handled by CPAN::Meta::Converter before validation. | ||||
| 211 | #pod (Note that this might result in invalid optional data being silently | ||||
| 212 | #pod dropped.) The default is false. | ||||
| 213 | #pod | ||||
| 214 | #pod =back | ||||
| 215 | #pod | ||||
| 216 | #pod =cut | ||||
| 217 | |||||
| 218 | sub _new { | ||||
| 219 | 7 | 0s | my ($class, $struct, $options) = @_; | ||
| 220 | 7 | 0s | my $self; | ||
| 221 | |||||
| 222 | 7 | 0s | if ( $options->{lazy_validation} ) { | ||
| 223 | # try to convert to a valid structure; if succeeds, then return it | ||||
| 224 | 7 | 0s | 7 | 0s |     my $cmc = CPAN::Meta::Converter->new( $struct );     # spent     0s making 7 calls to CPAN::Meta::Converter::new, avg 0s/call  | 
| 225 | 7 | 0s | 7 | 109ms |     $self = $cmc->convert( version => 2 ); # valid or dies     # spent   109ms making 7 calls to CPAN::Meta::Converter::convert, avg 15.6ms/call  | 
| 226 | 7 | 0s | return bless $self, $class; | ||
| 227 | } | ||||
| 228 | else { | ||||
| 229 | # validate original struct | ||||
| 230 | my $cmv = CPAN::Meta::Validator->new( $struct ); | ||||
| 231 | unless ( $cmv->is_valid) { | ||||
| 232 | die "Invalid metadata structure. Errors: " | ||||
| 233 | . join(", ", $cmv->errors) . "\n"; | ||||
| 234 | } | ||||
| 235 | } | ||||
| 236 | |||||
| 237 | # up-convert older spec versions | ||||
| 238 | my $version = $struct->{'meta-spec'}{version} || '1.0'; | ||||
| 239 | if ( $version == 2 ) { | ||||
| 240 | $self = $struct; | ||||
| 241 | } | ||||
| 242 | else { | ||||
| 243 | my $cmc = CPAN::Meta::Converter->new( $struct ); | ||||
| 244 | $self = $cmc->convert( version => 2 ); | ||||
| 245 | } | ||||
| 246 | |||||
| 247 | return bless $self, $class; | ||||
| 248 | } | ||||
| 249 | |||||
| 250 | # spent 46.8ms (0s+46.8) within CPAN::Meta::new which was called 3 times, avg 15.6ms/call:
# 3 times (0s+46.8ms) by ExtUtils::MM_Any::write_mymeta at line 1529 of ExtUtils/MM_Any.pm, avg 15.6ms/call  | ||||
| 251 | 3 | 0s | my ($class, $struct, $options) = @_; | ||
| 252 | 6 | 0s | 3 | 46.8ms |   my $self = eval { $class->_new($struct, $options) };   # spent  46.8ms making 3 calls to CPAN::Meta::_new, avg 15.6ms/call  | 
| 253 | 3 | 0s | croak($@) if $@; | ||
| 254 | 3 | 0s | return $self; | ||
| 255 | } | ||||
| 256 | |||||
| 257 | #pod =method create | ||||
| 258 | #pod | ||||
| 259 | #pod my $meta = CPAN::Meta->create($distmeta_struct, \%options); | ||||
| 260 | #pod | ||||
| 261 | #pod This is same as C<new()>, except that C<generated_by> and C<meta-spec> fields | ||||
| 262 | #pod will be generated if not provided. This means the metadata structure is | ||||
| 263 | #pod assumed to otherwise follow the latest L<CPAN::Meta::Spec>. | ||||
| 264 | #pod | ||||
| 265 | #pod =cut | ||||
| 266 | |||||
| 267 | # spent 46.8ms (0s+46.8) within CPAN::Meta::create which was called 3 times, avg 15.6ms/call:
# 3 times (0s+46.8ms) by ExtUtils::MM_Any::metafile_target at line 969 of ExtUtils/MM_Any.pm, avg 15.6ms/call  | ||||
| 268 | 3 | 0s | my ($class, $struct, $options) = @_; | ||
| 269 | 3 | 0s | 3 | 0s |   my $version = __PACKAGE__->VERSION || 2;   # spent     0s making 3 calls to version::vxs::_VERSION, avg 0s/call  | 
| 270 | 3 | 0s | $struct->{generated_by} ||= __PACKAGE__ . " version $version" ; | ||
| 271 | 3 | 0s | $struct->{'meta-spec'}{version} ||= int($version); | ||
| 272 | 6 | 0s | 3 | 46.8ms |   my $self = eval { $class->_new($struct, $options) };   # spent  46.8ms making 3 calls to CPAN::Meta::_new, avg 15.6ms/call  | 
| 273 | 3 | 0s | croak ($@) if $@; | ||
| 274 | 3 | 0s | return $self; | ||
| 275 | } | ||||
| 276 | |||||
| 277 | #pod =method load_file | ||||
| 278 | #pod | ||||
| 279 | #pod my $meta = CPAN::Meta->load_file($distmeta_file, \%options); | ||||
| 280 | #pod | ||||
| 281 | #pod Given a pathname to a file containing metadata, this deserializes the file | ||||
| 282 | #pod according to its file suffix and constructs a new C<CPAN::Meta> object, just | ||||
| 283 | #pod like C<new()>. It will die if the deserialized version fails to validate | ||||
| 284 | #pod against its stated specification version. | ||||
| 285 | #pod | ||||
| 286 | #pod It takes the same options as C<new()> but C<lazy_validation> defaults to | ||||
| 287 | #pod true. | ||||
| 288 | #pod | ||||
| 289 | #pod =cut | ||||
| 290 | |||||
| 291 | # spent 15.6ms (0s+15.6) within CPAN::Meta::load_file which was called:
#    once (0s+15.6ms) by ExtUtils::MM_Any::_mymeta_from_meta at line 1490 of ExtUtils/MM_Any.pm  | ||||
| 292 | 1 | 0s | my ($class, $file, $options) = @_; | ||
| 293 | 1 | 0s | $options->{lazy_validation} = 1 unless exists $options->{lazy_validation}; | ||
| 294 | |||||
| 295 | 1 | 0s | 1 | 0s |   croak "load_file() requires a valid, readable filename"   # spent     0s making 1 call to CPAN::Meta::CORE:fteread  | 
| 296 | unless -r $file; | ||||
| 297 | |||||
| 298 | 1 | 0s | my $self; | ||
| 299 | 1 | 0s | eval { | ||
| 300 | 1 | 0s | 1 | 0s |     my $struct = Parse::CPAN::Meta->load_file( $file );     # spent     0s making 1 call to Parse::CPAN::Meta::load_file  | 
| 301 | 1 | 0s | 1 | 15.6ms |     $self = $class->_new($struct, $options);     # spent  15.6ms making 1 call to CPAN::Meta::_new  | 
| 302 | }; | ||||
| 303 | 1 | 0s | croak($@) if $@; | ||
| 304 | 1 | 0s | return $self; | ||
| 305 | } | ||||
| 306 | |||||
| 307 | #pod =method load_yaml_string | ||||
| 308 | #pod | ||||
| 309 | #pod my $meta = CPAN::Meta->load_yaml_string($yaml, \%options); | ||||
| 310 | #pod | ||||
| 311 | #pod This method returns a new CPAN::Meta object using the first document in the | ||||
| 312 | #pod given YAML string. In other respects it is identical to C<load_file()>. | ||||
| 313 | #pod | ||||
| 314 | #pod =cut | ||||
| 315 | |||||
| 316 | sub load_yaml_string { | ||||
| 317 | my ($class, $yaml, $options) = @_; | ||||
| 318 | $options->{lazy_validation} = 1 unless exists $options->{lazy_validation}; | ||||
| 319 | |||||
| 320 | my $self; | ||||
| 321 | eval { | ||||
| 322 | my ($struct) = Parse::CPAN::Meta->load_yaml_string( $yaml ); | ||||
| 323 | $self = $class->_new($struct, $options); | ||||
| 324 | }; | ||||
| 325 | croak($@) if $@; | ||||
| 326 | return $self; | ||||
| 327 | } | ||||
| 328 | |||||
| 329 | #pod =method load_json_string | ||||
| 330 | #pod | ||||
| 331 | #pod my $meta = CPAN::Meta->load_json_string($json, \%options); | ||||
| 332 | #pod | ||||
| 333 | #pod This method returns a new CPAN::Meta object using the structure represented by | ||||
| 334 | #pod the given JSON string. In other respects it is identical to C<load_file()>. | ||||
| 335 | #pod | ||||
| 336 | #pod =cut | ||||
| 337 | |||||
| 338 | sub load_json_string { | ||||
| 339 | my ($class, $json, $options) = @_; | ||||
| 340 | $options->{lazy_validation} = 1 unless exists $options->{lazy_validation}; | ||||
| 341 | |||||
| 342 | my $self; | ||||
| 343 | eval { | ||||
| 344 | my $struct = Parse::CPAN::Meta->load_json_string( $json ); | ||||
| 345 | $self = $class->_new($struct, $options); | ||||
| 346 | }; | ||||
| 347 | croak($@) if $@; | ||||
| 348 | return $self; | ||||
| 349 | } | ||||
| 350 | |||||
| 351 | #pod =method load_string | ||||
| 352 | #pod | ||||
| 353 | #pod my $meta = CPAN::Meta->load_string($string, \%options); | ||||
| 354 | #pod | ||||
| 355 | #pod If you don't know if a string contains YAML or JSON, this method will use | ||||
| 356 | #pod L<Parse::CPAN::Meta> to guess. In other respects it is identical to | ||||
| 357 | #pod C<load_file()>. | ||||
| 358 | #pod | ||||
| 359 | #pod =cut | ||||
| 360 | |||||
| 361 | sub load_string { | ||||
| 362 | my ($class, $string, $options) = @_; | ||||
| 363 | $options->{lazy_validation} = 1 unless exists $options->{lazy_validation}; | ||||
| 364 | |||||
| 365 | my $self; | ||||
| 366 | eval { | ||||
| 367 | my $struct = Parse::CPAN::Meta->load_string( $string ); | ||||
| 368 | $self = $class->_new($struct, $options); | ||||
| 369 | }; | ||||
| 370 | croak($@) if $@; | ||||
| 371 | return $self; | ||||
| 372 | } | ||||
| 373 | |||||
| 374 | #pod =method save | ||||
| 375 | #pod | ||||
| 376 | #pod $meta->save($distmeta_file, \%options); | ||||
| 377 | #pod | ||||
| 378 | #pod Serializes the object as JSON and writes it to the given file. The only valid | ||||
| 379 | #pod option is C<version>, which defaults to '2'. On Perl 5.8.1 or later, the file | ||||
| 380 | #pod is saved with UTF-8 encoding. | ||||
| 381 | #pod | ||||
| 382 | #pod For C<version> 2 (or higher), the filename should end in '.json'. L<JSON::PP> | ||||
| 383 | #pod is the default JSON backend. Using another JSON backend requires L<JSON> 2.5 or | ||||
| 384 | #pod later and you must set the C<$ENV{PERL_JSON_BACKEND}> to a supported alternate | ||||
| 385 | #pod backend like L<JSON::XS>. | ||||
| 386 | #pod | ||||
| 387 | #pod For C<version> less than 2, the filename should end in '.yml'. | ||||
| 388 | #pod L<CPAN::Meta::Converter> is used to generate an older metadata structure, which | ||||
| 389 | #pod is serialized to YAML. CPAN::Meta::YAML is the default YAML backend. You may | ||||
| 390 | #pod set the C<$ENV{PERL_YAML_BACKEND}> to a supported alternative backend, though | ||||
| 391 | #pod this is not recommended due to subtle incompatibilities between YAML parsers on | ||||
| 392 | #pod CPAN. | ||||
| 393 | #pod | ||||
| 394 | #pod =cut | ||||
| 395 | |||||
| 396 | # spent 62.4ms (0s+62.4) within CPAN::Meta::save which was called 6 times, avg 10.4ms/call:
# 3 times (0s+46.8ms) by ExtUtils::MM_Any::write_mymeta at line 1531 of ExtUtils/MM_Any.pm, avg 15.6ms/call
# 3 times (0s+15.6ms) by ExtUtils::MM_Any::write_mymeta at line 1530 of ExtUtils/MM_Any.pm, avg 5.20ms/call  | ||||
| 397 | 6 | 0s | my ($self, $file, $options) = @_; | ||
| 398 | |||||
| 399 | 6 | 0s | my $version = $options->{version} || '2'; | ||
| 400 | 6 | 0s | my $layer = $] ge '5.008001' ? ':utf8' : ''; | ||
| 401 | |||||
| 402 | 6 | 0s | if ( $version ge '2' ) { | ||
| 403 | 3 | 0s | 3 | 0s |     carp "'$file' should end in '.json'"     # spent     0s making 3 calls to CPAN::Meta::CORE:match, avg 0s/call  | 
| 404 | unless $file =~ m{\.json$}; | ||||
| 405 | } | ||||
| 406 | else { | ||||
| 407 | 3 | 0s | 3 | 0s |     carp "'$file' should end in '.yml'"     # spent     0s making 3 calls to CPAN::Meta::CORE:match, avg 0s/call  | 
| 408 | unless $file =~ m{\.yml$}; | ||||
| 409 | } | ||||
| 410 | |||||
| 411 | 6 | 0s | 6 | 62.4ms |   my $data = $self->as_string( $options );   # spent  62.4ms making 6 calls to CPAN::Meta::as_string, avg 10.4ms/call  | 
| 412 | 6 | 0s | 6 | 0s |   open my $fh, ">$layer", $file   # spent     0s making 6 calls to CPAN::Meta::CORE:open, avg 0s/call  | 
| 413 | or die "Error opening '$file' for writing: $!\n"; | ||||
| 414 | |||||
| 415 | 6 | 0s | 6 | 0s |   print {$fh} $data;   # spent     0s making 6 calls to CPAN::Meta::CORE:print, avg 0s/call  | 
| 416 | 6 | 0s | 6 | 0s |   close $fh   # spent     0s making 6 calls to CPAN::Meta::CORE:close, avg 0s/call  | 
| 417 | or die "Error closing '$file': $!\n"; | ||||
| 418 | |||||
| 419 | 6 | 0s | return 1; | ||
| 420 | } | ||||
| 421 | |||||
| 422 | #pod =method meta_spec_version | ||||
| 423 | #pod | ||||
| 424 | #pod This method returns the version part of the C<meta_spec> entry in the distmeta | ||||
| 425 | #pod structure. It is equivalent to: | ||||
| 426 | #pod | ||||
| 427 | #pod $meta->meta_spec->{version}; | ||||
| 428 | #pod | ||||
| 429 | #pod =cut | ||||
| 430 | |||||
| 431 | # spent 0s within CPAN::Meta::meta_spec_version which was called 18 times, avg 0s/call:
# 18 times (0s+0s) by CPAN::Meta::as_string at line 601, avg 0s/call  | ||||
| 432 | 18 | 0s | my ($self) = @_; | ||
| 433 | 18 | 0s | 18 | 0s |   return $self->meta_spec->{version};   # spent     0s making 18 calls to CPAN::Meta::__ANON__[CPAN/Meta.pm:168], avg 0s/call  | 
| 434 | } | ||||
| 435 | |||||
| 436 | #pod =method effective_prereqs | ||||
| 437 | #pod | ||||
| 438 | #pod my $prereqs = $meta->effective_prereqs; | ||||
| 439 | #pod | ||||
| 440 | #pod my $prereqs = $meta->effective_prereqs( \@feature_identifiers ); | ||||
| 441 | #pod | ||||
| 442 | #pod This method returns a L<CPAN::Meta::Prereqs> object describing all the | ||||
| 443 | #pod prereqs for the distribution. If an arrayref of feature identifiers is given, | ||||
| 444 | #pod the prereqs for the identified features are merged together with the | ||||
| 445 | #pod distribution's core prereqs before the CPAN::Meta::Prereqs object is returned. | ||||
| 446 | #pod | ||||
| 447 | #pod =cut | ||||
| 448 | |||||
| 449 | sub effective_prereqs { | ||||
| 450 | my ($self, $features) = @_; | ||||
| 451 | $features ||= []; | ||||
| 452 | |||||
| 453 | my $prereq = CPAN::Meta::Prereqs->new($self->prereqs); | ||||
| 454 | |||||
| 455 | return $prereq unless @$features; | ||||
| 456 | |||||
| 457 | my @other = map {; $self->feature($_)->prereqs } @$features; | ||||
| 458 | |||||
| 459 | return $prereq->with_merged_prereqs(\@other); | ||||
| 460 | } | ||||
| 461 | |||||
| 462 | #pod =method should_index_file | ||||
| 463 | #pod | ||||
| 464 | #pod ... if $meta->should_index_file( $filename ); | ||||
| 465 | #pod | ||||
| 466 | #pod This method returns true if the given file should be indexed. It decides this | ||||
| 467 | #pod by checking the C<file> and C<directory> keys in the C<no_index> property of | ||||
| 468 | #pod the distmeta structure. Note that neither the version format nor | ||||
| 469 | #pod C<release_status> are considered. | ||||
| 470 | #pod | ||||
| 471 | #pod C<$filename> should be given in unix format. | ||||
| 472 | #pod | ||||
| 473 | #pod =cut | ||||
| 474 | |||||
| 475 | sub should_index_file { | ||||
| 476 | my ($self, $filename) = @_; | ||||
| 477 | |||||
| 478 | for my $no_index_file (@{ $self->no_index->{file} || [] }) { | ||||
| 479 | return if $filename eq $no_index_file; | ||||
| 480 | } | ||||
| 481 | |||||
| 482 | for my $no_index_dir (@{ $self->no_index->{directory} }) { | ||||
| 483 | $no_index_dir =~ s{$}{/} unless $no_index_dir =~ m{/\z}; | ||||
| 484 | return if index($filename, $no_index_dir) == 0; | ||||
| 485 | } | ||||
| 486 | |||||
| 487 | return 1; | ||||
| 488 | } | ||||
| 489 | |||||
| 490 | #pod =method should_index_package | ||||
| 491 | #pod | ||||
| 492 | #pod ... if $meta->should_index_package( $package ); | ||||
| 493 | #pod | ||||
| 494 | #pod This method returns true if the given package should be indexed. It decides | ||||
| 495 | #pod this by checking the C<package> and C<namespace> keys in the C<no_index> | ||||
| 496 | #pod property of the distmeta structure. Note that neither the version format nor | ||||
| 497 | #pod C<release_status> are considered. | ||||
| 498 | #pod | ||||
| 499 | #pod =cut | ||||
| 500 | |||||
| 501 | sub should_index_package { | ||||
| 502 | my ($self, $package) = @_; | ||||
| 503 | |||||
| 504 | for my $no_index_pkg (@{ $self->no_index->{package} || [] }) { | ||||
| 505 | return if $package eq $no_index_pkg; | ||||
| 506 | } | ||||
| 507 | |||||
| 508 | for my $no_index_ns (@{ $self->no_index->{namespace} }) { | ||||
| 509 | return if index($package, "${no_index_ns}::") == 0; | ||||
| 510 | } | ||||
| 511 | |||||
| 512 | return 1; | ||||
| 513 | } | ||||
| 514 | |||||
| 515 | #pod =method features | ||||
| 516 | #pod | ||||
| 517 | #pod my @feature_objects = $meta->features; | ||||
| 518 | #pod | ||||
| 519 | #pod This method returns a list of L<CPAN::Meta::Feature> objects, one for each | ||||
| 520 | #pod optional feature described by the distribution's metadata. | ||||
| 521 | #pod | ||||
| 522 | #pod =cut | ||||
| 523 | |||||
| 524 | sub features { | ||||
| 525 | my ($self) = @_; | ||||
| 526 | |||||
| 527 | my $opt_f = $self->optional_features; | ||||
| 528 | my @features = map {; CPAN::Meta::Feature->new($_ => $opt_f->{ $_ }) } | ||||
| 529 | keys %$opt_f; | ||||
| 530 | |||||
| 531 | return @features; | ||||
| 532 | } | ||||
| 533 | |||||
| 534 | #pod =method feature | ||||
| 535 | #pod | ||||
| 536 | #pod my $feature_object = $meta->feature( $identifier ); | ||||
| 537 | #pod | ||||
| 538 | #pod This method returns a L<CPAN::Meta::Feature> object for the optional feature | ||||
| 539 | #pod with the given identifier. If no feature with that identifier exists, an | ||||
| 540 | #pod exception will be raised. | ||||
| 541 | #pod | ||||
| 542 | #pod =cut | ||||
| 543 | |||||
| 544 | sub feature { | ||||
| 545 | my ($self, $ident) = @_; | ||||
| 546 | |||||
| 547 | croak "no feature named $ident" | ||||
| 548 | unless my $f = $self->optional_features->{ $ident }; | ||||
| 549 | |||||
| 550 | return CPAN::Meta::Feature->new($ident, $f); | ||||
| 551 | } | ||||
| 552 | |||||
| 553 | #pod =method as_struct | ||||
| 554 | #pod | ||||
| 555 | #pod my $copy = $meta->as_struct( \%options ); | ||||
| 556 | #pod | ||||
| 557 | #pod This method returns a deep copy of the object's metadata as an unblessed hash | ||||
| 558 | #pod reference. It takes an optional hashref of options. If the hashref contains | ||||
| 559 | #pod a C<version> argument, the copied metadata will be converted to the version | ||||
| 560 | #pod of the specification and returned. For example: | ||||
| 561 | #pod | ||||
| 562 | #pod my $old_spec = $meta->as_struct( {version => "1.4"} ); | ||||
| 563 | #pod | ||||
| 564 | #pod =cut | ||||
| 565 | |||||
| 566 | # spent 62.4ms (0s+62.4) within CPAN::Meta::as_struct which was called 19 times, avg 3.28ms/call:
# 9 times (0s+46.8ms) by CPAN::Meta::as_string at line 602, avg 5.20ms/call
# 9 times (0s+15.6ms) by CPAN::Meta::as_string at line 606, avg 1.73ms/call
#    once (0s+0s) by ExtUtils::MM_Any::_mymeta_from_meta at line 1490 of ExtUtils/MM_Any.pm  | ||||
| 567 | 19 | 0s | my ($self, $options) = @_; | ||
| 568 | 19 | 0s | 19 | 62.4ms |   my $struct = _dclone($self);   # spent  62.4ms making 19 calls to CPAN::Meta::Converter::_dclone, avg 3.28ms/call  | 
| 569 | 19 | 0s | if ( $options->{version} ) { | ||
| 570 | 1 | 0s | 1 | 0s |     my $cmc = CPAN::Meta::Converter->new( $struct );     # spent     0s making 1 call to CPAN::Meta::Converter::new  | 
| 571 | 1 | 0s | 1 | 0s |     $struct = $cmc->convert( version => $options->{version} );     # spent     0s making 1 call to CPAN::Meta::Converter::convert  | 
| 572 | } | ||||
| 573 | 19 | 0s | return $struct; | ||
| 574 | } | ||||
| 575 | |||||
| 576 | #pod =method as_string | ||||
| 577 | #pod | ||||
| 578 | #pod my $string = $meta->as_string( \%options ); | ||||
| 579 | #pod | ||||
| 580 | #pod This method returns a serialized copy of the object's metadata as a character | ||||
| 581 | #pod string. (The strings are B<not> UTF-8 encoded.) It takes an optional hashref | ||||
| 582 | #pod of options. If the hashref contains a C<version> argument, the copied metadata | ||||
| 583 | #pod will be converted to the version of the specification and returned. For | ||||
| 584 | #pod example: | ||||
| 585 | #pod | ||||
| 586 | #pod my $string = $meta->as_string( {version => "1.4"} ); | ||||
| 587 | #pod | ||||
| 588 | #pod For C<version> greater than or equal to 2, the string will be serialized as | ||||
| 589 | #pod JSON. For C<version> less than 2, the string will be serialized as YAML. In | ||||
| 590 | #pod both cases, the same rules are followed as in the C<save()> method for choosing | ||||
| 591 | #pod a serialization backend. | ||||
| 592 | #pod | ||||
| 593 | #pod =cut | ||||
| 594 | |||||
| 595 | # spent 140ms (0s+140) within CPAN::Meta::as_string which was called 18 times, avg 7.80ms/call:
# 6 times (0s+62.4ms) by CPAN::Meta::save at line 411, avg 10.4ms/call
# 3 times (0s+31.2ms) by ExtUtils::MM_Any::metafile_target at line 976 of ExtUtils/MM_Any.pm, avg 10.4ms/call
# 3 times (0s+31.2ms) by ExtUtils::MM_Any::metafile_target at line 983 of ExtUtils/MM_Any.pm, avg 10.4ms/call
# 3 times (0s+15.6ms) by ExtUtils::MM_Any::metafile_target at line 986 of ExtUtils/MM_Any.pm, avg 5.20ms/call
# 3 times (0s+0s) by ExtUtils::MM_Any::metafile_target at line 977 of ExtUtils/MM_Any.pm, avg 0s/call  | ||||
| 596 | 18 | 0s | my ($self, $options) = @_; | ||
| 597 | |||||
| 598 | 18 | 0s | my $version = $options->{version} || '2'; | ||
| 599 | |||||
| 600 | 18 | 0s | my $struct; | ||
| 601 | 18 | 0s | 18 | 0s |   if ( $self->meta_spec_version ne $version ) {   # spent     0s making 18 calls to CPAN::Meta::meta_spec_version, avg 0s/call  | 
| 602 | 9 | 0s | 18 | 46.8ms |     my $cmc = CPAN::Meta::Converter->new( $self->as_struct );     # spent  46.8ms making 9 calls to CPAN::Meta::as_struct, avg 5.20ms/call
    # spent     0s making 9 calls to CPAN::Meta::Converter::new, avg 0s/call  | 
| 603 | 9 | 0s | 9 | 46.8ms |     $struct = $cmc->convert( version => $version );     # spent  46.8ms making 9 calls to CPAN::Meta::Converter::convert, avg 5.20ms/call  | 
| 604 | } | ||||
| 605 | else { | ||||
| 606 | 9 | 0s | 9 | 15.6ms |     $struct = $self->as_struct;     # spent  15.6ms making 9 calls to CPAN::Meta::as_struct, avg 1.73ms/call  | 
| 607 | } | ||||
| 608 | |||||
| 609 | 18 | 0s | my ($data, $backend); | ||
| 610 | 18 | 0s | if ( $version ge '2' ) { | ||
| 611 | 9 | 0s | 9 | 0s |     $backend = Parse::CPAN::Meta->json_backend();     # spent     0s making 9 calls to Parse::CPAN::Meta::json_backend, avg 0s/call  | 
| 612 | 9 | 0s | 36 | 15.6ms |     $data = $backend->new->pretty->canonical->encode($struct);     # spent  15.6ms making 9 calls to JSON::PP::encode, avg 1.73ms/call
    # spent     0s making 9 calls to JSON::PP::canonical, avg 0s/call
    # spent     0s making 9 calls to JSON::PP::new, avg 0s/call
    # spent     0s making 9 calls to JSON::PP::pretty, avg 0s/call  | 
| 613 | } | ||||
| 614 | else { | ||||
| 615 | 9 | 0s | 9 | 15.6ms |     $backend = Parse::CPAN::Meta->yaml_backend();     # spent  15.6ms making 9 calls to Parse::CPAN::Meta::yaml_backend, avg 1.73ms/call  | 
| 616 | 20 | 0s | 11 | 0s | # spent 0s within CPAN::Meta::BEGIN@616 which was called:
#    once (0s+0s) by ExtUtils::MM_Any::_has_cpan_meta at line 616     # spent     0s making 1 call to CPAN::Meta::BEGIN@616
    # spent     0s making 9 calls to CPAN::Meta::YAML::Dump, avg 0s/call
    # spent     0s making 1 call to strict::unimport  | 
| 617 | 9 | 0s | if ( $@ ) { | ||
| 618 | croak $backend->can('errstr') ? $backend->errstr : $@ | ||||
| 619 | } | ||||
| 620 | } | ||||
| 621 | |||||
| 622 | 18 | 0s | return $data; | ||
| 623 | } | ||||
| 624 | |||||
| 625 | # Used by JSON::PP, etc. for "convert_blessed" | ||||
| 626 | # spent 0s within CPAN::Meta::TO_JSON which was called 19 times, avg 0s/call:
# 19 times (0s+0s) by JSON::PP::object_to_json at line 324 of JSON/PP.pm, avg 0s/call  | ||||
| 627 | 19 | 0s | return { %{ $_[0] } }; | ||
| 628 | } | ||||
| 629 | |||||
| 630 | 1 | 0s | 1; | ||
| 631 | |||||
| 632 | # ABSTRACT: the distribution metadata for a CPAN dist | ||||
| 633 | |||||
| 634 | __END__ | ||||
# spent 0s within CPAN::Meta::CORE:close which was called 6 times, avg 0s/call:
# 6 times (0s+0s) by CPAN::Meta::save at line 416, avg 0s/call  | |||||
# spent 0s within CPAN::Meta::CORE:fteread which was called:
#    once (0s+0s) by CPAN::Meta::load_file at line 295  | |||||
sub CPAN::Meta::CORE:match; # opcode  | |||||
# spent 0s within CPAN::Meta::CORE:open which was called 6 times, avg 0s/call:
# 6 times (0s+0s) by CPAN::Meta::save at line 412, avg 0s/call  | |||||
# spent 0s within CPAN::Meta::CORE:print which was called 6 times, avg 0s/call:
# 6 times (0s+0s) by CPAN::Meta::save at line 415, avg 0s/call  | |||||
# spent 0s within CPAN::Meta::CORE:subst which was called 6 times, avg 0s/call:
# 6 times (0s+0s) by CPAN::Meta::BEGIN@150 at line 163, avg 0s/call  |