Lines Matching +full:meta +full:- +full:spec

4 package CPAN::Meta;
13 #pod use CPAN::Meta;
16 #pod my $meta = CPAN::Meta->load_file('META.json');
19 #pod $meta->name,
20 #pod $meta->version;
22 #pod my $prereqs = $meta->effective_prereqs;
26 #pod my $reqs = $prereqs->requirements_for($phase, "requires");
27 #pod for my $module ( sort $reqs->required_modules ) {
30 #pod my $version = $module eq 'perl' ? $] : $module->VERSION;
31 #pod $status = $reqs->accepts_module($module, $version)
42 #pod Software distributions released to the CPAN include a F<META.json> or, for
43 #pod older distributions, F<META.yml>, which describes the distribution, its
45 #pod The data structure stored in the F<META.json> file is described in
46 #pod L<CPAN::Meta::Spec>.
48 #pod CPAN::Meta provides a simple class to represent this distribution metadata (or
51 #pod The documentation below is only for the methods of the CPAN::Meta object. For
52 #pod information on the meaning of individual fields, consult the spec.
57 use CPAN::Meta::Feature;
58 use CPAN::Meta::Prereqs;
59 use CPAN::Meta::Converter;
60 use CPAN::Meta::Validator;
61 use Parse::CPAN::Meta 1.4414 ();
63 BEGIN { *_dclone = \&CPAN::Meta::Converter::_dclone }
133 sub authors { $_[0]->author }
134 sub licenses { $_[0]->license }
153 meta-spec
164 (my $subname = $attr) =~ s/-/_/;
178 #pod say $meta->custom($_) for $meta->custom_keys;
190 my $value = $self->{$attr};
197 #pod my $meta = CPAN::Meta->new($distmeta_struct, \%options);
199 #pod Returns a valid CPAN::Meta object or dies if the supplied metadata hash
200 #pod reference fails to validate. Older-format metadata will be up-converted to
209 #pod lazy_validation -- if true, new will attempt to convert the given metadata
211 #pod fixable errors will be handled by CPAN::Meta::Converter before validation.
223 if ( $options->{lazy_validation} ) {
225 my $cmc = CPAN::Meta::Converter->new( $struct );
226 $self = $cmc->convert( version => 2 ); # valid or dies
231 my $cmv = CPAN::Meta::Validator->new( $struct );
232 unless ( $cmv->is_valid) {
234 . join(", ", $cmv->errors) . "\n";
238 # up-convert older spec versions
239 my $version = $struct->{'meta-spec'}{version} || '1.0';
244 my $cmc = CPAN::Meta::Converter->new( $struct );
245 $self = $cmc->convert( version => 2 );
253 my $self = eval { $class->_new($struct, $options) };
260 #pod my $meta = CPAN::Meta->create($distmeta_struct, \%options);
262 #pod This is same as C<new()>, except that C<generated_by> and C<meta-spec> fields
264 #pod assumed to otherwise follow the latest L<CPAN::Meta::Spec>.
270 my $version = __PACKAGE__->VERSION || 2;
271 $struct->{generated_by} ||= __PACKAGE__ . " version $version" ;
272 $struct->{'meta-spec'}{version} ||= int($version);
273 my $self = eval { $class->_new($struct, $options) };
280 #pod my $meta = CPAN::Meta->load_file($distmeta_file, \%options);
283 #pod according to its file suffix and constructs a new C<CPAN::Meta> object, just
294 $options->{lazy_validation} = 1 unless exists $options->{lazy_validation};
297 unless -r $file;
301 my $struct = Parse::CPAN::Meta->load_file( $file );
302 $self = $class->_new($struct, $options);
310 #pod my $meta = CPAN::Meta->load_yaml_string($yaml, \%options);
312 #pod This method returns a new CPAN::Meta object using the first document in the
319 $options->{lazy_validation} = 1 unless exists $options->{lazy_validation};
323 my ($struct) = Parse::CPAN::Meta->load_yaml_string( $yaml );
324 $self = $class->_new($struct, $options);
332 #pod my $meta = CPAN::Meta->load_json_string($json, \%options);
334 #pod This method returns a new CPAN::Meta object using the structure represented by
341 $options->{lazy_validation} = 1 unless exists $options->{lazy_validation};
345 my $struct = Parse::CPAN::Meta->load_json_string( $json );
346 $self = $class->_new($struct, $options);
354 #pod my $meta = CPAN::Meta->load_string($string, \%options);
357 #pod L<Parse::CPAN::Meta> to guess. In other respects it is identical to
364 $options->{lazy_validation} = 1 unless exists $options->{lazy_validation};
368 my $struct = Parse::CPAN::Meta->load_string( $string );
369 $self = $class->_new($struct, $options);
377 #pod $meta->save($distmeta_file, \%options);
381 #pod is saved with UTF-8 encoding.
389 #pod L<CPAN::Meta::Converter> is used to generate an older metadata structure, which
390 #pod is serialized to YAML. CPAN::Meta::YAML is the default YAML backend. You may
400 my $version = $options->{version} || '2';
412 my $data = $self->as_string( $options );
428 #pod $meta->meta_spec->{version};
434 return $self->meta_spec->{version};
439 #pod my $prereqs = $meta->effective_prereqs;
441 #pod my $prereqs = $meta->effective_prereqs( \@feature_identifiers );
443 #pod This method returns a L<CPAN::Meta::Prereqs> object describing all the
446 #pod distribution's core prereqs before the CPAN::Meta::Prereqs object is returned.
454 my $prereq = CPAN::Meta::Prereqs->new($self->prereqs);
458 my @other = map {; $self->feature($_)->prereqs } @$features;
460 return $prereq->with_merged_prereqs(\@other);
465 #pod ... if $meta->should_index_file( $filename );
479 for my $no_index_file (@{ $self->no_index->{file} || [] }) {
483 for my $no_index_dir (@{ $self->no_index->{directory} }) {
493 #pod ... if $meta->should_index_package( $package );
505 for my $no_index_pkg (@{ $self->no_index->{package} || [] }) {
509 for my $no_index_ns (@{ $self->no_index->{namespace} }) {
518 #pod my @feature_objects = $meta->features;
520 #pod This method returns a list of L<CPAN::Meta::Feature> objects, one for each
528 my $opt_f = $self->optional_features;
529 my @features = map {; CPAN::Meta::Feature->new($_ => $opt_f->{ $_ }) }
537 #pod my $feature_object = $meta->feature( $identifier );
539 #pod This method returns a L<CPAN::Meta::Feature> object for the optional feature
549 unless my $f = $self->optional_features->{ $ident };
551 return CPAN::Meta::Feature->new($ident, $f);
556 #pod my $copy = $meta->as_struct( \%options );
563 #pod my $old_spec = $meta->as_struct( {version => "1.4"} );
570 if ( $options->{version} ) {
571 my $cmc = CPAN::Meta::Converter->new( $struct );
572 $struct = $cmc->convert( version => $options->{version} );
579 #pod my $string = $meta->as_string( \%options );
582 #pod string. (The strings are B<not> UTF-8 encoded.) It takes an optional hashref
587 #pod my $string = $meta->as_string( {version => "1.4"} );
596 #pod C<$meta> object will be clobbered.
603 my $version = $options->{version} || '2';
606 if ( $self->meta_spec_version ne $version ) {
607 my $cmc = CPAN::Meta::Converter->new( $self->as_struct );
608 $struct = $cmc->convert( version => $version );
611 $struct = $self->as_struct;
616 $backend = Parse::CPAN::Meta->json_backend();
617 local $struct->{x_serialization_backend} = sprintf '%s version %s',
618 $backend, $backend->VERSION;
619 $data = $backend->new->pretty->canonical->encode($struct);
622 $backend = Parse::CPAN::Meta->yaml_backend();
623 local $struct->{x_serialization_backend} = sprintf '%s version %s',
624 $backend, $backend->VERSION;
627 croak $backend->can('errstr') ? $backend->errstr : $@
645 =encoding UTF-8
649 CPAN::Meta - the distribution metadata for a CPAN dist
660 use CPAN::Meta;
663 my $meta = CPAN::Meta->load_file('META.json');
666 $meta->name,
667 $meta->version;
669 my $prereqs = $meta->effective_prereqs;
673 my $reqs = $prereqs->requirements_for($phase, "requires");
674 for my $module ( sort $reqs->required_modules ) {
677 my $version = $module eq 'perl' ? $] : $module->VERSION;
678 $status = $reqs->accepts_module($module, $version)
689 Software distributions released to the CPAN include a F<META.json> or, for
690 older distributions, F<META.yml>, which describes the distribution, its
692 The data structure stored in the F<META.json> file is described in
693 L<CPAN::Meta::Spec>.
695 CPAN::Meta provides a simple class to represent this distribution metadata (or
698 The documentation below is only for the methods of the CPAN::Meta object. For
699 information on the meaning of individual fields, consult the spec.
705 my $meta = CPAN::Meta->new($distmeta_struct, \%options);
707 Returns a valid CPAN::Meta object or dies if the supplied metadata hash
708 reference fails to validate. Older-format metadata will be up-converted to
717 lazy_validation -- if true, new will attempt to convert the given metadata
719 fixable errors will be handled by CPAN::Meta::Converter before validation.
727 my $meta = CPAN::Meta->create($distmeta_struct, \%options);
729 This is same as C<new()>, except that C<generated_by> and C<meta-spec> fields
731 assumed to otherwise follow the latest L<CPAN::Meta::Spec>.
735 my $meta = CPAN::Meta->load_file($distmeta_file, \%options);
738 according to its file suffix and constructs a new C<CPAN::Meta> object, just
747 my $meta = CPAN::Meta->load_yaml_string($yaml, \%options);
749 This method returns a new CPAN::Meta object using the first document in the
754 my $meta = CPAN::Meta->load_json_string($json, \%options);
756 This method returns a new CPAN::Meta object using the structure represented by
761 my $meta = CPAN::Meta->load_string($string, \%options);
764 L<Parse::CPAN::Meta> to guess. In other respects it is identical to
769 $meta->save($distmeta_file, \%options);
773 is saved with UTF-8 encoding.
781 L<CPAN::Meta::Converter> is used to generate an older metadata structure, which
782 is serialized to YAML. CPAN::Meta::YAML is the default YAML backend. You may
792 $meta->meta_spec->{version};
796 my $prereqs = $meta->effective_prereqs;
798 my $prereqs = $meta->effective_prereqs( \@feature_identifiers );
800 This method returns a L<CPAN::Meta::Prereqs> object describing all the
803 distribution's core prereqs before the CPAN::Meta::Prereqs object is returned.
807 ... if $meta->should_index_file( $filename );
818 ... if $meta->should_index_package( $package );
827 my @feature_objects = $meta->features;
829 This method returns a list of L<CPAN::Meta::Feature> objects, one for each
834 my $feature_object = $meta->feature( $identifier );
836 This method returns a L<CPAN::Meta::Feature> object for the optional feature
842 my $copy = $meta->as_struct( \%options );
849 my $old_spec = $meta->as_struct( {version => "1.4"} );
853 my $string = $meta->as_string( \%options );
856 string. (The strings are B<not> UTF-8 encoded.) It takes an optional hashref
861 my $string = $meta->as_string( {version => "1.4"} );
870 C<$meta> object will be clobbered.
972 say $meta->custom($_) for $meta->custom_keys;
984 L<http://rt.cpan.org/Dist/Display.html?Queue=CPAN-Meta>
986 When submitting a bug or request, please include a test-file or a patch to an
987 existing test-file that illustrates the bug or desired feature.
995 L<CPAN::Meta::Converter>
999 L<CPAN::Meta::Validator>
1010 at L<https://github.com/Perl-Toolchain-Gang/CPAN-Meta/issues>.
1018 L<https://github.com/Perl-Toolchain-Gang/CPAN-Meta>
1020 git clone https://github.com/Perl-Toolchain-Gang/CPAN-Meta.git