PAR::Repository::Client - Access PAR repositories
use PAR::Repository::Client; my $client = PAR::Repository::Client->new( uri => 'http://foo/repository', ); # This is happening at run-time, of course: # But calling import from your namespace $client->use_module('Foo::Bar') or die $client->error; $client->require_module('Bar::Baz') or die $client->error;
This module represents the client for PAR repositories as implemented by the PAR::Repository module.
Chances are, you should be looking at the PAR module instead. Starting with version 0.950, it supports automatically loading any modules that aren't found on your system from a repository. If you need finer control than that, then this module is the right one to use.
You can use this module to access repositories in one of two ways: On your local filesystem or via HTTP. The access methods are implemented in PAR::Repository::Client::HTTP and PAR::Repository::Client::Local. Any common code is in this module.
For a detailed discussion of the structure of PAR repositories, please have a look at the PAR::Repository distribution.
A PAR repository is, well, a repository of .par distributions which contain Perl modules and scripts. You can create .par distributions using the PAR::Dist module or the PAR module itself.
If you are unsure what PAR archives are, then have a look at the "SEE ALSO" section below, which points you at the relevant locations.
Following is a list of class and instance methods. (Instance methods until otherwise mentioned.)
Creates a new PAR::Repository::Client object. Takes named arguments.
Mandatory paramater:
uri specifies the URI of the repository to use. Initially, http and file URIs will be supported, so you can access a repository locally using file:///path/to/repository or just with /path/to/repository. HTTP accessible repositories can be specified as http://foo and https://foo.
file:///path/to/repository
/path/to/repository
http://foo
https://foo
Upon client creation, the repository's version is validated to be compatible with this version of the client.
First argument must be a package name (namespace) to require. The method scans the repository for distributions that contain the specified package.
When one or more distributions are found, it determines which distribution to use using the prefered_distribution() method.
prefered_distribution()
Then, it fetches the prefered .par distribution from the repository and opens it using the PAR module. Finally, it loads the specified module from the downloaded .par distribution using require().
require()
Returns 1 on success, the empty list on failure. In case of failure, an error message can be obtained with the error() method.
error()
Works the same as the require_module method except that instead of only requiring the specified module, it also calls the import method if it exists. Any arguments to this methods after the package to load are passed to the import call.
require_module
import
First parameter must be a namespace, second parameter may be a boolean indicating whether the PAR is a fallback-PAR or one to load from preferably. (Defaults to false which means loading preferably.)
Searches for a specified namespace in the repository and downloads the corresponding PAR distribution. Automatically loads PAR and appends the downloaded PAR distribution to the list of PARs to load from.
Returns the name of the local PAR file. Think of this as require_module without actually doing a require() of the module.
Returns the last error message if there was an error or the empty list otherwise.
Takes a namespace as first argument followed by a reference to a hash of distribution file names with associated module versions. The file name should have the following form:
Math-Symbolic-0.502-x86_64-linux-gnu-thread-multi-5.8.7.par
This method decides which distribution to load and returns that file name.
Accesses the repository meta information and validates that it has a compatible version. This is done on object creation, so it should not normally be necessary to call this from user code.
Returns a boolean indicating the outcome of the operation.
This is a private method.
Fetches the modules_dists.dbm database from the repository, ties it to a DBM::Deep object and returns a tied hash reference or the empty list on failure. Second return value is the name of the local temporary file.
modules_dists.dbm
In case of failure, an error message is available via the error() method.
The method uses the _fetch_dbm_file() method which must be implemented in a subclass such as PAR::Repository::Client::HTTP.
_fetch_dbm_file()
Closes the modules_dists.dbm file and does all necessary cleaning up.
This is called when the object is destroyed.
This is a private method. Callable as class or instance method.
Unzips the file given as first argument to the file given as second argument. If a third argument is used, the zip member of that name is extracted. If the zip member name is omitted, it is set to the target file name.
Returns the name of the unzipped file.
This module is directly related to the PAR project. You need to have basic familiarity with it. Its homepage is at http://par.perl.org/
PAR
See PAR, PAR::Dist, PAR::Repository, etc.
PAR::Repository implements the server side creation and manipulation of PAR repositories.
PAR::WebStart is doing something similar but is otherwise unrelated.
Steffen Müller, <smueller@cpan.org>
Copyright (C) 2006 by Steffen Müller
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.6 or, at your option, any later version of Perl 5 you may have available.
1 POD Error
The following errors were encountered while parsing the POD:
Non-ASCII character seen before =encoding in 'Müller,'. Assuming UTF-8
To install PAR::Repository::Client, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PAR::Repository::Client
CPAN shell
perl -MCPAN -e shell install PAR::Repository::Client
For more information on module installation, please visit the detailed CPAN module installation guide.