Steffen Müller > Parse-CPAN-Meta-1.41_01 > Parse::CPAN::Meta

Download:
Parse-CPAN-Meta-1.41_01.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  2
Open  4
View/Report Bugs
Module Version: 1.41_01   Source   Latest Release: Parse-CPAN-Meta-1.4414

NAME ^

Parse::CPAN::Meta - Parse META.yml and other similar CPAN metadata files

SYNOPSIS ^

    #############################################
    # In your file
    
    ---
    name: My-Distribution
    version: 1.23
    resources:
      homepage: "http://example.com/dist/My-Distribution"
    
    
    #############################################
    # In your program
    
    use Parse::CPAN::Meta;
    
    my $distmeta = Parse::CPAN::Meta->load_file('META.yml');
    
    # Reading properties
    my $name     = $distmeta->{name};
    my $version  = $distmeta->{version};
    my $homepage = $distmeta->{resources}{homepage};

DESCRIPTION ^

Parse::CPAN::Meta is a parser for META.json and META.yml files, using JSON.pm and/or YAML::Tiny.

Parse::CPAN::Meta provides three methods: load_file, load_json_string, and load_yaml_string. These will read and deserialize CPAN metafiles, and are described below in detail.

Parse::CPAN::Meta provides a legacy API of only two functions, based on the YAML functions of the same name. Wherever possible, identical calling semantics are used.

All error reporting is done with exceptions (die'ing).

Note that META files are expected to be in UTF-8 encoding, only.

METHODS ^

load_file

  my $metadata_structure = Parse::CPAN::Meta->load_file('META.json');

  my $metadata_structure = Parse::CPAN::Meta->load_file('META.yml');

This method will read the named file and deserialize it to a data structure, determining whether it should be JSON or YAML based on the filename.

load_yaml_string

  my $metadata_structure = Parse::CPAN::Meta->load_yaml_string( $yaml_string);

This method deserializes the given string of YAML and returns the first document in it. (CPAN metadata files should always have only one document.)

load_json_string

  my $metadata_structure = Parse::CPAN::Meta->load_json_string( $json_string);

This method deserializes the given string of JSON and the result. If the JSON module is loaded, it will be used, otherwise, JSON::PP will be loaded and used instead.

FUNCTIONS ^

For maintenance clarity, no functions are exported. These functions are available for backwards compatibility only and are best avoided in favor of load_file.

Load

  my @yaml = Parse::CPAN::Meta::Load( $string );

Parses a string containing a valid YAML stream into a list of Perl data structures.

LoadFile

  my @yaml = Parse::CPAN::Meta::LoadFile( 'META.yml' );

Reads the YAML stream from a file instead of a string.

SUPPORT ^

Bugs should be reported via the CPAN bug tracker at

http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Parse-CPAN-Meta

AUTHOR ^

Adam Kennedy <adamk@cpan.org>

SEE ALSO ^

YAML, YAML::Syck, Config::Tiny, CSS::Tiny, http://use.perl.org/~Alias/journal/29427, http://ali.as/

COPYRIGHT ^

Copyright 2006 - 2010 Adam Kennedy.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.

syntax highlighting: