Mickey Nasriachi > MetaCPAN-Client-1.006000 > MetaCPAN::Client

Download:
MetaCPAN-Client-1.006000.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  2
View/Report Bugs
Module Version: 1.006000   Source   Latest Release: MetaCPAN-Client-1.008000

NAME ^

MetaCPAN::Client - A comprehensive, DWIM-featured client to the MetaCPAN API

VERSION ^

version 1.006000

SYNOPSIS ^

    # simple usage
    my $mcpan  = MetaCPAN::Client->new();
    my $author = $mcpan->author('XSAWYERX');
    my $dist   = $mcpan->distribuion('MetaCPAN-Client');

    # advanced usage with cache (contributed by Kent Fredric)
    use CHI;
    use WWW::Mechanize::Cached;
    use HTTP::Tiny::Mech;
    use MetaCPAN::Client;

    my $mcpan = MetaCPAN::Client->new(
      ua => HTTP::Tiny::Mech->new(
        mechua => WWW::Mechanize::Cached->new(
          cache => CHI->new(
            driver   => 'File',
            root_dir => '/tmp/metacpan-cache',
          ),
        ),
      ),
    );

    # now $mcpan caches results

DESCRIPTION ^

This is a hopefully-complete API-compliant client to MetaCPAN (https://metacpan.org) with DWIM capabilities, to make your life easier.

ATTRIBUTES ^

request

Internal attribute representing the request object making the request to MetaCPAN and analyzing the results. You probably don't want to set this, nor should you have any usage of it.

ua

If provided, MetaCPAN::Client::Request will use the user agent object instead of the default, which is HTTP::Tiny.

Then it can be used to fetch the user agent object used by MetaCPAN::Client::Request.

METHODS ^

author

    my $author = $mcpan->author('XSAWYERX');
    my $author = $mcpan->author($search_spec);

Finds an author by either its PAUSE ID or by a search spec defined by a hash reference. Since it is common to many other searches, it is explained below under SEARCH SPEC.

Return a MetaCPAN::Client::Author object on a simple search (PAUSE ID), or a MetaCPAN::Client::ResultSet object propagated with MetaCPAN::Client::Author objects on a complex (search spec based) search.

module

    my $module = $mcpan->module('MetaCPAN::Client');
    my $module = $mcpan->module($search_spec);

Finds a module by either its module name or by a search spec defined by a hash reference. Since it is common to many other searches, it is explained below under SEARCH SPEC.

Return a MetaCPAN::Client::Module object on a simple search (module name), or a MetaCPAN::Client::ResultSet object propagated with MetaCPAN::Client::Module objects on a complex (search spec based) search.

distribution

    my $dist = $mcpan->distribution('MetaCPAN-Client');
    my $dist = $mcpan->distribution($search_spec);

Finds a distribution by either its distribution name or by a search spec defined by a hash reference. Since it is common to many other searches, it is explained below under SEARCH SPEC.

Return a MetaCPAN::Client::Distribution object on a simple search (distribution name), or a MetaCPAN::Client::ResultSet object propagated with MetaCPAN::Client::Distribution objects on a complex (search spec based) search.

file

Return a MetaCPAN::Client::File object.

favorite

Return a MetaCPAN::Client::Favorite object.

rating

Return a MetaCPAN::Client::Rating object.

release

    my $release = $mcpan->release('MetaCPAN-Client');
    my $release = $mcpan->release($search_spec);

Finds a release by either its distribution name or by a search spec defined by a hash reference. Since it is common to many other searches, it is explained below under SEARCH SPEC.

Return a MetaCPAN::Client::Release object on a simple search (release name), or a MetaCPAN::Client::ResultSet object propagated with MetaCPAN::Client::Release objects on a complex (search spec based) search.

reverse_dependencies

    my $deps = $mcpan->reverse_dependencies('ElasticSearch');

all MetaCPAN::Client::Release objects of releases that are dependent on a given module, returned as MetaCPAN::Client::ResultSet.

rev_deps

Alias to reverse_dependencies described above.

recent

    my $recent = $mcpan->recent(10);
    my $recent = $mcpan->recent('today');

return the latest N releases, or all releases from today.

returns a MetaCPAN::Client::ResultSet of MetaCPAN::Client::Release.

pod

Not implemented yet.

BUILDARGS

Internal construction wrapper. Do not use.

SEARCH SPEC ^

The hash-based search spec is common to many searches. It is quite feature-rich and allows to disambiguate different types of searches.

Basic search specs just contain a hash of keys and values:

    my $author = $mcpan->author( { name => 'Micha Nasriachi' } );

    # the following is the same as ->author('MICKEY')
    my $author = $mcpan->author( { pauseid => 'MICKEY' } );

    # find all people named Dave, not covering Davids
    # will return a resultset
    my $daves = $mcpan->author( { name => 'Dave *' } );

OR

If you want to do a more complicated query that has an OR condition, such as "this or that", you can use the following syntax with the either key:

    # any author named "Dave" or "David"
    my $daves = $mcpan->author( {
        either => [
            { name => 'Dave *'  },
            { name => 'David *' },
        ]
    } );

AND

If you want to do a more complicated query that has an AND condition, such as "this and that", you can use the following syntax with the all key:

    # any users named 'John' with a Gmail account
    my $johns = $mcpan->author( {
        all => [
            { name  => 'John *'     },
            { email => '*gmail.com' },
        ]
    } );

NOT

If you want to filter out some of the results of an either/all query adding a NOT filter condition, such as "not these", you can use the following syntax with the not key:

    # any author named "Dave" or "David"
    my $daves = $mcpan->author( {
        either => [
            { name => 'Dave *'  },
            { name => 'David *' },
        ],
        not => [
            { email => '*gmail.com' },
        ],
    } );

DESIGN ^

This module has three purposes:

AUTHORS ^

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2014 by Sawyer X.

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

syntax highlighting: