Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37769888
en ru br
Репозитории ALT

Группа :: Разработка/Perl
Пакет: perl-MetaCPAN-API

 Главная   Изменения   Спек   Патчи   Исходники   Загрузить   Gear   Bugs and FR  Repocop 

pax_global_header00006660000000000000000000000064122053751570014521gustar00rootroot0000000000000052 comment=b4b4c0be642c8f75b47c9fbe8a4e299590f4ffe7
perl-MetaCPAN-API-0.43/000075500000000000000000000000001220537515700143445ustar00rootroot00000000000000perl-MetaCPAN-API-0.43/Build.PL000064400000000000000000000017371220537515700156500ustar00rootroot00000000000000
use strict;
use warnings;

use Module::Build 0.3601;


my %module_build_args = (
"build_requires" => {
"English" => 0,
"File::Find" => 0,
"File::Temp" => 0,
"Module::Build" => "0.3601",
"Test::Fatal" => 0,
"Test::More" => 0,
"Test::TinyMocker" => 0
},
"configure_requires" => {
"ExtUtils::MakeMaker" => "6.30",
"Module::Build" => "0.3601"
},
"dist_abstract" => "A comprehensive, DWIM-featured API to MetaCPAN",
"dist_author" => [
"Sawyer X <xsawyerx\@cpan.org>"
],
"dist_name" => "MetaCPAN-API",
"dist_version" => "0.43",
"license" => "perl",
"module_name" => "MetaCPAN::API",
"recommends" => {},
"recursive_test_files" => 1,
"requires" => {
"Any::Moose" => 0,
"Carp" => 0,
"HTTP::Tiny" => 0,
"JSON" => 0,
"Try::Tiny" => 0,
"URI::Escape" => 0,
"strict" => 0,
"warnings" => 0
},
"script_files" => []
);


my $build = Module::Build->new(%module_build_args);

$build->create_build_script;
perl-MetaCPAN-API-0.43/Changes000064400000000000000000000052621220537515700156440ustar00rootroot00000000000000Revision history for MetaCPAN-API

0.43 05.04.12
* Add example in POD of advanced usage with cache by Kent Fredric.
(Gist: https://gist.github.com/1291928)
* Sort keys in param join - more predictable result.

0.42 08.01.12
* Corrected documentation in MetaCPAN::API::Source.
* Updated Dist::Zilla configuration, added more tests.

0.41 07.01.12
* Use Test::TinyMocker 0.02 syntax in tests to avoid test fails.

0.40 06.01.12
* Fixed JSON encoding so ElasticSearch won't fail.
(Christian Walde)
* Documentation fixes (Logan - logie17).

0.34 02.10.11
* Added MetaCPAN::API::Source (Renee Baecker).
* Fix of HTTP::Tiny content-type in options (Renee Baecker).
* Typo fix (Olaf Alders, reported by @doherty).

0.33 24.08.11
* No functional changes.
* Skip t::lib in dzil.

0.32 04.08.11
* Use a default agent string for requests.
* Use a default agent string for tests.

0.31 02.08.11
* URL updates (thanks to Olaf Alders, OALDERS).
* Small mismatched quote in POD example.

0.30 30.07.11
* Add POST query searches (RT #69814, GH #2).
(original code by Tim Bunce, thank you!)
* More tests.

0.20 28.07.11
* Add complex (manual) searches to author()/release() + docs.
* Add file() as a synonym to module().
* Respect content-type.
* Allow setting additional params to fetch().
* Allow "pauseid" in author via key.
* Better check for content-type.

0.11 24.07.11
* Correct the POD example and tests.
* Update to use a different API path.

0.10 24.07.11
* Almost complete rewrite.
* Make use of the new beta API.
* Remove old API support.
* Remove DWIM methods for now.
* Include lots of tests.

0.02 13.02.11
(First stable release!)
* Add docs (Sawyer X).

0.01_03 10.02.11
* Immutable base_url (Olaf Alders, Sawyer X).

0.01_02 10.02.11
* Make base_url 'rw' (Olaf Alders).
* Update module search URL (Olaf Alders).
* Refactoring using _http_req method (Sawyer X).
* Remove render_result method (Sawyer X).
* Remove unnecessary print (Sawyer X).

0.01_01 05.02.11
* Module, Dist, POD, Author and CPANRatings are supported 100%.
* Still needs more refactoring, and some methods aren't used yet.

perl-MetaCPAN-API-0.43/LICENSE000064400000000000000000000436641220537515700153660ustar00rootroot00000000000000This software is copyright (c) 2011 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.

Terms of the Perl programming language system itself

a) the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any
later version, or
b) the "Artistic License"

--- The GNU General Public License, Version 1, February 1989 ---

This software is Copyright (c) 2011 by Sawyer X.

This is free software, licensed under:

The GNU General Public License, Version 1, February 1989

GNU GENERAL PUBLIC LICENSE
Version 1, February 1989

Copyright (C) 1989 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

Preamble

The license agreements of most software companies try to keep users
at the mercy of those companies. By contrast, our General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. The
General Public License applies to the Free Software Foundation's
software and to any other program whose authors commit to using it.
You can use it for your programs, too.

When we speak of free software, we are referring to freedom, not
price. Specifically, the General Public License is designed to make
sure that you have the freedom to give away or sell copies of free
software, that you receive source code or can get it if you want it,
that you can change the software or use pieces of it in new free
programs; and that you know you can do these things.

To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.

For example, if you distribute copies of a such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must tell them their rights.

We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.

Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.

The precise terms and conditions for copying, distribution and
modification follow.

GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. This License Agreement applies to any program or other work which
contains a notice placed by the copyright holder saying it may be
distributed under the terms of this General Public License. The
"Program", below, refers to any such program or work, and a "work based
on the Program" means either the Program or any work containing the
Program or a portion of it, either verbatim or with modifications. Each
licensee is addressed as "you".

1. You may copy and distribute verbatim copies of the Program's source
code as you receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice and
disclaimer of warranty; keep intact all the notices that refer to this
General Public License and to the absence of any warranty; and give any
other recipients of the Program a copy of this General Public License
along with the Program. You may charge a fee for the physical act of
transferring a copy.

2. You may modify your copy or copies of the Program or any portion of
it, and copy and distribute such modifications under the terms of Paragraph
1 above, provided that you also do the following:

a) cause the modified files to carry prominent notices stating that
you changed the files and the date of any change; and

b) cause the whole of any work that you distribute or publish, that
in whole or in part contains the Program or any part thereof, either
with or without modifications, to be licensed at no charge to all
third parties under the terms of this General Public License (except
that you may choose to grant warranty protection to some or all
third parties, at your option).

c) If the modified program normally reads commands interactively when
run, you must cause it, when started running for such interactive use
in the simplest and most usual way, to print or display an
announcement including an appropriate copyright notice and a notice
that there is no warranty (or else, saying that you provide a
warranty) and that users may redistribute the program under these
conditions, and telling the user how to view a copy of this General
Public License.

d) You may charge a fee for the physical act of transferring a
copy, and you may at your option offer warranty protection in
exchange for a fee.

Mere aggregation of another independent work with the Program (or its
derivative) on a volume of a storage or distribution medium does not bring
the other work under the scope of these terms.

3. You may copy and distribute the Program (or a portion or derivative of
it, under Paragraph 2) in object code or executable form under the terms of
Paragraphs 1 and 2 above provided that you also do one of the following:

a) accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of
Paragraphs 1 and 2 above; or,

b) accompany it with a written offer, valid for at least three
years, to give any third party free (except for a nominal charge
for the cost of distribution) a complete machine-readable copy of the
corresponding source code, to be distributed under the terms of
Paragraphs 1 and 2 above; or,

c) accompany it with the information you received as to where the
corresponding source code may be obtained. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form alone.)

Source code for a work means the preferred form of the work for making
modifications to it. For an executable file, complete source code means
all the source code for all modules it contains; but, as a special
exception, it need not include source code for modules which are standard
libraries that accompany the operating system on which the executable
file runs, or for standard header files or definitions files that
accompany that operating system.

4. You may not copy, modify, sublicense, distribute or transfer the
Program except as expressly provided under this General Public License.
Any attempt otherwise to copy, modify, sublicense, distribute or transfer
the Program is void, and will automatically terminate your rights to use
the Program under this License. However, parties who have received
copies, or rights to use copies, from you under this General Public
License will not have their licenses terminated so long as such parties
remain in full compliance.

5. By copying, distributing or modifying the Program (or any work based
on the Program) you indicate your acceptance of this license to do so,
and all its terms and conditions.

6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the original
licensor to copy, distribute or modify the Program subject to these
terms and conditions. You may not impose any further restrictions on the
recipients' exercise of the rights granted herein.

7. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

Each version is given a distinguishing version number. If the Program
specifies a version number of the license which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
the license, you may choose any version ever published by the Free Software
Foundation.

8. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.

NO WARRANTY

9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.

10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

END OF TERMS AND CONDITIONS

Appendix: How to Apply These Terms to Your New Programs

If you develop a new program, and you want it to be of the greatest
possible use to humanity, the best way to achieve this is to make it
free software which everyone can redistribute and change under these
terms.

To do so, attach the following notices to the program. It is safest to
attach them to the start of each source file to most effectively convey
the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.

<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA


Also add information on how to contact you by electronic and paper mail.

If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:

Gnomovision version 69, Copyright (C) 19xx name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the
appropriate parts of the General Public License. Of course, the
commands you use may be called something other than `show w' and `show
c'; they could even be mouse-clicks or menu items--whatever suits your
program.

You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here a sample; alter the names:

Yoyodyne, Inc., hereby disclaims all copyright interest in the
program `Gnomovision' (a program to direct compilers to make passes
at assemblers) written by James Hacker.

<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice

That's all there is to it!


--- The Artistic License 1.0 ---

This software is Copyright (c) 2011 by Sawyer X.

This is free software, licensed under:

The Artistic License 1.0

The Artistic License

Preamble

The intent of this document is to state the conditions under which a Package
may be copied, such that the Copyright Holder maintains some semblance of
artistic control over the development of the package, while giving the users of
the package the right to use and distribute the Package in a more-or-less
customary fashion, plus the right to make reasonable modifications.

Definitions:

- "Package" refers to the collection of files distributed by the Copyright
Holder, and derivatives of that collection of files created through
textual modification.
- "Standard Version" refers to such a Package if it has not been modified,
or has been modified in accordance with the wishes of the Copyright
Holder.
- "Copyright Holder" is whoever is named in the copyright or copyrights for
the package.
- "You" is you, if you're thinking about copying or distributing this Package.
- "Reasonable copying fee" is whatever you can justify on the basis of media
cost, duplication charges, time of people involved, and so on. (You will
not be required to justify it to the Copyright Holder, but only to the
computing community at large as a market that must bear the fee.)
- "Freely Available" means that no fee is charged for the item itself, though
there may be fees involved in handling the item. It also means that
recipients of the item may redistribute it under the same conditions they
received it.

1. You may make and give away verbatim copies of the source form of the
Standard Version of this Package without restriction, provided that you
duplicate all of the original copyright notices and associated disclaimers.

2. You may apply bug fixes, portability fixes and other modifications derived
from the Public Domain or from the Copyright Holder. A Package modified in such
a way shall still be considered the Standard Version.

3. You may otherwise modify your copy of this Package in any way, provided that
you insert a prominent notice in each changed file stating how and when you
changed that file, and provided that you do at least ONE of the following:

a) place your modifications in the Public Domain or otherwise make them
Freely Available, such as by posting said modifications to Usenet or an
equivalent medium, or placing the modifications on a major archive site
such as ftp.uu.net, or by allowing the Copyright Holder to include your
modifications in the Standard Version of the Package.

b) use the modified Package only within your corporation or organization.

c) rename any non-standard executables so the names do not conflict with
standard executables, which must also be provided, and provide a separate
manual page for each non-standard executable that clearly documents how it
differs from the Standard Version.

d) make other distribution arrangements with the Copyright Holder.

4. You may distribute the programs of this Package in object code or executable
form, provided that you do at least ONE of the following:

a) distribute a Standard Version of the executables and library files,
together with instructions (in the manual page or equivalent) on where to
get the Standard Version.

b) accompany the distribution with the machine-readable source of the Package
with your modifications.

c) accompany any non-standard executables with their corresponding Standard
Version executables, giving the non-standard executables non-standard
names, and clearly documenting the differences in manual pages (or
equivalent), together with instructions on where to get the Standard
Version.

d) make other distribution arrangements with the Copyright Holder.

5. You may charge a reasonable copying fee for any distribution of this
Package. You may charge any fee you choose for support of this Package. You
may not charge a fee for this Package itself. However, you may distribute this
Package in aggregate with other (possibly commercial) programs as part of a
larger (possibly commercial) software distribution provided that you do not
advertise this Package as a product of your own.

6. The scripts and library files supplied as input to or produced as output
from the programs of this Package do not automatically fall under the copyright
of this Package, but belong to whomever generated them, and may be sold
commercially, and may be aggregated with this Package.

7. C or perl subroutines supplied by you and linked into this Package shall not
be considered part of this Package.

8. The name of the Copyright Holder may not be used to endorse or promote
products derived from this software without specific prior written permission.

9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.

The End

perl-MetaCPAN-API-0.43/MANIFEST000064400000000000000000000006761220537515700155060ustar00rootroot00000000000000Build.PL
Changes
LICENSE
MANIFEST
META.yml
Makefile.PL
README
dist.ini
lib/MetaCPAN/API.pm
lib/MetaCPAN/API/Author.pm
lib/MetaCPAN/API/Module.pm
lib/MetaCPAN/API/POD.pm
lib/MetaCPAN/API/Release.pm
lib/MetaCPAN/API/Source.pm
t/00-compile.t
t/_build_extra_params.t
t/_decode_result.t
t/author-critic.t
t/author.t
t/fetch.t
t/lib/Functions.pm
t/module.t
t/pod.t
t/post.t
t/release-pod-coverage.t
t/release-pod-syntax.t
t/release.t
t/source.t
t/ua.t
perl-MetaCPAN-API-0.43/META.yml000064400000000000000000000013511220537515700156150ustar00rootroot00000000000000---
abstract: 'A comprehensive, DWIM-featured API to MetaCPAN'
author:
- 'Sawyer X <xsawyerx@cpan.org>'
build_requires:
English: 0
File::Find: 0
File::Temp: 0
Module::Build: 0.3601
Test::Fatal: 0
Test::More: 0
Test::TinyMocker: 0
configure_requires:
ExtUtils::MakeMaker: 6.30
Module::Build: 0.3601
dynamic_config: 0
generated_by: 'Dist::Zilla version 4.300005, CPAN::Meta::Converter version 2.112150'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
name: MetaCPAN-API
requires:
Any::Moose: 0
Carp: 0
HTTP::Tiny: 0
JSON: 0
Try::Tiny: 0
URI::Escape: 0
strict: 0
warnings: 0
resources:
repository: git://github.com/xsawyerx/metacpan-api.git
version: 0.43
perl-MetaCPAN-API-0.43/Makefile.PL000064400000000000000000000025051220537515700163200ustar00rootroot00000000000000
use strict;
use warnings;



use ExtUtils::MakeMaker 6.30;



my %WriteMakefileArgs = (
"ABSTRACT" => "A comprehensive, DWIM-featured API to MetaCPAN",
"AUTHOR" => "Sawyer X <xsawyerx\@cpan.org>",
"BUILD_REQUIRES" => {
"English" => 0,
"File::Find" => 0,
"File::Temp" => 0,
"Module::Build" => "0.3601",
"Test::Fatal" => 0,
"Test::More" => 0,
"Test::TinyMocker" => 0
},
"CONFIGURE_REQUIRES" => {
"ExtUtils::MakeMaker" => "6.30",
"Module::Build" => "0.3601"
},
"DISTNAME" => "MetaCPAN-API",
"EXE_FILES" => [],
"LICENSE" => "perl",
"NAME" => "MetaCPAN::API",
"PREREQ_PM" => {
"Any::Moose" => 0,
"Carp" => 0,
"HTTP::Tiny" => 0,
"JSON" => 0,
"Try::Tiny" => 0,
"URI::Escape" => 0,
"strict" => 0,
"warnings" => 0
},
"VERSION" => "0.43",
"test" => {
"TESTS" => "t/*.t"
}
);


unless ( eval { ExtUtils::MakeMaker->VERSION(6.56) } ) {
my $br = delete $WriteMakefileArgs{BUILD_REQUIRES};
my $pp = $WriteMakefileArgs{PREREQ_PM};
for my $mod ( keys %$br ) {
if ( exists $pp->{$mod} ) {
$pp->{$mod} = $br->{$mod} if $br->{$mod} > $pp->{$mod};
}
else {
$pp->{$mod} = $br->{$mod};
}
}
}

delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
unless eval { ExtUtils::MakeMaker->VERSION(6.52) };

WriteMakefile(%WriteMakefileArgs);



perl-MetaCPAN-API-0.43/README000064400000000000000000000132331220537515700152260ustar00rootroot00000000000000NAME
MetaCPAN::API - A comprehensive, DWIM-featured API to MetaCPAN

VERSION
version 0.43

SYNOPSIS
# simple usage
my $mcpan = MetaCPAN::API->new();
my $author = $mcpan->author('XSAWYERX');
my $dist = $mcpan->release( distribution => 'MetaCPAN-API' );

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

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

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

This module has three purposes:

* Provide 100% of the beta MetaCPAN API

This module will be updated regularly on every MetaCPAN API change,
and intends to provide the user with as much of the API as possible,
no shortcuts. If it's documented in the API, you should be able to
do it.

Because of this design decision, this module has an official
MetaCPAN namespace with the blessing of the MetaCPAN developers.

Notice this module currently only provides the beta API, not the old
soon-to-be-deprecated API.

* Be lightweight, to allow flexible usage

While many modules would help make writing easier, it's important to
take into account how they affect your compile-time, run-time and
overall memory consumption.

By providing a slim interface implementation, more users are able to
use this module, such as long-running processes (like daemons), CLI
or GUI applications, cron jobs, and more.

* DWIM

While it's possible to access the methods defined by the API spec,
there's still a matter of what you're really trying to achieve. For
example, when searching for *"Dave"*, you want to find both *Dave
Cross* and *Dave Rolsky* (and any other *Dave*), but you also want
to search for a PAUSE ID of *DAVE*, if one exists.

This is where DWIM comes in. This module provides you with
additional generic methods which will try to do what they think you
want.

Of course, this does not prevent you from manually using the API
methods. You still have full control over that, if that's what you
wish.

You can (and should) read up on the generic methods, which will
explain how their DWIMish nature works, and what searches they run.

ATTRIBUTES
base_url
my $mcpan = MetaCPAN::API->new(
base_url => 'http://localhost:9999',
);

This attribute is used for REST requests. You should set it to where the
MetaCPAN is accessible. By default it's already set correctly, but if
you're running a local instance of MetaCPAN, or use a local mirror, or
tunnel it through a local port, or any of those stuff, you would want to
change this.

Default: *http://api.metacpan.org/v0*.

This attribute is read-only (immutable), meaning that once it's set on
initialize (via "new()"), you cannot change it. If you need to, create a
new instance of MetaCPAN::API. Why is it immutable? Because it's better.

ua
This attribute is used to contain the user agent used for running the
REST request to the server. It is specifically set to HTTP::Tiny, so if
you want to set it manually, make sure it's of HTTP::Tiny.

HTTP::Tiny is used as part of the philosophy of keeping it tiny.

This attribute is read-only (immutable), meaning that once it's set on
initialize (via "new()"), you cannot change it. If you need to, create a
new instance of MetaCPAN::API. Why is it immutable? Because it's better.

ua_args
my $mcpan = MetaCPAN::API->new(
ua_args => [ agent => 'MyAgent' ],
);

The arguments that will be given to the HTTP::Tiny user agent.

This attribute is read-only (immutable), meaning that once it's set on
initialize (via "new()"), you cannot change it. If you need to, create a
new instance of MetaCPAN::API. Why is it immutable? Because it's better.

The default is a user agent string: MetaCPAN::API/$version.

METHODS
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.

AUTHOR
Sawyer X <xsawyerx@cpan.org>

COPYRIGHT AND LICENSE
This software is copyright (c) 2011 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.

perl-MetaCPAN-API-0.43/dist.ini000064400000000000000000000005461220537515700160150ustar00rootroot00000000000000name = MetaCPAN-API
author = Sawyer X <xsawyerx@cpan.org>
license = Perl_5
copyright_holder = Sawyer X
copyright_year = 2011

version = 0.43

[@Basic]
[PodSyntaxTests]
[PodCoverageTests]
[Test::Perl::Critic]
[Test::Compile]

[AutoPrereqs]
skip = ^t::lib::Functions$

[ModuleBuild]
[PodWeaver]
[ReadmeFromPod]
[CheckChangeLog]
[PkgVersion]
[Repository]
perl-MetaCPAN-API-0.43/lib/000075500000000000000000000000001220537515700151125ustar00rootroot00000000000000perl-MetaCPAN-API-0.43/lib/MetaCPAN/000075500000000000000000000000001220537515700164425ustar00rootroot00000000000000perl-MetaCPAN-API-0.43/lib/MetaCPAN/API.pm000064400000000000000000000202661220537515700174170ustar00rootroot00000000000000use strict;
use warnings;
package MetaCPAN::API;
{
$MetaCPAN::API::VERSION = '0.43';
}
# ABSTRACT: A comprehensive, DWIM-featured API to MetaCPAN

use Any::Moose;

use Carp;
use JSON;
use Try::Tiny;
use HTTP::Tiny;
use URI::Escape 'uri_escape';

with qw/
MetaCPAN::API::Author
MetaCPAN::API::Module
MetaCPAN::API::POD
MetaCPAN::API::Release
MetaCPAN::API::Source
/;

has base_url => (
is => 'ro',
isa => 'Str',
default => 'http://api.metacpan.org/v0',
);

has ua => (
is => 'ro',
isa => 'HTTP::Tiny',
lazy_build => 1,
);

has ua_args => (
is => 'ro',
isa => 'ArrayRef',
default => sub {
my $version = $MetaCPAN::API::VERSION || 'xx';
return [ agent => "MetaCPAN::API/$version" ];
},
);

sub _build_ua {
my $self = shift;

return HTTP::Tiny->new( @{ $self->ua_args } );
}

sub fetch {
my $self = shift;
my $url = shift;
my $extra = $self->_build_extra_params(@_);
my $base = $self->base_url;
my $req_url = $extra ? "$base/$url?$extra" : "$base/$url";

my $result = $self->ua->get($req_url);
return $self->_decode_result( $result, $req_url );
}

sub post {
my $self = shift;
my $url = shift;
my $query = shift;
my $base = $self->base_url;

defined $url
or croak 'First argument of URL must be provided';

ref $query and ref $query eq 'HASH'
or croak 'Second argument of query hashref must be provided';

my $query_json = to_json( $query, { canonical => 1 } );
my $result = $self->ua->request(
'POST',
"$base/$url",
{
headers => { 'Content-Type' => 'application/json' },
content => $query_json,
}
);

return $self->_decode_result( $result, $url, $query_json );
}

sub _decode_result {
my $self = shift;
my ( $result, $url, $original ) = @_;
my $decoded_result;

ref $result and ref $result eq 'HASH'
or croak 'First argument must be hashref';

defined $url
or croak 'Second argument of a URL must be provided';

if ( defined ( my $success = $result->{'success'} ) ) {
my $reason = $result->{'reason'} || '';
$reason .= ( defined $original ? " (request: $original)" : '' );

$success or croak "Failed to fetch '$url': $reason";
} else {
croak 'Missing success in return value';
}

defined ( my $content = $result->{'content'} )
or croak 'Missing content in return value';

try { $decoded_result = decode_json $content }
catch { croak "Couldn't decode '$content': $_" };

return $decoded_result;
}

sub _build_extra_params {
my $self = shift;

@_ % 2 == 0
or croak 'Incorrect number of params, must be key/value';

my %extra = @_;
my $extra = join '&', map {
"$_=" . uri_escape( $extra{$_} )
} sort keys %extra;

return $extra;
}

1;



=pod

=head1 NAME

MetaCPAN::API - A comprehensive, DWIM-featured API to MetaCPAN

=head1 VERSION

version 0.43

=head1 SYNOPSIS

# simple usage
my $mcpan = MetaCPAN::API->new();
my $author = $mcpan->author('XSAWYERX');
my $dist = $mcpan->release( distribution => 'MetaCPAN-API' );

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

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

=head1 DESCRIPTION

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

This module has three purposes:

=over 4

=item * Provide 100% of the beta MetaCPAN API

This module will be updated regularly on every MetaCPAN API change, and intends
to provide the user with as much of the API as possible, no shortcuts. If it's
documented in the API, you should be able to do it.

Because of this design decision, this module has an official MetaCPAN namespace
with the blessing of the MetaCPAN developers.

Notice this module currently only provides the beta API, not the old
soon-to-be-deprecated API.

=item * Be lightweight, to allow flexible usage

While many modules would help make writing easier, it's important to take into
account how they affect your compile-time, run-time and overall memory
consumption.

By providing a slim interface implementation, more users are able to use this
module, such as long-running processes (like daemons), CLI or GUI applications,
cron jobs, and more.

=item * DWIM

While it's possible to access the methods defined by the API spec, there's still
a matter of what you're really trying to achieve. For example, when searching
for I<"Dave">, you want to find both I<Dave Cross> and I<Dave Rolsky> (and any
other I<Dave>), but you also want to search for a PAUSE ID of I<DAVE>, if one
exists.

This is where DWIM comes in. This module provides you with additional generic
methods which will try to do what they think you want.

Of course, this does not prevent you from manually using the API methods. You
still have full control over that, if that's what you wish.

You can (and should) read up on the generic methods, which will explain how
their DWIMish nature works, and what searches they run.

=back

=head1 ATTRIBUTES

=head2 base_url

my $mcpan = MetaCPAN::API->new(
base_url => 'http://localhost:9999',
);

This attribute is used for REST requests. You should set it to where the
MetaCPAN is accessible. By default it's already set correctly, but if you're
running a local instance of MetaCPAN, or use a local mirror, or tunnel it
through a local port, or any of those stuff, you would want to change this.

Default: I<http://api.metacpan.org/v0>.

This attribute is read-only (immutable), meaning that once it's set on
initialize (via C<new()>), you cannot change it. If you need to, create a
new instance of MetaCPAN::API. Why is it immutable? Because it's better.

=head2 ua

This attribute is used to contain the user agent used for running the REST
request to the server. It is specifically set to L<HTTP::Tiny>, so if you
want to set it manually, make sure it's of HTTP::Tiny.

HTTP::Tiny is used as part of the philosophy of keeping it tiny.

This attribute is read-only (immutable), meaning that once it's set on
initialize (via C<new()>), you cannot change it. If you need to, create a
new instance of MetaCPAN::API. Why is it immutable? Because it's better.

=head2 ua_args

my $mcpan = MetaCPAN::API->new(
ua_args => [ agent => 'MyAgent' ],
);

The arguments that will be given to the L<HTTP::Tiny> user agent.

This attribute is read-only (immutable), meaning that once it's set on
initialize (via C<new()>), you cannot change it. If you need to, create a
new instance of MetaCPAN::API. Why is it immutable? Because it's better.

The default is a user agent string: B<MetaCPAN::API/$version>.

=head1 METHODS

=head2 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 C<GET> parameters.

=head2 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 C<fetch()> method. It gets the path and JSON request.

=head1 AUTHOR

Sawyer X <xsawyerx@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2011 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.

=cut


__END__

perl-MetaCPAN-API-0.43/lib/MetaCPAN/API/000075500000000000000000000000001220537515700170535ustar00rootroot00000000000000perl-MetaCPAN-API-0.43/lib/MetaCPAN/API/Author.pm000064400000000000000000000035331220537515700206570ustar00rootroot00000000000000use strict;
use warnings;
package MetaCPAN::API::Author;
{
$MetaCPAN::API::Author::VERSION = '0.43';
}
# ABSTRACT: Author information for MetaCPAN::API

use Carp;
use Any::Moose 'Role';

# /author/{author}
sub author {
my $self = shift;
my ( $pause_id, $url, %extra_opts );

if ( @_ == 1 ) {
$url = 'author/' . shift;
} elsif ( @_ == 2 ) {
my %opts = @_;

if ( defined $opts{'pauseid'} ) {
$url = "author/" . $opts{'pauseid'};
} elsif ( defined $opts{'search'} ) {
my $search_opts = $opts{'search'};

ref $search_opts && ref $search_opts eq 'HASH'
or croak "'search' key must be hashref";

%extra_opts = %{$search_opts};
$url = 'author/_search';
} else {
croak 'Unknown option given';
}
} else {
croak 'Please provide an author PAUSEID or a "search"';
}

return $self->fetch( $url, %extra_opts );
}

1;



=pod

=head1 NAME

MetaCPAN::API::Author - Author information for MetaCPAN::API

=head1 VERSION

version 0.43

=head1 DESCRIPTION

This role provides MetaCPAN::API with fetching information about authors.

=head1 METHODS

=head2 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,
},
);

=head1 AUTHOR

Sawyer X <xsawyerx@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2011 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.

=cut


__END__

perl-MetaCPAN-API-0.43/lib/MetaCPAN/API/Module.pm000064400000000000000000000021761220537515700206440ustar00rootroot00000000000000use strict;
use warnings;
package MetaCPAN::API::Module;
{
$MetaCPAN::API::Module::VERSION = '0.43';
}
# ABSTRACT: Module information for MetaCPAN::API

use Carp;
use Any::Moose 'Role';

# /module/{module}
sub module {
my $self = shift;
my $name = shift;

$name or croak 'Please provide a module name';

return $self->fetch("module/$name");
}

# file() is a synonym of module
sub file { goto &module }

1;



=pod

=head1 NAME

MetaCPAN::API::Module - Module information for MetaCPAN::API

=head1 VERSION

version 0.43

=head1 DESCRIPTION

This role provides MetaCPAN::API with fetching information about modules.

More specifically, this returns the C<.pm> file of that module.

=head1 METHODS

=head2 module

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

Searches MetaCPAN and returns a module's C<.pm> file.

=head2 file

A synonym of C<module>.

=head1 AUTHOR

Sawyer X <xsawyerx@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2011 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.

=cut


__END__

perl-MetaCPAN-API-0.43/lib/MetaCPAN/API/POD.pm000064400000000000000000000040441220537515700200350ustar00rootroot00000000000000use strict;
use warnings;
package MetaCPAN::API::POD;
{
$MetaCPAN::API::POD::VERSION = '0.43';
}
# ABSTRACT: POD information for MetaCPAN::API

use Carp;
use Any::Moose 'Role';

# /pod/{module}
# /pod/{author}/{release}/{path}
sub pod {
my $self = shift;
my %opts = @_ ? @_ : ();
my $url = '';
my $error = "Either provide 'module' or 'author and 'release' and 'path'";

%opts or croak $error;

if ( defined ( my $module = $opts{'module'} ) ) {
$url = "pod/$module";
} elsif (
defined ( my $author = $opts{'author'} ) &&
defined ( my $release = $opts{'release'} ) &&
defined ( my $path = $opts{'path'} )
) {
$url = "pod/$author/$release/$path";
} else {
croak $error;
}

# check content-type
my %extra = ();
if ( defined ( my $type = $opts{'content-type'} ) ) {
$type =~ m{^ text/ (?: html|plain|x-pod|x-markdown ) $}x
or croak 'Incorrect content-type provided';

$extra{headers}{'content-type'} = $type;
}

$url = $self->base_url . "/$url";

my $result = $self->ua->get( $url, \%extra );
$result->{'success'}
or croak "Failed to fetch '$url': " . $result->{'reason'};

return $result->{'content'};
}

1;



=pod

=head1 NAME

MetaCPAN::API::POD - POD information for MetaCPAN::API

=head1 VERSION

version 0.43

=head1 DESCRIPTION

This role provides MetaCPAN::API with fetching POD information about modules
and distribution releases.

=head1 METHODS

=head2 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.

=head1 AUTHOR

Sawyer X <xsawyerx@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2011 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.

=cut


__END__

perl-MetaCPAN-API-0.43/lib/MetaCPAN/API/Release.pm000064400000000000000000000041361220537515700207750ustar00rootroot00000000000000use strict;
use warnings;
package MetaCPAN::API::Release;
{
$MetaCPAN::API::Release::VERSION = '0.43';
}
# ABSTRACT: Distribution and releases information for MetaCPAN::API

use Carp;
use Any::Moose 'Role';

# /release/{distribution}
# /release/{author}/{release}
sub release {
my $self = shift;
my %opts = @_ ? @_ : ();
my $url = '';
my $error = "Either provide 'distribution', or 'author' and 'release', " .
"or 'search'";

%opts or croak $error;

my %extra_opts = ();

if ( defined ( my $dist = $opts{'distribution'} ) ) {
$url = "release/$dist";
} elsif (
defined ( my $author = $opts{'author'} ) &&
defined ( my $release = $opts{'release'} )
) {
$url = "release/$author/$release";
} elsif ( defined ( my $search_opts = $opts{'search'} ) ) {
ref $search_opts && ref $search_opts eq 'HASH'
or croak $error;

%extra_opts = %{$search_opts};
$url = 'release/_search';
} else {
croak $error;
}

return $self->fetch( $url, %extra_opts );
}

1;



=pod

=head1 NAME

MetaCPAN::API::Release - Distribution and releases information for MetaCPAN::API

=head1 VERSION

version 0.43

=head1 DESCRIPTION

This role provides MetaCPAN::API with fetching information about distribution
and releases.

=head1 METHODS

=head2 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,
},
);

=head1 AUTHOR

Sawyer X <xsawyerx@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2011 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.

=cut


__END__

perl-MetaCPAN-API-0.43/lib/MetaCPAN/API/Source.pm000064400000000000000000000035361220537515700206600ustar00rootroot00000000000000use strict;
use warnings;
package MetaCPAN::API::Source;
{
$MetaCPAN::API::Source::VERSION = '0.43';
}
# ABSTRACT: Source information for MetaCPAN::API

use Carp;
use Any::Moose 'Role';

# /source/{author}/{release}/{path}
sub source {
my $self = shift;
my %opts = @_ ? @_ : ();
my $url = '';
my $error = "Provide 'author' and 'release' and 'path'";

%opts or croak $error;

if (
defined ( my $author = $opts{'author'} ) &&
defined ( my $release = $opts{'release'} ) &&
defined ( my $path = $opts{'path'} )
) {
$url = "source/$author/$release/$path";
} else {
croak $error;
}

$url = $self->base_url . "/$url";

my $result = $self->ua->get($url);
$result->{'success'}
or croak "Failed to fetch '$url': " . $result->{'reason'};

return $result->{'content'};
}

1;



=pod

=head1 NAME

MetaCPAN::API::Source - Source information for MetaCPAN::API

=head1 VERSION

version 0.43

=head1 DESCRIPTION

This role provides MetaCPAN::API with fetching of source files.

=head1 METHODS

=head2 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.

=head1 AUTHOR

Renee Baecker <module@renee-baecker.de>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2011 by Renee Baecker.

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

=head1 AUTHOR

Sawyer X <xsawyerx@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2011 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.

=cut


__END__

perl-MetaCPAN-API-0.43/t/000075500000000000000000000000001220537515700146075ustar00rootroot00000000000000perl-MetaCPAN-API-0.43/t/00-compile.t000064400000000000000000000031251220537515700166420ustar00rootroot00000000000000#!perl

use strict;
use warnings;

use Test::More;



use File::Find;
use File::Temp qw{ tempdir };

my @modules;
find(
sub {
return if $File::Find::name !~ /\.pm\z/;
my $found = $File::Find::name;
$found =~ s{^lib/}{};
$found =~ s{[/\\]}{::}g;
$found =~ s/\.pm$//;
# nothing to skip
push @modules, $found;
},
'lib',
);

sub _find_scripts {
my $dir = shift @_;

my @found_scripts = ();
find(
sub {
return unless -f;
my $found = $File::Find::name;
# nothing to skip
open my $FH, '<', $_ or do {
note( "Unable to open $found in ( $! ), skipping" );
return;
};
my $shebang = <$FH>;
return unless $shebang =~ /^#!.*?\bperl\b\s*$/;
push @found_scripts, $found;
},
$dir,
);

return @found_scripts;
}

my @scripts;
do { push @scripts, _find_scripts($_) if -d $_ }
for qw{ bin script scripts };

my $plan = scalar(@modules) + scalar(@scripts);
$plan ? (plan tests => $plan) : (plan skip_all => "no tests to run");

{
# fake home for cpan-testers
# no fake requested ## local $ENV{HOME} = tempdir( CLEANUP => 1 );

like( qx{ $^X -Ilib -e "require $_; print '$_ ok'" }, qr/^\s*$_ ok/s, "$_ loaded ok" )
for sort @modules;

SKIP: {
eval "use Test::Script 1.05; 1;";
skip "Test::Script needed to test script compilation", scalar(@scripts) if $@;
foreach my $file ( @scripts ) {
my $script = $file;
$script =~ s!.*/!!;
script_compiles( $file, "$script script compiles" );
}
}
}
perl-MetaCPAN-API-0.43/t/_build_extra_params.t000064400000000000000000000014171220537515700210030ustar00rootroot00000000000000#!perl

use strict;
use warnings;

use Test::More tests => 5;
use Test::Fatal;
use t::lib::Functions;

my $mcpan = mcpan();

like(
exception { $mcpan->_build_extra_params('one') },
qr/^Incorrect number of params, must be key\/value/,
'Check for key/value params',
);

my $output;
is(
exception { $output = $mcpan->_build_extra_params },
undef,
'No exception or problem on empty args',
);

is(
$output,
'',
'No output either',
);

# regular
is(
$mcpan->_build_extra_params( param1 => 'one', param2 => 'two' ),
'param1=one&param2=two',
'Basic params',
);

# throw some symbols in there
is(
$mcpan->_build_extra_params( param1 => 'one', param2 => 'two space' ),
'param1=one&param2=two%20space',
'Escaping HTML in params',
);

perl-MetaCPAN-API-0.43/t/_decode_result.t000064400000000000000000000023701220537515700177560ustar00rootroot00000000000000#!perl

use strict;
use warnings;

use Test::More tests => 8;
use Test::Fatal;
use t::lib::Functions;

my $mcpan = mcpan();
isa_ok( $mcpan, 'MetaCPAN::API' );

# parameters
like(
exception { $mcpan->_decode_result },
qr/^First argument must be hashref/,
'Fail when first argument not given',
);

like(
exception { $mcpan->_decode_result( {} ) },
qr/^Second argument of a URL must be provided/,
'Fail when second argument not given',
);

like(
exception { $mcpan->_decode_result( {}, 'url' ) },
qr/^Missing success in return value/,
'Failing when got no success key',
);

like(
exception { $mcpan->_decode_result( { success => 0 }, 'url' ) },
qr/^Failed to fetch 'url':/,
'Fail without reason',
);

like(
exception { $mcpan->_decode_result(
{ success => 0, reason => 'because' },
'url' ) },
qr/^Failed to fetch 'url': because/,
'Fail with reason when got no success',
);

is_deeply(
$mcpan->_decode_result(
{ success => 1, content => '{"test":"test"}' },
'url',
),
{ test => 'test' },
'Correct result',
);

like(
exception {
$mcpan->_decode_result( { success => 1, content => 'string' }, 'url' )
},
qr/^Couldn't decode/,
'JSON decode fail',
);

perl-MetaCPAN-API-0.43/t/author-critic.t000064400000000000000000000006661220537515700175610ustar00rootroot00000000000000#!perl

BEGIN {
unless ($ENV{AUTHOR_TESTING}) {
require Test::More;
Test::More::plan(skip_all => 'these tests are for testing by the author');
}
}


use strict;
use warnings;

use Test::More;
use English qw(-no_match_vars);

eval "use Test::Perl::Critic";
plan skip_all => 'Test::Perl::Critic required to criticise code' if $@;
Test::Perl::Critic->import( -profile => "perlcritic.rc" ) if -e "perlcritic.rc";
all_critic_ok();
perl-MetaCPAN-API-0.43/t/author.t000064400000000000000000000006241220537515700163000ustar00rootroot00000000000000#!/usr/bin/perl
use strict;
use warnings;

use Test::More tests => 4;
use Test::Fatal;
use t::lib::Functions;

my $mcpan = mcpan();

isa_ok( $mcpan, 'MetaCPAN::API' );
can_ok( $mcpan, 'author' );

# missing input
like(
exception { $mcpan->author },
qr/^Please provide an author PAUSEID/,
'Missing any information',
);

my $result = $mcpan->author('DOY');
ok( $result, 'Got result' );

perl-MetaCPAN-API-0.43/t/fetch.t000064400000000000000000000022631220537515700160700ustar00rootroot00000000000000#!perl

use strict;
use warnings;

use Test::More tests => 7;
use Test::Fatal;
use Test::TinyMocker;
use t::lib::Functions;

my $mcpan = mcpan();
isa_ok( $mcpan, 'MetaCPAN::API' );

my $url = 'release/distribution/hello';
my $flag = 0;

mock 'HTTP::Tiny'
=> method 'get'
=> should {
my $self = shift;
isa_ok( $self, 'HTTP::Tiny' );
is( $_[0], $mcpan->base_url . "/$url", 'Correct URL' );

$flag++ == 0 and return {
success => 1,
content => '{"test":"test"}',
};

$flag++ == 2 and return {
success => 1,
};

return {
success => 1,
content => 'string',
};
};

my $result = $mcpan->fetch($url);
is_deeply( $result, { test => 'test' }, 'Correct result' );

mock 'HTTP::Tiny'
=> method 'get'
=> should {
my $self = shift;
isa_ok( $self, 'HTTP::Tiny' );
is( $_[0], $mcpan->base_url . '/?test=it', 'Correct URL' );

return {
success => 1,
content => '{"content":"ok"}',
};
};

is_deeply(
$mcpan->fetch( '', test => 'it' ),
{ content => 'ok' },
'Sending params work right',
);

perl-MetaCPAN-API-0.43/t/lib/000075500000000000000000000000001220537515700153555ustar00rootroot00000000000000perl-MetaCPAN-API-0.43/t/lib/Functions.pm000064400000000000000000000003301220537515700176570ustar00rootroot00000000000000use strict;
use warnings;
use MetaCPAN::API;

my $version = $MetaCPAN::API::VERSION || 'xx';

sub mcpan {
return MetaCPAN::API->new(
ua_args => [ agent => "MetaCPAN::API-testing/$version" ],
);
}

1;
perl-MetaCPAN-API-0.43/t/module.t000064400000000000000000000006221220537515700162610ustar00rootroot00000000000000#!/usr/bin/perl
use strict;
use warnings;

use Test::More tests => 4;
use Test::Fatal;
use t::lib::Functions;

my $mcpan = mcpan();

isa_ok( $mcpan, 'MetaCPAN::API' );
can_ok( $mcpan, 'module' );

# missing input
like(
exception { $mcpan->module },
qr/^Please provide a module name/,
'Missing any information',
);

my $result = $mcpan->module('Moose');
ok( $result, 'Got result' );

perl-MetaCPAN-API-0.43/t/pod.t000064400000000000000000000022431220537515700155570ustar00rootroot00000000000000#!/usr/bin/perl
use strict;
use warnings;

use Test::More tests => 11;
use Test::Fatal;
use t::lib::Functions;

my $mcpan = mcpan();

isa_ok( $mcpan, 'MetaCPAN::API' );
can_ok( $mcpan, 'pod' );
my $errmsg = qr/^Either provide 'module' or 'author and 'release' and 'path'/;

# missing input
like(
exception { $mcpan->pod },
$errmsg,
'Missing any information',
);

# incorrect input
like(
exception { $mcpan->pod( ding => 'dong' ) },
$errmsg,
'Incorrect input',
);

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

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

# failing content types
like(
exception {
$mcpan->pod( module => 'Moose', 'content-type' => 'text/text' )
},
qr/^Incorrect content-type provided/,
'Incorrect content-type',
);

# successful content types
my @types = qw( text/html text/plain text/x-pod text/x-markdown );
foreach my $type (@types) {
is(
exception { $mcpan->pod( module => 'Moose', 'content-type' => $type ) },
undef, # no exception
'Correct content-type',
);
}

perl-MetaCPAN-API-0.43/t/post.t000064400000000000000000000035411220537515700157640ustar00rootroot00000000000000#!perl

use strict;
use warnings;

use Test::More tests => 13;
use Test::Fatal;
use Test::TinyMocker;
use t::lib::Functions;

my $mcpan = mcpan();
isa_ok( $mcpan, 'MetaCPAN::API' );

like(
exception { $mcpan->post() },
qr/^First argument of URL must be provided/,
'Missing arguments',
);

like(
exception { $mcpan->post( 'release' ) },
qr/^Second argument of query hashref must be provided/,
'Missing second argument',
);

like(
exception { $mcpan->post( 'release', 'bad query' ) },
qr/^Second argument of query hashref must be provided/,
'Incorrect second argument',
);

my $url = 'release/dist';
my $flag = 0;

mock 'HTTP::Tiny'
=> method 'request'
=> should {
my $self = shift;
my @args = @_;

isa_ok( $self, 'HTTP::Tiny' );
is( $args[0], 'POST', 'Correct request type' );
is(
$args[1],
$mcpan->base_url . "/$url",
'Correct URL',
);

if ( $flag++ == 0 ) {
is_deeply(
$args[2],
{
headers => { 'Content-Type' => 'application/json' },
content => '{}',
},
'Correct request hash without content',
);
}

if ( $flag++ == 2 ) {
is_deeply(
$args[2],
{
headers => { 'Content-Type' => 'application/json' },
content => '{"useful":"query"}',
},
'Correct request hash with content',
);
}

return { success => 1, content => '{}' };
};

is(
exception { $mcpan->post( $url, {} ) },
undef,
'Correct arguments are successful',
);

is(
exception { $mcpan->post( $url, { useful => 'query' } ) },
undef,
'Correct and useful arguments are successful',
);

perl-MetaCPAN-API-0.43/t/release-pod-coverage.t000064400000000000000000000007651220537515700207750ustar00rootroot00000000000000#!perl

BEGIN {
unless ($ENV{RELEASE_TESTING}) {
require Test::More;
Test::More::plan(skip_all => 'these tests are for release candidate testing');
}
}


use Test::More;

eval "use Test::Pod::Coverage 1.08";
plan skip_all => "Test::Pod::Coverage 1.08 required for testing POD coverage"
if $@;

eval "use Pod::Coverage::TrustPod";
plan skip_all => "Pod::Coverage::TrustPod required for testing POD coverage"
if $@;

all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' });
perl-MetaCPAN-API-0.43/t/release-pod-syntax.t000064400000000000000000000004501220537515700205170ustar00rootroot00000000000000#!perl

BEGIN {
unless ($ENV{RELEASE_TESTING}) {
require Test::More;
Test::More::plan(skip_all => 'these tests are for release candidate testing');
}
}

use Test::More;

eval "use Test::Pod 1.41";
plan skip_all => "Test::Pod 1.41 required for testing POD" if $@;

all_pod_files_ok();
perl-MetaCPAN-API-0.43/t/release.t000064400000000000000000000013051220537515700164130ustar00rootroot00000000000000#!/usr/bin/perl
use strict;
use warnings;

use Test::More tests => 6;
use Test::Fatal;
use t::lib::Functions;

my $mcpan = mcpan();

isa_ok( $mcpan, 'MetaCPAN::API' );
can_ok( $mcpan, 'release' );
my $errmsg = qr/^Either provide 'distribution', or 'author' and 'release', or 'search'/;

# missing input
like(
exception { $mcpan->release },
$errmsg,
'Missing any information',
);

# incorrect input
like(
exception { $mcpan->release( ding => 'dong' ) },
$errmsg,
'Incorrect input',
);

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

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

ok( $result, 'Got result' );
perl-MetaCPAN-API-0.43/t/source.t000064400000000000000000000011531220537515700162740ustar00rootroot00000000000000#!/usr/bin/perl
use strict;
use warnings;

use Test::More tests => 5;
use Test::Fatal;
use t::lib::Functions;

my $mcpan = mcpan();

isa_ok( $mcpan, 'MetaCPAN::API' );
can_ok( $mcpan, 'source' );
my $errmsg = qr/^Provide 'author' and 'release' and 'path'/;

# missing input
like(
exception { $mcpan->source },
$errmsg,
'Missing any information',
);

# incorrect input
like(
exception { $mcpan->source( ding => 'dong' ) },
$errmsg,
'Incorrect input',
);

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

perl-MetaCPAN-API-0.43/t/ua.t000064400000000000000000000006001220537515700153750ustar00rootroot00000000000000#!perl

use strict;
use warnings;

use Test::More tests => 3;
use MetaCPAN::API;

{
my $mcpan = MetaCPAN::API->new;
isa_ok( $mcpan->ua, 'HTTP::Tiny' );
}

{
my $mcpan = MetaCPAN::API->new(
ua_args => [ agent => 'MyAgentMon' ],
);

my $ua = $mcpan->ua;
isa_ok( $ua, 'HTTP::Tiny' );
is( $ua->agent, 'MyAgentMon', 'Correct user agent arguments' );
}

 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin