12 Sep 2012 16:58:39 UTC
- Distribution: CPAN-Inject
- Module version: 1.14
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (8)
- Testers (914 / 1107 / 1)
- KwaliteeBus factor: 1
- 73.95% Coverage
- License: perl_5
- Perl: v5.6.0
- Activity24 month
- Download (49.82KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionPSHANGOV Peter Shangovand 1 contributors
- The C<author> accessor returns the CPAN id for the default author which
- SEE ALSO
CPAN::Inject - Base class for injecting distributions into CPAN sources
# Create the injector my $cpan = CPAN::Inject->new( sources => '/root/.cpan/sources', # Required field author => 'LOCAL', # The default ); # Add a file to the user $cpan->add( file => 'some/random/Perl-Tarball-1.02.tar.gz' ); # What would have have to use when installing # $path = 'LOCAL/Perl-Tarball-1.02.tar.gz'; my $path = $cpan->install_path( 'some/random/Perl-Tarball-1.02.tar.gz' );
While it was created for use with a minicpan mirror, similar functionality can be reused in other situations.
CPAN::Inject replicates the basics of this functionality.
Specifically, it takes an arbitrary tarball and adds it to the CPAN sources directory for a particular author, and then add the new file to the CHECKSUMS file.
It does not reimplement the logic to add files to the indexes.
The initial use this module was created for was to inject tarballs into the CPAN sources directory for the reserved LOCAL user, so that the can be installed via the CPAN shell, with automated recursion to CPAN dependencies.
But although the number of functions is limited (current only
addexists, with the others to be added as needed) the implementation is very generic and sub-classable, so that it can be reused in other situations.
# Create the injector for the default LOCAL author $cpan = CPAN::Inject->new( sources => '/root/.cpan/sources', ); # Create the injector for a specific author $cpan = CPAN::Inject->new( sources => '/root/.cpan/sources', author => 'ADAMK', );
newconstructor takes a set of named params and create a cpan injection object.
To retain the permissions and ownership integrity of the sources tree, you must be the owner of the
sourcesdirectory in order to inject the distribution tarballs.
* author - The optional
authorparam should be the CPAN id of an author. By default, the reserved local CPAN id "LOCAL" will be used.
The author provided will be used as a default in all further actions.
CPAN::Injectobject, or throws an exception on error.
from_cpan_configconstructor loads the CPAN.pm configuration file, and uses the data contained within to specific the sources path for the object.
This constructor is otherwise the same.
Returns a CPAN::Inject object on success, or throws an exception on error.
sourcesaccessor returns the path to the root of the directory tree.
authoraccessor returns the CPAN id for the default author which will be "LOCAL" if you did not provide an alternative param to the the
# Add a file to the constructor/default author $cpan->add( file => 'any/arbitrary/Perl-Tarball-1.01.tar.gz' );
addmethod takes a Perl distribution tarball from an arbitrary path, and adds it to the sources path.
The specific location the tarball is copied to will be in the root directory for the author provided to the constructor.
Returns the install_path value as a convenience, or throws an exception on error.
# Remove a distribution from the repository $cpan->remove( dist => 'LOCAL/Perl-Tarball-1.01.tar.gz' );
removemethod takes a distribution path and removes it from the sources path. The file is also removed.
Does not return anything useful and throws an exception on error.
# $path = 'authors/id/L/LO/LOCAL' $path = $cpan->author_subpath;
author_subpathmethod takes a CPAN author id (or uses the CPAN author id originally provided to the constructor) and returns the relative subpath for the AUTHOR within the sources tree.
Returns the subpath as a string.
# $path = '/root/.cpan/sources/authors/id/L/LO/LOCAL' $path = $cpan->author_subpath;
author_pathmethod finds the full path for the root directory for the named author.
Returns the path as a string.
# $path = '/root/.cpan/sources/authors/id/L/LO/LOCAL/Perl-Tarball-1.02.tar.gz' $path = $cpan->file_path( 'Perl-Tarball-1.02.tar.gz' ); $path = $cpan->file_path( '/some/random/place/Perl-Tarball-1.02.tar.gz' );
file_pathmethod takes the name of a tarball (either just the name or a full path) and calculates the location that the file will end up at.
When files are copied into the sources directory, they are always copied to the top level of the author root.
Returns the path as a string.
# $path = 'LOCAL/Perl-Tarball-1.01.tar.gz'; $path = $cpan->install_path( 'Perl-Tarball-1.01.tar.gz' ); $path = $cpan->install_path( '/some/random/place/Perl-Tarball-1.02.tar.gz' );
install_pathmethod returns the path for the distribution as the CPAN shell understands it.
Using this path, the CPAN shell can expand it to locate the distribution, and then can install it.
Returns the path as a string.
This module is stored in an Open Repository at the following address.
Write access to the repository is made available automatically to any published CPAN author, and to most other volunteers on request.
If you are able to submit your bug report in the form of new (failing) unit tests, or can apply your fix directly instead of submitting a patch, you are strongly encouraged to do so as the author currently maintains over 100 modules and it can take some time to deal with non-Critcal bug reports or patches.
This will guarentee that your issue will be addressed in the next release of the module.
If you cannot provide a direct test or fix, or don't have time to do so, then regular bug reports are still accepted and appreciated via the CPAN bug tracker.
For other issues, for commercial enhancement or support, or to have your write access enabled for the repository, contact the author at the email address above.
Adam Kennedy <email@example.com>
Copyright 2006 - 2011 Adam Kennedy.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.