CPAN-Meta

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN


    CPAN::Meta provides a simple class to represent this distribution
    metadata (or *distmeta*), along with some helpful methods for
    interrogating that data.

    The documentation below is only for the methods of the CPAN::Meta
    object. For information on the meaning of individual fields, consult the
    spec.

METHODS
  new
      my $meta = CPAN::Meta->new($distmeta_struct, \%options);

    Returns a valid CPAN::Meta object or dies if the supplied metadata hash
    reference fails to validate. Older-format metadata will be up-converted
    to version 2 if they validate against the original stated specification.

    It takes an optional hashref of options. Valid options include:

    *   lazy_validation -- if true, new will attempt to convert the given
        metadata to version 2 before attempting to validate it. This means
        than any fixable errors will be handled by CPAN::Meta::Converter
        before validation. (Note that this might result in invalid optional
        data being silently dropped.) The default is false.

  create
      my $meta = CPAN::Meta->create($distmeta_struct, \%options);

    This is same as new(), except that "generated_by" and "meta-spec" fields
    will be generated if not provided. This means the metadata structure is
    assumed to otherwise follow the latest CPAN::Meta::Spec.

  load_file
      my $meta = CPAN::Meta->load_file($distmeta_file, \%options);

    Given a pathname to a file containing metadata, this deserializes the
    file according to its file suffix and constructs a new "CPAN::Meta"
    object, just like new(). It will die if the deserialized version fails
    to validate against its stated specification version.

    It takes the same options as new() but "lazy_validation" defaults to
    true.

  load_yaml_string
      my $meta = CPAN::Meta->load_yaml_string($yaml, \%options);

    This method returns a new CPAN::Meta object using the first document in
    the given YAML string. In other respects it is identical to load_file().

  load_json_string
      my $meta = CPAN::Meta->load_json_string($json, \%options);

    This method returns a new CPAN::Meta object using the structure
    represented by the given JSON string. In other respects it is identical
    to load_file().

  load_string
      my $meta = CPAN::Meta->load_string($string, \%options);

    If you don't know if a string contains YAML or JSON, this method will
    use Parse::CPAN::Meta to guess. In other respects it is identical to
    load_file().

  save
      $meta->save($distmeta_file, \%options);

    Serializes the object as JSON and writes it to the given file. The only
    valid option is "version", which defaults to '2'. On Perl 5.8.1 or
    later, the file is saved with UTF-8 encoding.

    For "version" 2 (or higher), the filename should end in '.json'.
    JSON::PP is the default JSON backend. Using another JSON backend
    requires JSON 2.5 or later and you must set the $ENV{PERL_JSON_BACKEND}
    to a supported alternate backend like JSON::XS.

    For "version" less than 2, the filename should end in '.yml'.
    CPAN::Meta::Converter is used to generate an older metadata structure,
    which is serialized to YAML. CPAN::Meta::YAML is the default YAML
    backend. You may set the $ENV{PERL_YAML_BACKEND} to a supported
    alternative backend, though this is not recommended due to subtle
    incompatibilities between YAML parsers on CPAN.

  meta_spec_version
    This method returns the version part of the "meta_spec" entry in the
    distmeta structure. It is equivalent to:

      $meta->meta_spec->{version};

  effective_prereqs
      my $prereqs = $meta->effective_prereqs;

      my $prereqs = $meta->effective_prereqs( \@feature_identifiers );

    This method returns a CPAN::Meta::Prereqs object describing all the
    prereqs for the distribution. If an arrayref of feature identifiers is
    given, the prereqs for the identified features are merged together with
    the distribution's core prereqs before the CPAN::Meta::Prereqs object is
    returned.

  should_index_file
      ... if $meta->should_index_file( $filename );

    This method returns true if the given file should be indexed. It decides
    this by checking the "file" and "directory" keys in the "no_index"
    property of the distmeta structure. Note that neither the version format
    nor "release_status" are considered.

    $filename should be given in unix format.

  should_index_package
      ... if $meta->should_index_package( $package );

    This method returns true if the given package should be indexed. It
    decides this by checking the "package" and "namespace" keys in the
    "no_index" property of the distmeta structure. Note that neither the
    version format nor "release_status" are considered.

  features
      my @feature_objects = $meta->features;

    This method returns a list of CPAN::Meta::Feature objects, one for each



( run in 0.696 second using v1.01-cache-2.11-cpan-ceb78f64989 )