← Index
NYTProf Performance Profile   « line view »
For Makefile.PL
  Run on Sun Mar 1 16:04:44 2015
Reported on Sun Mar 1 16:09:02 2015

FilenameC:/tmp64ng/perl/lib/CPAN/Meta.pm
StatementsExecuted 584 statements in 15.6ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11131.2ms31.2msCPAN::Meta::::BEGIN@58 CPAN::Meta::BEGIN@58
1110s0sCPAN::Meta::::BEGIN@113 CPAN::Meta::BEGIN@113
1110s0sCPAN::Meta::::BEGIN@120 CPAN::Meta::BEGIN@120
1110s0sCPAN::Meta::::BEGIN@150 CPAN::Meta::BEGIN@150
1110s0sCPAN::Meta::::BEGIN@161 CPAN::Meta::BEGIN@161
1110s0sCPAN::Meta::::BEGIN@55 CPAN::Meta::BEGIN@55
1110s0sCPAN::Meta::::BEGIN@56 CPAN::Meta::BEGIN@56
1110s0sCPAN::Meta::::BEGIN@57 CPAN::Meta::BEGIN@57
1110s0sCPAN::Meta::::BEGIN@59 CPAN::Meta::BEGIN@59
1110s0sCPAN::Meta::::BEGIN@60 CPAN::Meta::BEGIN@60
1110s0sCPAN::Meta::::BEGIN@616 CPAN::Meta::BEGIN@616
1110s0sCPAN::Meta::::BEGIN@62 CPAN::Meta::BEGIN@62
1110s0sCPAN::Meta::::BEGIN@81 CPAN::Meta::BEGIN@81
1110s0sCPAN::Meta::::BEGIN@92 CPAN::Meta::BEGIN@92
6110s0sCPAN::Meta::::CORE:close CPAN::Meta::CORE:close (opcode)
1110s0sCPAN::Meta::::CORE:fteread CPAN::Meta::CORE:fteread (opcode)
6210s0sCPAN::Meta::::CORE:match CPAN::Meta::CORE:match (opcode)
6110s0sCPAN::Meta::::CORE:open CPAN::Meta::CORE:open (opcode)
6110s0sCPAN::Meta::::CORE:print CPAN::Meta::CORE:print (opcode)
6110s0sCPAN::Meta::::CORE:subst CPAN::Meta::CORE:subst (opcode)
19110s0sCPAN::Meta::::TO_JSON CPAN::Meta::TO_JSON
0000s0sCPAN::Meta::::__ANON__[:128] CPAN::Meta::__ANON__[:128]
18110s0sCPAN::Meta::::__ANON__[:168] CPAN::Meta::__ANON__[:168]
0000s0sCPAN::Meta::::__ANON__[:94] CPAN::Meta::__ANON__[:94]
7310s109msCPAN::Meta::::_new CPAN::Meta::_new
18520s140msCPAN::Meta::::as_string CPAN::Meta::as_string
19320s62.4msCPAN::Meta::::as_struct CPAN::Meta::as_struct
0000s0sCPAN::Meta::::authors CPAN::Meta::authors
3110s46.8msCPAN::Meta::::create CPAN::Meta::create
0000s0sCPAN::Meta::::custom CPAN::Meta::custom
0000s0sCPAN::Meta::::custom_keys CPAN::Meta::custom_keys
0000s0sCPAN::Meta::::effective_prereqs CPAN::Meta::effective_prereqs
0000s0sCPAN::Meta::::feature CPAN::Meta::feature
0000s0sCPAN::Meta::::features CPAN::Meta::features
0000s0sCPAN::Meta::::licenses CPAN::Meta::licenses
1110s15.6msCPAN::Meta::::load_file CPAN::Meta::load_file
0000s0sCPAN::Meta::::load_json_string CPAN::Meta::load_json_string
0000s0sCPAN::Meta::::load_string CPAN::Meta::load_string
0000s0sCPAN::Meta::::load_yaml_string CPAN::Meta::load_yaml_string
18110s0sCPAN::Meta::::meta_spec_version CPAN::Meta::meta_spec_version
3110s46.8msCPAN::Meta::::new CPAN::Meta::new
6210s62.4msCPAN::Meta::::save CPAN::Meta::save
0000s0sCPAN::Meta::::should_index_file CPAN::Meta::should_index_file
0000s0sCPAN::Meta::::should_index_package CPAN::Meta::should_index_package
1110s0sExtUtils::MM_Any::::BEGIN@1ExtUtils::MM_Any::BEGIN@1
1110s0sExtUtils::MM_Any::::BEGIN@2ExtUtils::MM_Any::BEGIN@2
1110s0sExtUtils::MM_Any::::BEGIN@3.3ExtUtils::MM_Any::BEGIN@3.3
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
120s10s
# spent 0s within ExtUtils::MM_Any::BEGIN@1 which was called: # once (0s+0s) by ExtUtils::MM_Any::_has_cpan_meta at line 1
use 5.006;
# spent 0s making 1 call to ExtUtils::MM_Any::BEGIN@1
220s20s
# spent 0s within ExtUtils::MM_Any::BEGIN@2 which was called: # once (0s+0s) by ExtUtils::MM_Any::_has_cpan_meta at line 2
use strict;
# spent 0s making 1 call to ExtUtils::MM_Any::BEGIN@2 # spent 0s making 1 call to strict::import
320s20s
# 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
use warnings;
# spent 0s making 1 call to ExtUtils::MM_Any::BEGIN@3.3 # spent 0s making 1 call to warnings::import
4package CPAN::Meta;
5# VERSION
610s$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
5520s20s
# spent 0s within CPAN::Meta::BEGIN@55 which was called: # once (0s+0s) by ExtUtils::MM_Any::_has_cpan_meta at line 55
use Carp qw(carp croak);
# spent 0s making 1 call to CPAN::Meta::BEGIN@55 # spent 0s making 1 call to Exporter::import
5620s10s
# spent 0s within CPAN::Meta::BEGIN@56 which was called: # once (0s+0s) by ExtUtils::MM_Any::_has_cpan_meta at line 56
use CPAN::Meta::Feature;
# spent 0s making 1 call to CPAN::Meta::BEGIN@56
5720s10s
# spent 0s within CPAN::Meta::BEGIN@57 which was called: # once (0s+0s) by ExtUtils::MM_Any::_has_cpan_meta at line 57
use CPAN::Meta::Prereqs;
# spent 0s making 1 call to CPAN::Meta::BEGIN@57
58215.6ms131.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
use CPAN::Meta::Converter;
# spent 31.2ms making 1 call to CPAN::Meta::BEGIN@58
5920s10s
# spent 0s within CPAN::Meta::BEGIN@59 which was called: # once (0s+0s) by ExtUtils::MM_Any::_has_cpan_meta at line 59
use CPAN::Meta::Validator;
# spent 0s making 1 call to CPAN::Meta::BEGIN@59
6030s20s
# spent 0s within CPAN::Meta::BEGIN@60 which was called: # once (0s+0s) by ExtUtils::MM_Any::_has_cpan_meta at line 60
use Parse::CPAN::Meta 1.4414 ();
# spent 0s making 1 call to CPAN::Meta::BEGIN@60 # spent 0s making 1 call to version::vxs::_VERSION
61
6210s10s
# spent 0s within CPAN::Meta::BEGIN@62 which was called: # once (0s+0s) by ExtUtils::MM_Any::_has_cpan_meta at line 62
BEGIN { *_dclone = \&CPAN::Meta::Converter::_dclone }
# 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
BEGIN {
8210s my @STRING_READERS = qw(
83 abstract
84 description
85 dynamic_config
86 generated_by
87 name
88 release_status
89 version
90 );
91
9220s20s
# spent 0s within CPAN::Meta::BEGIN@92 which was called: # once (0s+0s) by ExtUtils::MM_Any::_has_cpan_meta at line 92
no strict 'refs';
# spent 0s making 1 call to CPAN::Meta::BEGIN@92 # spent 0s making 1 call to strict::unimport
9310s for my $attr (@STRING_READERS) {
9470s *$attr = sub { $_[0]{ $attr } };
95 }
9610s10s}
# 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
BEGIN {
11410s my @LIST_READERS = qw(
115 author
116 keywords
117 license
118 );
119
12020s20s
# spent 0s within CPAN::Meta::BEGIN@120 which was called: # once (0s+0s) by ExtUtils::MM_Any::_has_cpan_meta at line 120
no strict 'refs';
# spent 0s making 1 call to CPAN::Meta::BEGIN@120 # spent 0s making 1 call to strict::unimport
12110s 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;
12830s };
129 }
13010s10s}
# spent 0s making 1 call to CPAN::Meta::BEGIN@113
131
132sub authors { $_[0]->author }
133sub 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
BEGIN {
15110s my @MAP_READERS = qw(
152 meta-spec
153 resources
154 provides
155 no_index
156
157 prereqs
158 optional_features
159 );
160
16120s20s
# spent 0s within CPAN::Meta::BEGIN@161 which was called: # once (0s+0s) by ExtUtils::MM_Any::_has_cpan_meta at line 161
no strict 'refs';
# spent 0s making 1 call to CPAN::Meta::BEGIN@161 # spent 0s making 1 call to strict::unimport
16210s for my $attr (@MAP_READERS) {
16360s60s (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
*$subname = sub {
165180s my $value = $_[0]{ $attr };
166180s180s return _dclone($value) if $value;
# spent 0s making 18 calls to CPAN::Meta::Converter::_dclone, avg 0s/call
167 return {};
16860s };
169 }
17010s10s}
# 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
183sub custom_keys {
184 return grep { /^x_/i } keys %{$_[0]};
185}
186
187sub 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
# spent 109ms (0s+109) within CPAN::Meta::_new which was called 7 times, avg 15.6ms/call: # 3 times (0s+46.8ms) by CPAN::Meta::create at line 272, avg 15.6ms/call # 3 times (0s+46.8ms) by CPAN::Meta::new at line 252, avg 15.6ms/call # once (0s+15.6ms) by CPAN::Meta::load_file at line 301
sub _new {
21970s my ($class, $struct, $options) = @_;
22070s my $self;
221
22270s if ( $options->{lazy_validation} ) {
223 # try to convert to a valid structure; if succeeds, then return it
22470s70s my $cmc = CPAN::Meta::Converter->new( $struct );
# spent 0s making 7 calls to CPAN::Meta::Converter::new, avg 0s/call
22570s7109ms $self = $cmc->convert( version => 2 ); # valid or dies
# spent 109ms making 7 calls to CPAN::Meta::Converter::convert, avg 15.6ms/call
22670s 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
sub new {
25130s my ($class, $struct, $options) = @_;
25260s346.8ms my $self = eval { $class->_new($struct, $options) };
# spent 46.8ms making 3 calls to CPAN::Meta::_new, avg 15.6ms/call
25330s croak($@) if $@;
25430s 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
sub create {
26830s my ($class, $struct, $options) = @_;
26930s30s my $version = __PACKAGE__->VERSION || 2;
# spent 0s making 3 calls to version::vxs::_VERSION, avg 0s/call
27030s $struct->{generated_by} ||= __PACKAGE__ . " version $version" ;
27130s $struct->{'meta-spec'}{version} ||= int($version);
27260s346.8ms my $self = eval { $class->_new($struct, $options) };
# spent 46.8ms making 3 calls to CPAN::Meta::_new, avg 15.6ms/call
27330s croak ($@) if $@;
27430s 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
sub load_file {
29210s my ($class, $file, $options) = @_;
29310s $options->{lazy_validation} = 1 unless exists $options->{lazy_validation};
294
29510s10s croak "load_file() requires a valid, readable filename"
# spent 0s making 1 call to CPAN::Meta::CORE:fteread
296 unless -r $file;
297
29810s my $self;
29910s eval {
30010s10s my $struct = Parse::CPAN::Meta->load_file( $file );
# spent 0s making 1 call to Parse::CPAN::Meta::load_file
30110s115.6ms $self = $class->_new($struct, $options);
# spent 15.6ms making 1 call to CPAN::Meta::_new
302 };
30310s croak($@) if $@;
30410s 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
316sub 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
338sub 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
361sub 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
sub save {
39760s my ($self, $file, $options) = @_;
398
39960s my $version = $options->{version} || '2';
40060s my $layer = $] ge '5.008001' ? ':utf8' : '';
401
40260s if ( $version ge '2' ) {
40330s30s 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 {
40730s30s 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
41160s662.4ms my $data = $self->as_string( $options );
# spent 62.4ms making 6 calls to CPAN::Meta::as_string, avg 10.4ms/call
41260s60s 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
41560s60s print {$fh} $data;
# spent 0s making 6 calls to CPAN::Meta::CORE:print, avg 0s/call
41660s60s close $fh
# spent 0s making 6 calls to CPAN::Meta::CORE:close, avg 0s/call
417 or die "Error closing '$file': $!\n";
418
41960s 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
sub meta_spec_version {
432180s my ($self) = @_;
433180s180s 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
449sub 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
475sub 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
501sub 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
524sub 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
544sub 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
sub as_struct {
567190s my ($self, $options) = @_;
568190s1962.4ms my $struct = _dclone($self);
# spent 62.4ms making 19 calls to CPAN::Meta::Converter::_dclone, avg 3.28ms/call
569190s if ( $options->{version} ) {
57010s10s my $cmc = CPAN::Meta::Converter->new( $struct );
# spent 0s making 1 call to CPAN::Meta::Converter::new
57110s10s $struct = $cmc->convert( version => $options->{version} );
# spent 0s making 1 call to CPAN::Meta::Converter::convert
572 }
573190s 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
sub as_string {
596180s my ($self, $options) = @_;
597
598180s my $version = $options->{version} || '2';
599
600180s my $struct;
601180s180s if ( $self->meta_spec_version ne $version ) {
# spent 0s making 18 calls to CPAN::Meta::meta_spec_version, avg 0s/call
60290s1846.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
60390s946.8ms $struct = $cmc->convert( version => $version );
# spent 46.8ms making 9 calls to CPAN::Meta::Converter::convert, avg 5.20ms/call
604 }
605 else {
60690s915.6ms $struct = $self->as_struct;
# spent 15.6ms making 9 calls to CPAN::Meta::as_struct, avg 1.73ms/call
607 }
608
609180s my ($data, $backend);
610180s if ( $version ge '2' ) {
61190s90s $backend = Parse::CPAN::Meta->json_backend();
# spent 0s making 9 calls to Parse::CPAN::Meta::json_backend, avg 0s/call
61290s3615.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 {
61590s915.6ms $backend = Parse::CPAN::Meta->yaml_backend();
# spent 15.6ms making 9 calls to Parse::CPAN::Meta::yaml_backend, avg 1.73ms/call
616200s110s
# spent 0s within CPAN::Meta::BEGIN@616 which was called: # once (0s+0s) by ExtUtils::MM_Any::_has_cpan_meta at line 616
$data = eval { no strict 'refs'; &{"$backend\::Dump"}($struct) };
# 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
61790s if ( $@ ) {
618 croak $backend->can('errstr') ? $backend->errstr : $@
619 }
620 }
621
622180s 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
sub TO_JSON {
627190s return { %{ $_[0] } };
628}
629
63010s1;
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
sub CPAN::Meta::CORE:close; # opcode
# 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:fteread; # opcode
# spent 0s within CPAN::Meta::CORE:match which was called 6 times, avg 0s/call: # 3 times (0s+0s) by CPAN::Meta::save at line 403, avg 0s/call # 3 times (0s+0s) by CPAN::Meta::save at line 407, avg 0s/call
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
sub CPAN::Meta::CORE:open; # opcode
# 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
sub CPAN::Meta::CORE:print; # opcode
# 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
sub CPAN::Meta::CORE:subst; # opcode