MetaCPAN::API::Tiny - A Tiny API client for MetaCPAN
version 1.121020
This is the Tiny version of MetaCPAN::API. It implements a compatible API with a few notable exceptions:
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.
Instead of using Try::Tiny, raw evals are used. This could potentially cause issues, so just be aware.
Test::Fatal was replaced with an eval implementation of exception(). Test::TinyMocker usage is retained, but may be absorbed since it is pure perl
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.
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.
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, }, );
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.
my $result = $mcpan->module('MetaCPAN::API');
Searches MetaCPAN and returns a module's ".pm" file.
A synonym of "module"
my $result1 = $mcpan->author('XSAWYERX'); my $result2 = $mcpan->author( pauseid => 'XSAWYERX' );
Searches MetaCPAN for a specific author.
# example lifted from MetaCPAN docs my $result = $mcpan->author( search => { q => 'profile.name:twitter', size => 1, }, );
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.
# /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.
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.
Nicholas R. Perez <nperez@cpan.org>
This software is copyright (c) 2012 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.
To install MetaCPAN::API::Tiny, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MetaCPAN::API::Tiny
CPAN shell
perl -MCPAN -e shell install MetaCPAN::API::Tiny
For more information on module installation, please visit the detailed CPAN module installation guide.