++ed by:
SHARYANTO

1 PAUSE user(s)
1 non-PAUSE user(s).

Nicholas Perez

NAME

MetaCPAN::API::Tiny - A Tiny API client for MetaCPAN

VERSION

version 1.131730

DESCRIPTION

This is the Tiny version of MetaCPAN::API. It implements a compatible API with a few notable exceptions:

Attributes are direct hash access

The attributes defined using Mo(o|u)se are now accessed via the blessed hash directly. There are no accessors defined to access this elements.

Exception handling

Instead of using Try::Tiny, raw evals are used. This could potentially cause issues, so just be aware.

Testing

Test::Fatal was replaced with an eval implementation of exception(). Test::TinyMocker usage is retained, but may be absorbed since it is pure perl

CLASS_METHODS

new

new is the constructor for MetaCPAN::API::Tiny. In the non-tiny version of this module, this is provided via Any::Moose built from the attributes defined. In the tiny version, we define our own constructor. It takes the same arguments and provides similar checks to MetaCPAN::API with regards to arguments passed.

PUBLIC_METHODS

source

    my $source = $mcpan->source(
        author  => 'DOY',
        release => 'Moose-2.0201',
        path    => 'lib/Moose.pm',
    );

Searches MetaCPAN for a module or a specific release and returns the plain source.

release

    my $result = $mcpan->release( distribution => 'Moose' );

    # or
    my $result = $mcpan->release( author => 'DOY', release => 'Moose-2.0001' );

Searches MetaCPAN for a dist.

You can do complex searches using 'search' parameter:

    # example lifted from MetaCPAN docs
    my $result = $mcpan->release(
        search => {
            author => "OALDERS AND ",
            filter => "status:latest",
            fields => "name",
            size   => 1,
        },
    );

pod

    my $result = $mcpan->pod( module => 'Moose' );

    # or
    my $result = $mcpan->pod(
        author  => 'DOY',
        release => 'Moose-2.0201',
        path    => 'lib/Moose.pm',
    );

Searches MetaCPAN for a module or a specific release and returns the POD.

module

    my $result = $mcpan->module('MetaCPAN::API');

Searches MetaCPAN and returns a module's ".pm" file.

file

A synonym of "module"

author

    my $result1 = $mcpan->author('XSAWYERX');
    my $result2 = $mcpan->author( pauseid => 'XSAWYERX' );

Searches MetaCPAN for a specific author.

You can do complex searches using 'search' parameter:

    # example lifted from MetaCPAN docs
    my $result = $mcpan->author(
        search => {
            q    => 'profile.name:twitter',
            size => 1,
        },
    );

fetch

    my $result = $mcpan->fetch('/release/distribution/Moose');

    # with parameters
    my $more = $mcpan->fetch(
        '/release/distribution/Moose',
        param => 'value',
    );

This is a helper method for API implementations. It fetches a path from MetaCPAN, decodes the JSON from the content variable and returns it.

You don't really need to use it, but you can in case you want to write your own extension implementation to MetaCPAN::API.

It accepts an additional hash as "GET" parameters.

post

    # /release&content={"query":{"match_all":{}},"filter":{"prefix":{"archive":"Cache-Cache-1.06"}}}
    my $result = $mcpan->post(
        'release',
        {   
            query  => { match_all => {} },
            filter => { prefix => { archive => 'Cache-Cache-1.06' } },
        },
    );

The POST equivalent of the "fetch()" method. It gets the path and JSON request.

THANKS

Overall the tests and code were ripped directly from MetaCPAN::API and tiny-fied. A big thanks to Sawyer X for writing the original module.

AUTHOR

Nicholas R. Perez <nperez@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Nicholas R. Perez <nperez@cpan.org>.

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




Hosting generously
sponsored by Bytemark