| 1 |
NAME |
| 2 |
Package::Locator - Find a package among CPAN-like repositories |
| 3 |
|
| 4 |
VERSION |
| 5 |
version 0.010 |
| 6 |
|
| 7 |
SYNOPSIS |
| 8 |
use Package::Locator; |
| 9 |
|
| 10 |
# Basic search... |
| 11 |
my $locator = Package::Locator->new(); |
| 12 |
my $url = locator->locate( package => 'Test::More' ); |
| 13 |
|
| 14 |
# Search for first within multiple repositories: |
| 15 |
my $repos = [ qw(http://cpan.pair.com http://my.company.com/DPAN) ]; |
| 16 |
my $locator = Package::Locator->new( repository_urls => $repos ); |
| 17 |
my $url = locator->locate( package => 'Test::More' ); |
| 18 |
|
| 19 |
# Search for first where version >= 0.34: |
| 20 |
my $repos = [ qw(http://cpan.pair.com http://my.company.com/DPAN) ]; |
| 21 |
my $locator = Package::Locator->new( repository_urls => $repos ); |
| 22 |
my $url = locator->locate( package => 'Test::More' version => 0.34); |
| 23 |
|
| 24 |
# Search for latest where version >= 0.34: |
| 25 |
my $repos = [ qw(http://cpan.pair.com http://my.company.com/DPAN) ]; |
| 26 |
my $locator = Package::Locator->new( repository_urls => $repos ); |
| 27 |
my $url = locator->locate( package => 'Test::More' version => 0.34, latest => 1); |
| 28 |
|
| 29 |
# Search for specific dist on multiple repositories...: |
| 30 |
my $repos = [ qw(http://cpan.pair.com http://my.company.com/DPAN) ]; |
| 31 |
my $locator = Package::Locator->new( repository_urls => $repos ); |
| 32 |
my $url = locator->locate( distribution => 'A/AU/AUTHOR/Foo-1.0.tar.gz'); |
| 33 |
|
| 34 |
DESCRIPTION |
| 35 |
Package::Locator attempts to answer the question: "Where can I find a |
| 36 |
distribution that will provide this package?" The answer is divined by |
| 37 |
searching the indexes for one or more CPAN-like repositories. If you |
| 38 |
also provide a specific version number, Package::Locator will attempt to |
| 39 |
find a distribution with that version of the package, or higher. You can |
| 40 |
also ask to find the latest version of a package across all the indexes. |
| 41 |
|
| 42 |
Package::Locator only looks at the index files for each repository, and |
| 43 |
those indexes only contain information about the latest versions of the |
| 44 |
packages within that repository. So Package::Locator is not BackPAN |
| 45 |
magic -- you cannot use it to find precisely which distribution a |
| 46 |
particular package (or file) came from. For that stuff, see "/See Also". |
| 47 |
|
| 48 |
CONSTRUCTOR |
| 49 |
new( %attributes ) |
| 50 |
All the attributes listed below can be passed to the constructor, and |
| 51 |
retrieved via accessor methods with the same name. All attributes are |
| 52 |
read-only, and cannot be changed once the object is constructed. |
| 53 |
|
| 54 |
ATTRIBUTES |
| 55 |
repository_urls => [ qw(http://somewhere http://somewhere.else) ] |
| 56 |
An array reference containing the base URLs of the repositories you want |
| 57 |
to search. These are usually CPAN mirrors, but can be any website or |
| 58 |
local directory that is organized in a CPAN-like structure. For each |
| 59 |
request, repositories are searched in the order you specified them here. |
| 60 |
This defaults to http://cpan.perl.org. |
| 61 |
|
| 62 |
user_agent => $user_agent_obj |
| 63 |
The LWP::UserAgent object that will fetch index files. If you do not |
| 64 |
provide a user agent, then a default one will be constructed for you. |
| 65 |
|
| 66 |
cache_dir => '/some/directory/path' |
| 67 |
The path (as a string or Path::Class::Dir object) to a directory where |
| 68 |
the index file will be cached. If the directory does not exist, it will |
| 69 |
be created for you. If you do not specify a cache directory, then a |
| 70 |
temporary directory will be used. The temporary directory will be |
| 71 |
deleted when your application terminates. |
| 72 |
|
| 73 |
force => $boolean |
| 74 |
Causes any cached index files to be removed, thus forcing a new one to |
| 75 |
be downloaded when the object is constructed. This only has effect if |
| 76 |
you specified the "cache_dir" attribute. The default is false. |
| 77 |
|
| 78 |
METHODS |
| 79 |
indexes() |
| 80 |
Returns a list of Package::Locator::Index objects representing the |
| 81 |
indexes of each of the repositories. The indexes are only populated |
| 82 |
on-demand when the "locate" method is called. The order of the indexes |
| 83 |
is the same as the order of the repositories defined by the |
| 84 |
"repository_urls" attribute. |
| 85 |
|
| 86 |
locate( package => 'Foo::Bar' ) |
| 87 |
locate( package => 'Foo::Bar', latest => 1 ) |
| 88 |
locate( package => 'Foo::Bar', version => '1.2') |
| 89 |
locate( package => 'Foo::Bar', version => '1.2', latest => 1 ) |
| 90 |
locate ( distribution => 'A/AU/AUTHOR/Foo-Bar-1.0.tar.gz' ) |
| 91 |
Given the name of a package, searches all the repository indexes and |
| 92 |
returns the URL to a distribution containing that requested package, or |
| 93 |
the distribution you requested. |
| 94 |
|
| 95 |
If you also specify a "version", then you'll always get a distribution |
| 96 |
that contains that version of the package or higher. If you also specify |
| 97 |
"latest" then you'll always get the distribution that contains the |
| 98 |
latest version of the package that can be found in all the indexes. |
| 99 |
Otherwise you'll just get the first distribution we can find that |
| 100 |
satisfies your request. |
| 101 |
|
| 102 |
If you give a distribution path instead, then you'll just get back the |
| 103 |
URL to the first distribution we find at that path in any of the |
| 104 |
repository indexes. |
| 105 |
|
| 106 |
If neither the package nor the distribution path can be found in any of |
| 107 |
the indexes, returns undef. |
| 108 |
|
| 109 |
clear_cache() |
| 110 |
Deletes the cached index files. Any subsequent calls to the "locate" |
| 111 |
method will cause the index files to be fetched anew. |
| 112 |
|
| 113 |
MOTIVATION |
| 114 |
The CPAN module also provides a mechanism for locating packages or |
| 115 |
distributions, much like Package::Locator does. However, CPAN assumes |
| 116 |
that all repositories are CPAN mirrors, so it only searches the first |
| 117 |
repository that it can contact. |
| 118 |
|
| 119 |
My secret ambition is to fill the world with lots of DarkPAN |
| 120 |
repositories -- each with its own set of distributions. For that |
| 121 |
scenario, I need to search multiple repositories at the same time. |
| 122 |
|
| 123 |
SEE ALSO |
| 124 |
If you need to locate a distribution that contains a precise version of |
| 125 |
a file rather than just a version that is "new enough", then look at |
| 126 |
some of these: |
| 127 |
|
| 128 |
Dist::Surveyor |
| 129 |
|
| 130 |
BackPAN::Index |
| 131 |
|
| 132 |
BackPAN::Version::Discover |
| 133 |
|
| 134 |
SUPPORT |
| 135 |
Perldoc |
| 136 |
You can find documentation for this module with the perldoc command. |
| 137 |
|
| 138 |
perldoc Package::Locator |
| 139 |
|
| 140 |
Websites |
| 141 |
The following websites have more information about this module, and may |
| 142 |
be of help to you. As always, in addition to those websites please use |
| 143 |
your favorite search engine to discover more resources. |
| 144 |
|
| 145 |
* Search CPAN |
| 146 |
|
| 147 |
The default CPAN search engine, useful to view POD in HTML format. |
| 148 |
|
| 149 |
<http://search.cpan.org/dist/Package-Locator> |
| 150 |
|
| 151 |
* CPAN Ratings |
| 152 |
|
| 153 |
The CPAN Ratings is a website that allows community ratings and |
| 154 |
reviews of Perl modules. |
| 155 |
|
| 156 |
<http://cpanratings.perl.org/d/Package-Locator> |
| 157 |
|
| 158 |
* CPAN Testers |
| 159 |
|
| 160 |
The CPAN Testers is a network of smokers who run automated tests on |
| 161 |
uploaded CPAN distributions. |
| 162 |
|
| 163 |
<http://www.cpantesters.org/distro/P/Package-Locator> |
| 164 |
|
| 165 |
* CPAN Testers Matrix |
| 166 |
|
| 167 |
The CPAN Testers Matrix is a website that provides a visual overview |
| 168 |
of the test results for a distribution on various Perls/platforms. |
| 169 |
|
| 170 |
<http://matrix.cpantesters.org/?dist=Package-Locator> |
| 171 |
|
| 172 |
* CPAN Testers Dependencies |
| 173 |
|
| 174 |
The CPAN Testers Dependencies is a website that shows a chart of the |
| 175 |
test results of all dependencies for a distribution. |
| 176 |
|
| 177 |
<http://deps.cpantesters.org/?module=Package::Locator> |
| 178 |
|
| 179 |
Bugs / Feature Requests |
| 180 |
<https://github.com/thaljef/Package-Locator/issues> |
| 181 |
|
| 182 |
Source Code |
| 183 |
<https://github.com/thaljef/Package-Locator> |
| 184 |
|
| 185 |
git clone git://github.com/thaljef/Package-Locator.git |
| 186 |
|
| 187 |
AUTHOR |
| 188 |
Jeffrey Ryan Thalhammer <[email protected]> |
| 189 |
|
| 190 |
COPYRIGHT AND LICENSE |
| 191 |
This software is copyright (c) 2011 by Imaginative Software Systems. |
| 192 |
|
| 193 |
This is free software; you can redistribute it and/or modify it under |
| 194 |
the same terms as the Perl 5 programming language system itself. |
| 195 |
|