Package-Locator-0.010/000755 000765 000765 00000000000 12205752364 014354 5ustar00jeffjeff000000 000000 Package-Locator-0.010/Build.PL000644 000765 000765 00000002766 12205752364 015663 0ustar00jeffjeff000000 000000 use strict; use warnings; use Module::Build 0.3601; my %module_build_args = ( "build_requires" => { "Module::Build" => "0.3601" }, "configure_requires" => { "Module::Build" => "0.3601" }, "dist_abstract" => "Find a package among CPAN-like repositories", "dist_author" => [ "Jeffrey Ryan Thalhammer " ], "dist_name" => "Package-Locator", "dist_version" => "0.010", "license" => "perl", "module_name" => "Package::Locator", "recommends" => {}, "recursive_test_files" => 1, "requires" => { "CPAN::DistnameInfo" => 0, "Carp" => 0, "File::Temp" => 0, "IO::Zlib" => 0, "LWP::UserAgent" => 0, "Moose" => 0, "MooseX::MarkAsMethods" => 0, "MooseX::Types::Path::Class" => 0, "MooseX::Types::URI" => 0, "Path::Class" => 0, "URI" => 0, "URI::Escape" => 0, "perl" => "5.006", "version" => 0 }, "script_files" => [], "test_requires" => { "File::Find" => 0, "FindBin" => 0, "Test::Exception" => 0, "Test::More" => 0, "strict" => 0, "warnings" => 0 } ); unless ( eval { Module::Build->VERSION(0.4004) } ) { my $tr = delete $module_build_args{test_requires}; my $br = $module_build_args{build_requires}; for my $mod ( keys %$tr ) { if ( exists $br->{$mod} ) { $br->{$mod} = $tr->{$mod} if $tr->{$mod} > $br->{$mod}; } else { $br->{$mod} = $tr->{$mod}; } } } my $build = Module::Build->new(%module_build_args); $build->create_build_script; Package-Locator-0.010/Changes000644 000765 000765 00000003606 12205752364 015654 0ustar00jeffjeff000000 000000 0.010 2013-08-23 14:32:30 America/Los_Angeles Use proxy settings from the environment, if available. 0.009 2013-06-06 19:23:13 America/Los_Angeles Fixed some test failures reported by CPAN Testers. But no code changes in the library itself. 0.008 2013-06-06 14:04:54 America/Los_Angeles Also use IO::Zlib instead of PerlIO::gzip during tests. 0.007 2013-06-05 22:18:56 America/Los_Angeles Now uses IO::Zlib instead of PerlIO::gzip so there is one less non-core dependency. 0.006 2012-05-04 16:00:24 America/Los_Angeles Added clear_cache() method on the Package::Locator class. This deletes the cached index files, causing subsequent calls to locate() to fetch the index files anew. When calling locate() with a distribution path, we actually try and fetch the corresponding URL at each repository. This allows you to find distributions that are not in the index (i.e. older relases). 0.004 2011-12-02 03:12:06 America/Los_Angeles Package::Locator::Index does its own parsing of the index file now, and can return the contents as a simple data structure. Yes, I reinvented that wheel. I have my reasons. The locate() method now uses named arguments. The old positional argument interface is not supported. The "get_latest" attribute is gone. Instead, you can specify a "latest" argument to the locate() method. Fixed some failing tests. Thanks CPANTESTERS. 0.003 2011-11-23 14:02:56 America/Los_Angeles Fixed bug that inadvertenty swallowed all exceptions when calling the locate() method. Now requires Try::Tiny. 0.002 2011-11-21 21:50:22 America/Los_Angeles Found a bunch of bugs by writing test cases. The first release didn't really work as advertised. This one actually has a chance. 0.001 2011-11-21 15:32:09 America/Los_Angeles Initial release. Package-Locator-0.010/dist.ini000644 000765 000765 00000005744 12205752364 016032 0ustar00jeffjeff000000 000000 name = Package-Locator main_module = lib/Package/Locator.pm author = Jeffrey Ryan Thalhammer license = Perl_5 copyright_holder = Imaginative Software Systems copyright_year = 2011 version = 0.010 [GatherDir] ; everything under top dir [PruneCruft] ; default stuff to skip [ManifestSkip] ; if -f MANIFEST.SKIP, skip those, too ; file modifications [OurPkgVersion] ; add $VERSION = ... to all files [PodWeaver] ; generate Pod ; generated files [License] ; boilerplate license [ReadmeFromPod] ; from Pod (runs after PodWeaver) ; t tests [Test::Compile] ; make sure .pm files all compile fake_home = 1 ; fakes $ENV{HOME} just in case ; xt tests [MetaTests] ; xt/release/meta-yaml.t [PodSyntaxTests] ; xt/release/pod-syntax.t [PodCoverageTests] ; xt/release/pod-coverage.t [Test::Version] ; xt/release/test-version.t [Test::Perl::Critic] ; xt/author/critic.t critic_config = perlcritic.ini [Test::PodSpelling] ; xt/release/pod-spell.t spell_cmd = aspell list stopwords = VCS stopwords = PASSed stopwords = BackPAN stopwords = DarkPAN ; metadata [AutoPrereqs] ; find prereqs from code [Prereqs] ; prereqs that aren't findable [MinimumPerl] ; determine minimum perl version [GitHub::Meta] ; add Github links [MetaNoIndex] ; sets 'no_index' in META directory = t directory = xt directory = examples directory = corpus [MetaProvides::Package] ; add 'provides' to META files meta_noindex = 1 ; respect prior no_index directives [MetaYAML] ; generate META.yml (v1.4) [MetaJSON] ; generate META.json (v2) ; build system [ExecDir] ; include 'bin/*' as executables [ShareDir] ; include 'share/' for File::ShareDir [ModuleBuild] ; create Build.PL ; INSTALL file [InstallGuide] ; must come after making Build.PL and/or Makefile.PL ; manifest (after all generated files) [Manifest] ; create MANIFEST ; before release [Git::Check] ; ensure all files checked in [CheckPrereqsIndexed] ; ensure prereqs are on CPAN [CheckChangesHasContent] ; ensure Changes has been updated [CheckExtraTests] ; ensure xt/ tests pass [TestRelease] ; ensure t/ tests pass [ConfirmRelease] ; prompt before uploading ; releaser [UploadToCPAN] ; uploads to CPAN ; after release [Git::Commit / Commit_Dirty_Files] ; commit Changes (as released) [Git::Tag] ; tag repo with custom tag tag_format = release-%v ; NextRelease acts *during* pre-release to write $VERSION and ; timestamp to Changes and *after* release to add a new {{$NEXT}} ; section, so to act at the right time after release, it must actually ; come after Commit_Dirty_Files but before Commit_Changes in the ; dist.ini. It will still act during pre-release as usual [NextRelease] [Git::Commit / Commit_Changes] ; commit Changes (for new dev) [Git::Push] ; push repo to remote push_to = origin Package-Locator-0.010/examples/000755 000765 000765 00000000000 12205752364 016172 5ustar00jeffjeff000000 000000 Package-Locator-0.010/INSTALL000644 000765 000765 00000001730 12205752364 015406 0ustar00jeffjeff000000 000000 This is the Perl distribution Package-Locator. Installing Package-Locator is straightforward. ## Installation with cpanm If you have cpanm, you only need one line: % cpanm Package::Locator If you are installing into a system-wide directory, you may need to pass the "-S" flag to cpanm, which uses sudo to install the module: % cpanm -S Package::Locator ## Installing with the CPAN shell Alternatively, if your CPAN shell is set up, you should just be able to do: % cpan Package::Locator ## Manual installation As a last resort, you can manually install it. Download the tarball, untar it, then build it: % perl Build.PL % ./Build && ./Build test Then install it: % ./Build install If you are installing into a system-wide directory, you may need to run: % sudo ./Build install ## Documentation Package-Locator documentation is available as POD. You can run perldoc from a shell to read the documentation: % perldoc Package::Locator Package-Locator-0.010/lib/000755 000765 000765 00000000000 12205752364 015122 5ustar00jeffjeff000000 000000 Package-Locator-0.010/LICENSE000644 000765 000765 00000043733 12205752364 015373 0ustar00jeffjeff000000 000000 This software is copyright (c) 2011 by Imaginative Software Systems. 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 Imaginative Software Systems. 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, Suite 500, Boston, MA 02110-1335 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. Copyright (C) 19yy 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. , 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 Imaginative Software Systems. 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 Package-Locator-0.010/MANIFEST000644 000765 000765 00000000762 12205752364 015512 0ustar00jeffjeff000000 000000 Build.PL Changes INSTALL LICENSE MANIFEST META.json META.yml README dist.ini examples/pkg-locate lib/Package/Locator.pm lib/Package/Locator/Index.pm perlcritic.ini t/00-compile.t t/02-functional.t t/03-exceptions.t t/04-cache.t t/05-cache-clear.t t/06-index.t t/repos/a/modules/02packages.details.txt.gz t/repos/b/modules/02packages.details.txt.gz weaver.ini xt/author/critic.t xt/author/pod-spell.t xt/release/distmeta.t xt/release/pod-coverage.t xt/release/pod-syntax.t xt/release/test-version.t Package-Locator-0.010/META.json000644 000765 000765 00000004577 12205752364 016012 0ustar00jeffjeff000000 000000 { "abstract" : "Find a package among CPAN-like repositories", "author" : [ "Jeffrey Ryan Thalhammer " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 4.300035, CPAN::Meta::Converter version 2.130880", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Package-Locator", "no_index" : { "directory" : [ "t", "xt", "examples", "corpus" ] }, "prereqs" : { "build" : { "requires" : { "Module::Build" : "0.3601" } }, "configure" : { "requires" : { "Module::Build" : "0.3601" } }, "develop" : { "requires" : { "Pod::Coverage::TrustPod" : "0", "Test::CPAN::Meta" : "0", "Test::Pod" : "1.41", "Test::Pod::Coverage" : "1.08" } }, "runtime" : { "requires" : { "CPAN::DistnameInfo" : "0", "Carp" : "0", "File::Temp" : "0", "IO::Zlib" : "0", "LWP::UserAgent" : "0", "Moose" : "0", "MooseX::MarkAsMethods" : "0", "MooseX::Types::Path::Class" : "0", "MooseX::Types::URI" : "0", "Path::Class" : "0", "URI" : "0", "URI::Escape" : "0", "perl" : "5.006", "version" : "0" } }, "test" : { "requires" : { "File::Find" : "0", "FindBin" : "0", "Test::Exception" : "0", "Test::More" : "0", "strict" : "0", "warnings" : "0" } } }, "provides" : { "Package::Locator" : { "file" : "lib/Package/Locator.pm", "version" : "0.010" }, "Package::Locator::Index" : { "file" : "lib/Package/Locator/Index.pm", "version" : "0.010" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/thaljef/Package-Locator/issues" }, "repository" : { "type" : "git", "url" : "git://github.com/thaljef/Package-Locator.git", "web" : "https://github.com/thaljef/Package-Locator" } }, "version" : "0.010" } Package-Locator-0.010/META.yml000644 000765 000765 00000002230 12205752364 015622 0ustar00jeffjeff000000 000000 --- abstract: 'Find a package among CPAN-like repositories' author: - 'Jeffrey Ryan Thalhammer ' build_requires: File::Find: 0 FindBin: 0 Module::Build: 0.3601 Test::Exception: 0 Test::More: 0 strict: 0 warnings: 0 configure_requires: Module::Build: 0.3601 dynamic_config: 0 generated_by: 'Dist::Zilla version 4.300035, CPAN::Meta::Converter version 2.130880' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Package-Locator no_index: directory: - t - xt - examples - corpus provides: Package::Locator: file: lib/Package/Locator.pm version: 0.010 Package::Locator::Index: file: lib/Package/Locator/Index.pm version: 0.010 requires: CPAN::DistnameInfo: 0 Carp: 0 File::Temp: 0 IO::Zlib: 0 LWP::UserAgent: 0 Moose: 0 MooseX::MarkAsMethods: 0 MooseX::Types::Path::Class: 0 MooseX::Types::URI: 0 Path::Class: 0 URI: 0 URI::Escape: 0 perl: 5.006 version: 0 resources: bugtracker: https://github.com/thaljef/Package-Locator/issues repository: git://github.com/thaljef/Package-Locator.git version: 0.010 Package-Locator-0.010/perlcritic.ini000644 000765 000765 00000000676 12205752364 017226 0ustar00jeffjeff000000 000000 severity = 3 ; This tends to run afoul of Moose classes [-Subroutines::ProhibitUnusedPrivateSubroutines] ; I prefer my own hand-made formatting [-CodeLayout::RequireTidyCode] ; But this makes my POD so ugly! [-Documentation::RequirePodLinksIncludeText] ; Moose::Autobox tends to create long chains [-ValuesAndExpressions::ProhibitLongChainsOfMethodCalls] [Subroutines::RequireFinalReturn] terminal_funcs = pod2usage throw_error throw_fatal Package-Locator-0.010/README000644 000765 000765 00000017324 12205752364 015243 0ustar00jeffjeff000000 000000 NAME Package::Locator - Find a package among CPAN-like repositories VERSION version 0.010 SYNOPSIS use Package::Locator; # Basic search... my $locator = Package::Locator->new(); my $url = locator->locate( package => 'Test::More' ); # Search for first within multiple repositories: my $repos = [ qw(http://cpan.pair.com http://my.company.com/DPAN) ]; my $locator = Package::Locator->new( repository_urls => $repos ); my $url = locator->locate( package => 'Test::More' ); # Search for first where version >= 0.34: my $repos = [ qw(http://cpan.pair.com http://my.company.com/DPAN) ]; my $locator = Package::Locator->new( repository_urls => $repos ); my $url = locator->locate( package => 'Test::More' version => 0.34); # Search for latest where version >= 0.34: my $repos = [ qw(http://cpan.pair.com http://my.company.com/DPAN) ]; my $locator = Package::Locator->new( repository_urls => $repos ); my $url = locator->locate( package => 'Test::More' version => 0.34, latest => 1); # Search for specific dist on multiple repositories...: my $repos = [ qw(http://cpan.pair.com http://my.company.com/DPAN) ]; my $locator = Package::Locator->new( repository_urls => $repos ); my $url = locator->locate( distribution => 'A/AU/AUTHOR/Foo-1.0.tar.gz'); DESCRIPTION Package::Locator attempts to answer the question: "Where can I find a distribution that will provide this package?" The answer is divined by searching the indexes for one or more CPAN-like repositories. If you also provide a specific version number, Package::Locator will attempt to find a distribution with that version of the package, or higher. You can also ask to find the latest version of a package across all the indexes. Package::Locator only looks at the index files for each repository, and those indexes only contain information about the latest versions of the packages within that repository. So Package::Locator is not BackPAN magic -- you cannot use it to find precisely which distribution a particular package (or file) came from. For that stuff, see "/See Also". CONSTRUCTOR new( %attributes ) All the attributes listed below can be passed to the constructor, and retrieved via accessor methods with the same name. All attributes are read-only, and cannot be changed once the object is constructed. ATTRIBUTES repository_urls => [ qw(http://somewhere http://somewhere.else) ] An array reference containing the base URLs of the repositories you want to search. These are usually CPAN mirrors, but can be any website or local directory that is organized in a CPAN-like structure. For each request, repositories are searched in the order you specified them here. This defaults to http://cpan.perl.org. user_agent => $user_agent_obj The LWP::UserAgent object that will fetch index files. If you do not provide a user agent, then a default one will be constructed for you. cache_dir => '/some/directory/path' The path (as a string or Path::Class::Dir object) to a directory where the index file will be cached. If the directory does not exist, it will be created for you. If you do not specify a cache directory, then a temporary directory will be used. The temporary directory will be deleted when your application terminates. force => $boolean Causes any cached index files to be removed, thus forcing a new one to be downloaded when the object is constructed. This only has effect if you specified the "cache_dir" attribute. The default is false. METHODS indexes() Returns a list of Package::Locator::Index objects representing the indexes of each of the repositories. The indexes are only populated on-demand when the "locate" method is called. The order of the indexes is the same as the order of the repositories defined by the "repository_urls" attribute. locate( package => 'Foo::Bar' ) locate( package => 'Foo::Bar', latest => 1 ) locate( package => 'Foo::Bar', version => '1.2') locate( package => 'Foo::Bar', version => '1.2', latest => 1 ) locate ( distribution => 'A/AU/AUTHOR/Foo-Bar-1.0.tar.gz' ) Given the name of a package, searches all the repository indexes and returns the URL to a distribution containing that requested package, or the distribution you requested. If you also specify a "version", then you'll always get a distribution that contains that version of the package or higher. If you also specify "latest" then you'll always get the distribution that contains the latest version of the package that can be found in all the indexes. Otherwise you'll just get the first distribution we can find that satisfies your request. If you give a distribution path instead, then you'll just get back the URL to the first distribution we find at that path in any of the repository indexes. If neither the package nor the distribution path can be found in any of the indexes, returns undef. clear_cache() Deletes the cached index files. Any subsequent calls to the "locate" method will cause the index files to be fetched anew. MOTIVATION The CPAN module also provides a mechanism for locating packages or distributions, much like Package::Locator does. However, CPAN assumes that all repositories are CPAN mirrors, so it only searches the first repository that it can contact. My secret ambition is to fill the world with lots of DarkPAN repositories -- each with its own set of distributions. For that scenario, I need to search multiple repositories at the same time. SEE ALSO If you need to locate a distribution that contains a precise version of a file rather than just a version that is "new enough", then look at some of these: Dist::Surveyor BackPAN::Index BackPAN::Version::Discover SUPPORT Perldoc You can find documentation for this module with the perldoc command. perldoc Package::Locator Websites The following websites have more information about this module, and may be of help to you. As always, in addition to those websites please use your favorite search engine to discover more resources. * Search CPAN The default CPAN search engine, useful to view POD in HTML format. * CPAN Ratings The CPAN Ratings is a website that allows community ratings and reviews of Perl modules. * CPAN Testers The CPAN Testers is a network of smokers who run automated tests on uploaded CPAN distributions. * CPAN Testers Matrix The CPAN Testers Matrix is a website that provides a visual overview of the test results for a distribution on various Perls/platforms. * CPAN Testers Dependencies The CPAN Testers Dependencies is a website that shows a chart of the test results of all dependencies for a distribution. Bugs / Feature Requests Source Code git clone git://github.com/thaljef/Package-Locator.git AUTHOR Jeffrey Ryan Thalhammer COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Imaginative Software Systems. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Package-Locator-0.010/t/000755 000765 000765 00000000000 12205752364 014617 5ustar00jeffjeff000000 000000 Package-Locator-0.010/weaver.ini000644 000765 000765 00000001462 12205752364 016351 0ustar00jeffjeff000000 000000 [@CorePrep] ; [@Default] [Name] ; [@Default] [Version] ; [@Default] [Generic / SYNOPSIS] ; [@Default] [Generic / DESCRIPTION] ; [@Default] [Generic / CONSTRUCTOR] ; [@Default] [Collect / ATTRIBUTES] ; [@Default] command = attr [Collect / METHODS] ; [@Default] command = method [Collect / FUNCTIONS] ; [@Default] command = func [Leftovers] ; [@Default] [Support] repository_content = repository_link = both websites = search, ratings, testers, testmatrix, deps bugs_content = {WEB} bugs = metadata [Authors] ; [@Default] [Legal] ; [@Default] ;[-Transformer] ; enable =for :list ;transformer = List [-StopWords] ; generate some stopwords and gather them together Package-Locator-0.010/xt/000755 000765 000765 00000000000 12205752364 015007 5ustar00jeffjeff000000 000000 Package-Locator-0.010/xt/author/000755 000765 000765 00000000000 12205752364 016311 5ustar00jeffjeff000000 000000 Package-Locator-0.010/xt/release/000755 000765 000765 00000000000 12205752364 016427 5ustar00jeffjeff000000 000000 Package-Locator-0.010/xt/release/distmeta.t000644 000765 000765 00000000217 12205752364 020426 0ustar00jeffjeff000000 000000 #!perl use Test::More; eval "use Test::CPAN::Meta"; plan skip_all => "Test::CPAN::Meta required for testing META.yml" if $@; meta_yaml_ok(); Package-Locator-0.010/xt/release/pod-coverage.t000644 000765 000765 00000000527 12205752364 021173 0ustar00jeffjeff000000 000000 #!perl 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' }); Package-Locator-0.010/xt/release/pod-syntax.t000644 000765 000765 00000000212 12205752364 020715 0ustar00jeffjeff000000 000000 #!perl 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(); Package-Locator-0.010/xt/release/test-version.t000644 000765 000765 00000000643 12205752364 021261 0ustar00jeffjeff000000 000000 use strict; use warnings; use Test::More; # generated by Dist::Zilla::Plugin::Test::Version 0.002004 BEGIN { eval "use Test::Version; 1;" or die $@; } my @imports = ( 'version_all_ok' ); my $params = { is_strict => 0, has_version => 1, }; push @imports, $params if version->parse( $Test::Version::VERSION ) >= version->parse('1.002'); Test::Version->import(@imports); version_all_ok; done_testing; Package-Locator-0.010/xt/author/critic.t000644 000765 000765 00000000437 12205752364 017757 0ustar00jeffjeff000000 000000 #!perl 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.ini" ) if -e "perlcritic.ini"; all_critic_ok(); Package-Locator-0.010/xt/author/pod-spell.t000644 000765 000765 00000000617 12205752364 020401 0ustar00jeffjeff000000 000000 use strict; use warnings; use Test::More; # generated by Dist::Zilla::Plugin::Test::PodSpelling 2.006000 eval "use Test::Spelling 0.12; use Pod::Wordlist::hanekomu; 1" or die $@; set_spell_cmd('aspell list'); add_stopwords(); all_pod_files_spelling_ok( qw( bin lib ) ); __DATA__ VCS PASSed BackPAN DarkPAN Jeffrey Ryan Thalhammer jeff Imaginative Software Systems lib Package Locator Index Package-Locator-0.010/t/00-compile.t000644 000765 000765 00000003100 12205752364 016643 0ustar00jeffjeff000000 000000 #!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 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" ); } } } Package-Locator-0.010/t/02-functional.t000644 000765 000765 00000004275 12205752364 017375 0ustar00jeffjeff000000 000000 #!perl use strict; use warnings; use FindBin qw($Bin); use Path::Class; use Test::More (tests => 10); use Package::Locator; #------------------------------------------------------------------------------ my $found; my $repos_dir = dir($Bin)->as_foreign('Unix')->stringify() . '/repos'; my @repos_urls = map { URI->new("file://$repos_dir/$_") } qw(a b); my $locator = Package::Locator->new( repository_urls => \@repos_urls ); #------------------------------------------------------------------------------ # Locate first... $found = $locator->locate(package => 'Foo'); is($found, "file://$repos_dir/a/authors/id/A/AU/AUTHOR/Foo-1.0.tar.gz", 'Locate by package name'); $found = $locator->locate(package => 'Bar'); is($found, undef, 'Locate non-existant package name'); $found = $locator->locate(distribution => 'A/AU/AUTHOR/Foo-1.0.tar.gz'); is($found, "file://$repos_dir/a/authors/id/A/AU/AUTHOR/Foo-1.0.tar.gz", 'Locate by dist path'); $found = $locator->locate(distribution => 'A/AU/AUTHOR/Bar-1.0.tar.gz'); is($found, undef, 'Locate non-existant dist path'); $found = $locator->locate(package => 'Foo', version => 2.0); is($found, "file://$repos_dir/b/authors/id/A/AU/AUTHOR/Foo-2.0.tar.gz", 'Locate by package name and decimal version'); $found = $locator->locate(package => 'Foo', version => 'v1.2.0'); is($found, "file://$repos_dir/b/authors/id/A/AU/AUTHOR/Foo-2.0.tar.gz", 'Locate by package name and vstring'); $found = $locator->locate(package => 'Foo', version => 3.0); is($found, undef, 'Locate non-existant version'); #------------------------------------------------------------------------------ # Locate latest... $found = $locator->locate(package => 'Foo', latest => 1); is($found, "file://$repos_dir/b/authors/id/A/AU/AUTHOR/Foo-2.0.tar.gz", 'Locate latest by package name'); $found = $locator->locate(package => 'Foo', version => 1.0, latest => 1); is($found, "file://$repos_dir/b/authors/id/A/AU/AUTHOR/Foo-2.0.tar.gz", 'Locate latest by package name and decimal version'); $found = $locator->locate(package => 'Foo', version => 'v1.0.5', latest => 1); is($found, "file://$repos_dir/b/authors/id/A/AU/AUTHOR/Foo-2.0.tar.gz", 'Locate latest by package name and vstring'); Package-Locator-0.010/t/03-exceptions.t000644 000765 000765 00000002545 12205752364 017413 0ustar00jeffjeff000000 000000 #!perl use strict; use warnings; use Test::More (tests => 6); use Test::Exception; use Package::Locator; #------------------------------------------------------------------------------ my $class = 'Package::Locator'; #------------------------------------------------------------------------------ throws_ok { $class->new()->locate() } qr/Must specify package or distribution/; throws_ok { $class->new()->locate(package => 'Foo', distribution => 'Foo.tar.gz') } qr/Cannot specify package and distribution together/; throws_ok { $class->new()->locate(distribution => 'Foo.tar.gz', version => 1.2) } qr/Cannot specify version and distribution together/; throws_ok { $class->new()->locate(distribution => 'Foo.tar.gz', latest => 1) } qr/Cannot specify latest and distribution together/; throws_ok { $class->new()->locate(package => 'Foo', version => '2.3-RC') } qr/Invalid version/; #------------------------------------------------------------------------------ # This next one seems to throw different exceptions, depending on the # version of perl. I suspect the exception originates from different # places, depending on what you have. So for now, I just test that # at least some kind of exception is thrown. my $bogus_urls = [ URI->new('http://__bogus__') ]; dies_ok { $class->new(repository_urls => $bogus_urls)->locate(package => 'Foo') }; Package-Locator-0.010/t/04-cache.t000644 000765 000765 00000003540 12205752364 016272 0ustar00jeffjeff000000 000000 #!perl use strict; use warnings; use Path::Class; use FindBin qw($Bin); use URI::Escape qw(uri_escape); use File::Temp qw(tempdir); use IO::Zlib; use Test::More; use Package::Locator; #------------------------------------------------------------------------------ my $found; my $temp_dir = tempdir(CLEANUP => 1); my $repos_dir = dir($Bin)->as_foreign('Unix')->stringify() . '/repos'; my @repos_urls = map { URI->new("file://$repos_dir/$_") } qw(a b); #------------------------------------------------------------------------------ my $locator = Package::Locator->new( repository_urls => \@repos_urls, cache_dir => $temp_dir ); $found = $locator->locate(package => 'Foo', version => 1.0); is($found, "file://$repos_dir/a/authors/id/A/AU/AUTHOR/Foo-1.0.tar.gz", 'Located Foo-1.0'); $found = $locator->locate(package => 'Foo', version => 2.0); is($found, "file://$repos_dir/b/authors/id/A/AU/AUTHOR/Foo-2.0.tar.gz", 'Located Foo-2.0'); for my $url (@repos_urls) { my $cache_file = file( $temp_dir, uri_escape($url), '02packages.details.txt.gz' ); ok( -e $cache_file, "Cache file $cache_file exists" ); # Erase contents of cache file. But we still need the standard gzip header # or else there will be an exception when we try to open the file later. my $fh = IO::Zlib->new($cache_file->stringify, 'wb'); print $fh ''; close $fh; } $locator = Package::Locator->new( repository_urls => \@repos_urls, cache_dir => $temp_dir ); $found = $locator->locate(package => 'Foo', version => 1.0); is($found, undef, 'Did not find Foo-1.0 in empty cache'); $found = $locator->locate(package => 'Foo', version => 2.0); is($found, undef, 'Did not find Foo-2.0 in empty cache'); #------------------------------------------------------------------------------ done_testing(); Package-Locator-0.010/t/05-cache-clear.t000644 000765 000765 00000003142 12205752364 017355 0ustar00jeffjeff000000 000000 use strict; use warnings; use Path::Class; use FindBin qw($Bin); use File::Temp qw(tempdir); use Test::More; use Package::Locator; #------------------------------------------------------------------------------ my $found; my $temp_dir = tempdir(CLEANUP => 1); my $repos_dir = dir($Bin)->as_foreign('Unix')->stringify() . '/repos'; my @repos_urls = map { URI->new("file://$repos_dir/$_") } qw(a b); #------------------------------------------------------------------------------ my $locator = Package::Locator->new( repository_urls => \@repos_urls, cache_dir => $temp_dir ); $found = $locator->locate(package => 'Foo', version => 1.0); is($found, "file://$repos_dir/a/authors/id/A/AU/AUTHOR/Foo-1.0.tar.gz", 'Located Foo-1.0'); $found = $locator->locate(package => 'Foo', version => 2.0); is($found, "file://$repos_dir/b/authors/id/A/AU/AUTHOR/Foo-2.0.tar.gz", 'Located Foo-2.0'); my @index_files = map { $_->index_file } $locator->indexes(); ok(-e $_, 'Index file exists') for @index_files; $locator->clear_cache(); ok(! -e $_, 'Index file removed by clear_cache()') for @index_files; $found = $locator->locate(package => 'Foo', version => 1.0); is($found, "file://$repos_dir/a/authors/id/A/AU/AUTHOR/Foo-1.0.tar.gz", 'Located Foo-1.0 again'); $found = $locator->locate(package => 'Foo', version => 2.0); is($found, "file://$repos_dir/b/authors/id/A/AU/AUTHOR/Foo-2.0.tar.gz", 'Located Foo-2.0 again'); ok(-e $_, 'Index file restored after calling locate()') for @index_files; #------------------------------------------------------------------------------- done_testing(); Package-Locator-0.010/t/06-index.t000644 000765 000765 00000002042 12205752364 016334 0ustar00jeffjeff000000 000000 #!perl use strict; use warnings; use Path::Class; use FindBin qw($Bin); use Test::More (tests => 8); use Package::Locator::Index; #------------------------------------------------------------------------------ my $repos_dir = dir($Bin)->as_foreign('Unix')->stringify() . '/repos'; my $repos_url = URI->new("file://$repos_dir/a"); my $index = Package::Locator::Index->new( repository_url => $repos_url ); #------------------------------------------------------------------------------ my $pkg = $index->packages->{Foo}; ok($pkg, 'Found package'); is($pkg->{name}, 'Foo', 'Package name'); is($pkg->{version}, '1.0', 'Package version'); is($pkg->{distribution}, 'A/AU/AUTHOR/Foo-1.0.tar.gz', 'Dist path'); #------------------------------------------------------------------------------ my $dist = $index->distributions->{'A/AU/AUTHOR/Foo-1.0.tar.gz'}; ok($dist, 'Found dist'); is($dist->{path}, 'A/AU/AUTHOR/Foo-1.0.tar.gz', 'Dist path'); is($dist->{source}, $repos_url, 'Dist path'); is($dist->{packages}->[0]->{name}, 'Foo', 'Package name'); Package-Locator-0.010/t/repos/000755 000765 000765 00000000000 12205752364 015747 5ustar00jeffjeff000000 000000 Package-Locator-0.010/t/repos/a/000755 000765 000765 00000000000 12205752364 016167 5ustar00jeffjeff000000 000000 Package-Locator-0.010/t/repos/b/000755 000765 000765 00000000000 12205752364 016170 5ustar00jeffjeff000000 000000 Package-Locator-0.010/t/repos/b/modules/000755 000765 000765 00000000000 12205752364 017640 5ustar00jeffjeff000000 000000 Package-Locator-0.010/t/repos/b/modules/02packages.details.txt.gz000644 000765 000765 00000000537 12205752364 024371 0ustar00jeffjeff000000 000000 N02packages.details.txtuMO0 >p\|z+&&1MTQԸ[ĝ6~= "Kly_{iz,bTڡ42#iotxî <`O〖 Ikj,G/x.зΌl CG`,h *'oP)2Z$s``=g!deF.ɕPMLb!{p4ggBNqZeɋ3)me*U@cLRIP<*ZyNQGšPߕuY@!p\|z+&&1MTQԸ[ĝ6~= "Kly_{iz,bTڡ42#iotxî <`O〖 Ikj,G/x.зΌl CG`,h *'oP)2Z$s``=g!deF.ɕPMLb!{p4ggBNqZeɋ3)me*U@cLRIP<*ZyNQGšPߕuY@! 1); use MooseX::Types::Path::Class; use Carp; use File::Temp; use Path::Class; use LWP::UserAgent; use CPAN::DistnameInfo; use URI; use Package::Locator::Index; use version; #------------------------------------------------------------------------------ our $VERSION = '0.010'; # VERSION #------------------------------------------------------------------------------ has repository_urls => ( is => 'ro', isa => 'ArrayRef[URI]', auto_deref => 1, default => sub { [URI->new('http://cpan.perl.org')] }, ); #------------------------------------------------------------------------------ has user_agent => ( is => 'ro', isa => 'LWP::UserAgent', builder => '_build_user_agent', ); sub _build_user_agent { my ($self) = @_; my $agent = sprintf "%s/%s", ref $self, $self->VERSION || 'UNKNOWN'; return LWP::UserAgent->new(agent => $agent, env_proxy => 1, keep_alive => 5); } #------------------------------------------------------------------------------ has cache_dir => ( is => 'ro', isa => 'Path::Class::Dir', default => sub { Path::Class::Dir->new( File::Temp::tempdir(CLEANUP => 1) ) }, coerce => 1, ); #------------------------------------------------------------------------------ has force => ( is => 'ro', isa => 'Bool', default => 0, ); #------------------------------------------------------------------------------ has indexes => ( is => 'ro', isa => 'ArrayRef[Package::Locator::Index]', auto_deref => 1, lazy_build => 1, init_arg => undef, ); #------------------------------------------------------------------------------ sub _build_indexes { my ($self) = @_; my @indexes = map { Package::Locator::Index->new( force => $self->force(), cache_dir => $self->cache_dir(), user_agent => $self->user_agent(), repository_url => $_ ) } $self->repository_urls(); return \@indexes; } #------------------------------------------------------------------------------ sub locate { my ($self, %args) = @_; $self->_validate_locate_args(%args); if ($args{package}) { my $package = $args{package}; my $version = $args{version} || 0; my $latest = $args{latest} || 0; return $self->_locate_package($package, $version, $latest); } else { my $dist = $args{distribution}; return $self->_locate_dist($dist); } } #------------------------------------------------------------------------------ sub _validate_locate_args { my ($self, %args) = @_; croak 'Cannot specify latest and distribution together' if $args{distribution} and $args{latest}; croak 'Cannot specify version and distribution together' if $args{distribution} and $args{version}; croak 'Cannot specify package and distribution together' if $args{distribution} and $args{package}; croak 'Must specify package or distribution' if not ( $args{distribution} or $args{package} ); return 1; } #------------------------------------------------------------------------------ sub _locate_package { my ($self, $package, $version, $latest) = @_; my $wanted_version = version->parse($version); my ($latest_found_package, $found_in_index); for my $index ( $self->indexes() ) { my $found_package = $index->packages->{$package}; next if not $found_package; my $found_package_version = version->parse( $found_package->{version} ); next if $found_package_version < $wanted_version; $found_in_index ||= $index; $latest_found_package ||= $found_package; last unless $latest; ($found_in_index, $latest_found_package) = ($index, $found_package) if $self->__compare_packages($found_package, $latest_found_package) == 1; } if ($latest_found_package) { my $base_url = $found_in_index->repository_url(); my $latest_dist_path = $latest_found_package->{distribution}; return URI->new( "$base_url/authors/id/" . $latest_dist_path ); } return; } #------------------------------------------------------------------------------ sub _locate_dist { my ($self, $dist_path) = @_; for my $index ( $self->indexes ) { my $base_url = $index->repository_url(); my $dist_url = URI->new("$base_url/authors/id/$dist_path"); return $dist_url if $index->distributions->{$dist_path}; return $dist_url if $self->user_agent->head($dist_url)->is_success; } return; } #------------------------------------------------------------------------------ sub __compare_packages { my ($self, $pkg_a, $pkg_b) = @_; my $pkg_a_version = $self->__versionize( $pkg_a->{version} ); my $pkg_b_version = $self->__versionize( $pkg_b->{version} ); # TODO: compare dist mtimes (but they are on the server!) return $pkg_a_version <=> $pkg_b_version; } #------------------------------------------------------------------------------ sub __versionize { my ($self, $version) = @_; my $v = eval { version->parse($version) }; return defined $v ? $v : version->new(0); } #------------------------------------------------------------------------------ sub clear_cache { my ($self) = @_; for my $index ( $self->indexes() ) { $index->index_file->remove(); } $self->clear_indexes(); return $self; } #------------------------------------------------------------------------------ __PACKAGE__->meta->make_immutable(); #------------------------------------------------------------------------------ 1; __END__ =pod =for :stopwords Jeffrey Ryan Thalhammer Imaginative Software Systems cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan =head1 NAME Package::Locator - Find a package among CPAN-like repositories =head1 VERSION version 0.010 =head1 SYNOPSIS use Package::Locator; # Basic search... my $locator = Package::Locator->new(); my $url = locator->locate( package => 'Test::More' ); # Search for first within multiple repositories: my $repos = [ qw(http://cpan.pair.com http://my.company.com/DPAN) ]; my $locator = Package::Locator->new( repository_urls => $repos ); my $url = locator->locate( package => 'Test::More' ); # Search for first where version >= 0.34: my $repos = [ qw(http://cpan.pair.com http://my.company.com/DPAN) ]; my $locator = Package::Locator->new( repository_urls => $repos ); my $url = locator->locate( package => 'Test::More' version => 0.34); # Search for latest where version >= 0.34: my $repos = [ qw(http://cpan.pair.com http://my.company.com/DPAN) ]; my $locator = Package::Locator->new( repository_urls => $repos ); my $url = locator->locate( package => 'Test::More' version => 0.34, latest => 1); # Search for specific dist on multiple repositories...: my $repos = [ qw(http://cpan.pair.com http://my.company.com/DPAN) ]; my $locator = Package::Locator->new( repository_urls => $repos ); my $url = locator->locate( distribution => 'A/AU/AUTHOR/Foo-1.0.tar.gz'); =head1 DESCRIPTION L attempts to answer the question: "Where can I find a distribution that will provide this package?" The answer is divined by searching the indexes for one or more CPAN-like repositories. If you also provide a specific version number, L will attempt to find a distribution with that version of the package, or higher. You can also ask to find the latest version of a package across all the indexes. L only looks at the index files for each repository, and those indexes only contain information about the latest versions of the packages within that repository. So L is not BackPAN magic -- you cannot use it to find precisely which distribution a particular package (or file) came from. For that stuff, see C<"/See Also">. =head1 CONSTRUCTOR =head2 new( %attributes ) All the attributes listed below can be passed to the constructor, and retrieved via accessor methods with the same name. All attributes are read-only, and cannot be changed once the object is constructed. =head1 ATTRIBUTES =head2 repository_urls => [ qw(http://somewhere http://somewhere.else) ] An array reference containing the base URLs of the repositories you want to search. These are usually CPAN mirrors, but can be any website or local directory that is organized in a CPAN-like structure. For each request, repositories are searched in the order you specified them here. This defaults to http://cpan.perl.org. =head2 user_agent => $user_agent_obj The L object that will fetch index files. If you do not provide a user agent, then a default one will be constructed for you. =head2 cache_dir => '/some/directory/path' The path (as a string or L object) to a directory where the index file will be cached. If the directory does not exist, it will be created for you. If you do not specify a cache directory, then a temporary directory will be used. The temporary directory will be deleted when your application terminates. =head2 force => $boolean Causes any cached index files to be removed, thus forcing a new one to be downloaded when the object is constructed. This only has effect if you specified the C attribute. The default is false. =head1 METHODS =head2 indexes() Returns a list of L objects representing the indexes of each of the repositories. The indexes are only populated on-demand when the C method is called. The order of the indexes is the same as the order of the repositories defined by the C attribute. =head2 locate( package => 'Foo::Bar' ) =head2 locate( package => 'Foo::Bar', latest => 1 ) =head2 locate( package => 'Foo::Bar', version => '1.2') =head2 locate( package => 'Foo::Bar', version => '1.2', latest => 1 ) =head2 locate ( distribution => 'A/AU/AUTHOR/Foo-Bar-1.0.tar.gz' ) Given the name of a package, searches all the repository indexes and returns the URL to a distribution containing that requested package, or the distribution you requested. If you also specify a C, then you'll always get a distribution that contains that version of the package or higher. If you also specify C then you'll always get the distribution that contains the latest version of the package that can be found in all the indexes. Otherwise you'll just get the first distribution we can find that satisfies your request. If you give a distribution path instead, then you'll just get back the URL to the first distribution we find at that path in any of the repository indexes. If neither the package nor the distribution path can be found in any of the indexes, returns undef. =head2 clear_cache() Deletes the cached index files. Any subsequent calls to the C method will cause the index files to be fetched anew. =head1 MOTIVATION The L module also provides a mechanism for locating packages or distributions, much like L does. However, L assumes that all repositories are CPAN mirrors, so it only searches the first repository that it can contact. My secret ambition is to fill the world with lots of DarkPAN repositories -- each with its own set of distributions. For that scenario, I need to search multiple repositories at the same time. =head1 SEE ALSO If you need to locate a distribution that contains a precise version of a file rather than just a version that is "new enough", then look at some of these: L L L =head1 SUPPORT =head2 Perldoc You can find documentation for this module with the perldoc command. perldoc Package::Locator =head2 Websites The following websites have more information about this module, and may be of help to you. As always, in addition to those websites please use your favorite search engine to discover more resources. =over 4 =item * Search CPAN The default CPAN search engine, useful to view POD in HTML format. L =item * CPAN Ratings The CPAN Ratings is a website that allows community ratings and reviews of Perl modules. L =item * CPAN Testers The CPAN Testers is a network of smokers who run automated tests on uploaded CPAN distributions. L =item * CPAN Testers Matrix The CPAN Testers Matrix is a website that provides a visual overview of the test results for a distribution on various Perls/platforms. L =item * CPAN Testers Dependencies The CPAN Testers Dependencies is a website that shows a chart of the test results of all dependencies for a distribution. L =back =head2 Bugs / Feature Requests L =head2 Source Code L git clone git://github.com/thaljef/Package-Locator.git =head1 AUTHOR Jeffrey Ryan Thalhammer =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Imaginative Software Systems. 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 Package-Locator-0.010/lib/Package/Locator/Index.pm000644 000765 000765 00000020576 12205752364 021477 0ustar00jeffjeff000000 000000 # ABSTRACT: The package index of a repository package Package::Locator::Index; use Moose; use MooseX::Types::URI qw(Uri); use MooseX::Types::Path::Class; use MooseX::MarkAsMethods (autoclean => 1); use Carp; use File::Temp; use Path::Class; use IO::Zlib; use LWP::UserAgent; use URI::Escape; use URI; #------------------------------------------------------------------------ our $VERSION = '0.010'; # VERSION #------------------------------------------------------------------------ has repository_url => ( is => 'ro', isa => Uri, required => 1, coerce => 1, ); #------------------------------------------------------------------------ has user_agent => ( is => 'ro', isa => 'LWP::UserAgent', default => sub { LWP::UserAgent->new() }, ); #------------------------------------------------------------------------ has cache_dir => ( is => 'ro', isa => 'Path::Class::Dir', default => sub { Path::Class::Dir->new( File::Temp::tempdir(CLEANUP => 1) ) }, coerce => 1, ); #------------------------------------------------------------------------ has force => ( is => 'ro', isa => 'Bool', default => 0, ); #------------------------------------------------------------------------ has index_file => ( is => 'ro', isa => 'Path::Class::File', init_arg => undef, lazy_build => 1, ); #------------------------------------------------------------------------ has distributions => ( is => 'ro', isa => 'HashRef', init_arg => undef, default => sub { $_[0]->_data->{distributions} }, lazy => 1, ); #------------------------------------------------------------------------ has packages => ( is => 'ro', isa => 'HashRef', init_arg => undef, default => sub { $_[0]->_data->{packages} }, lazy => 1, ); #------------------------------------------------------------------------ has _data => ( is => 'ro', isa => 'HashRef', init_arg => undef, lazy_build => 1, ); #------------------------------------------------------------------------------ sub _build_index_file { my ($self) = @_; my $repos_url = $self->repository_url->canonical()->as_string(); $repos_url =~ s{ /*$ }{}mx; # Remove trailing slash $repos_url = URI->new($repos_url); # Reconstitute as URI object my $cache_dir = $self->cache_dir->subdir( URI::Escape::uri_escape($repos_url) ); $self->__mkpath($cache_dir); my $destination = $cache_dir->file('02packages.details.txt.gz'); $destination->remove() if -e $destination and $self->force(); my $source = URI->new( "$repos_url/modules/02packages.details.txt.gz" ); my $response = $self->user_agent->mirror($source, $destination); $self->__handle_ua_response($response, $source, $destination); return $destination; } #------------------------------------------------------------------------------ sub _build__data { my ($self) = @_; my $file = $self->index_file->stringify; my $fh = IO::Zlib->new($file, 'rb') or croak "Failed to open index file $file: $!"; my $index_data = $self->__read_index($fh); close $fh; return $index_data; } #------------------------------------------------------------------------------ sub __read_index { my ($self, $fh) = @_; my $inheader = 1; my $packages = {}; my $distributions = {}; my $source = $self->repository_url(); while (<$fh>) { if ($inheader) { $inheader = 0 if not m/ \S /x; next; } chomp; my ($package, $version, $dist_path) = split; my $dist_struct = $distributions->{$dist_path} ||= { source => $source, path => $dist_path }; my $pkg_struct = {name => $package, version => $version, distribution => $dist_path}; push @{ $dist_struct->{packages} ||= [] }, $pkg_struct; $packages->{$package} = $pkg_struct; } return { packages => $packages, distributions => $distributions }; } #------------------------------------------------------------------------ sub __handle_ua_response { my ($self, $response, $source, $destination) = @_; return 1 if $response->is_success(); # Ok return 1 if $response->code() == 304; # Not modified croak sprintf 'Request to %s failed: %s', $source, $response->status_line(); } #------------------------------------------------------------------------------ sub __mkpath { my ($self, $dir) = @_; return 1 if -e $dir; $dir = dir($dir) unless eval { $dir->isa('Path::Class::Dir') }; return $dir->mkpath() or croak "Failed to make directory $dir: $!"; } #------------------------------------------------------------------------ __PACKAGE__->meta->make_immutable(); #------------------------------------------------------------------------ 1; __END__ =pod =for :stopwords Jeffrey Ryan Thalhammer Imaginative Software Systems =head1 NAME Package::Locator::Index - The package index of a repository =head1 VERSION version 0.010 =head1 SYNOPSIS use Package::Locator::Index; my $index = Package::Locator::Index->new( repository_url => 'http://somewhere' ); my $dist = $index->distributions->{'A/AU/AUTHOR/Foo-Bar-1.0.tar.gz'}; my $pkg = $index->packages->{'Foo::Bar'}; =head1 DESCRIPTION B L is yet-another module for parsing the contents of the F<02packages.details.txt> file from a CPAN-like repository. =head1 CONSTRUCTOR =head2 new( %attributes ) All the attributes listed below can be passed to the constructor, and can be retrieved via accessor methods with the same name. All attributes are read-only, and cannot be changed once the object is constructed. =head1 ATTRIBUTES =head2 repository_url => 'http://somewhere' The base URL of the repository you want to get the index from. This is usually a CPAN mirror, but can be any site or directory that is organized in a CPAN-like structure. This attribute is required. =head2 user_agent => $user_agent_obj The L object that will fetch the index file. If you do not provide a user agent, then a default one will be constructed for you. =head2 cache_dir => '/some/directory/path' The path (as a string or L object) to a directory where the index file will be cached. If the directory does not exist, it will be created for you. If you do not specify a cache directory, then a temporary directory will be used. The temporary directory will be deleted when your application terminates. =head2 force => $boolean Causes any cached index files to be removed, thus forcing a new one to be downloaded when the object is constructed. This only has effect if you specified the C attribute. The default is false. =head1 METHODS =head2 index_file() Returns the path to the local copy of the index file (as a L). =head2 distributions Returns a hashref representing the contents of the index. The keys are the paths to the distributions (as they appear in the index). The values are data structures that look like this: { path => 'A/AU/AUTHOR/FooBar-1.0.tar.gz', source => 'http://some.cpan.mirror' packages => [ ## See package structure below ## ] } =head2 packages Returns a hashref representing the contents of the index. The keys are the names of packages. The values are data structures that look like this: { name => 'Foo', version => '1.0', distribution => 'A/AU/AUTHOR/FooBar-1.0.tar.gz' } =head1 MOTIVATION There are numerous existing modules for parsing the F<02packages.details.txt> file, but I wasn't completely happy with any of them. Most of the existing modules transform the data into various flavors of Distribution and Package objects. But I'm not ready to commit to any particular API for Distributions and Packages (not even one of my own). So L exposes the index data as simple data structures. =head1 AUTHOR Jeffrey Ryan Thalhammer =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Imaginative Software Systems. 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 Package-Locator-0.010/examples/pkg-locate000755 000765 000765 00000002460 12205752364 020150 0ustar00jeffjeff000000 000000 #!/usr/bin/perl # ABSTRACT: Find URL to distribution that contains a given package # PODNAME: pkg-locate use strict; use warnings; use Getopt::Long; use Pod::Usage; use Package::Locator; my @opts_spec = qw(cache_dir|cache=s); GetOptions(\my %opts, @opts_spec) || pod2usage(); my @wanted = @ARGV ? @ARGV : pod2usage(); my $locator = Package::Locator->new(%opts); my %found = map { my $p = $_; $p => $locator->locate($p) || '' } @wanted; my $longest = (sort { $b <=> $a } map { length } keys %found)[0]; printf "%-${longest}s => %s\n", $_, $found{$_} for sort keys %found; exit; #----------------------------------------------------------------------------- =head1 SYNOPSIS pkg-locate [ --cache=/some/dir ] PACKAGE_NAME_OR_DIST_PATH ... =head1 DESCRIPTION L is a simple command line tool demonstrating the use of L. For each package, L will report the URL of a distribution that will provide that package. =head1 ARGUMENTS The arguments are the names of packages (e.g. 'FOO::Bar') or paths to distributions as they would appear in a CPAN-like index file (e.g. 'F/FO/FOO/Bar-1.2.tar.gz'). =head1 OPTIONS =head2 --cache = /some/path A directory that will be used to cache index files for future lookups. If this directory does not exist it will be created for you.