NAME
CPAN::Faker - build a bogus CPAN instance for testing
VERSION
version 0.012
SYNOPSIS
use CPAN::Faker;
my $cpan = CPAN::Faker->new({
source => './eg',
dest => './will-contain-fakepan',
});
$cpan->make_cpan;
DESCRIPTION
First things first: this is a pretty special-needs module. It's for people who are writing tools that will operate against a copy of the CPAN (or something just like it), and who need data to test those tools against.
Because the real CPAN is constantly changing, and a mirror of the CPAN is a pretty big chunk of data to deal with, CPAN::Faker lets you build a fake CPAN-like directory tree out of simple descriptions of the distributions that should be in your fake CPAN.
PERL VERSION
This module should work on any version of perl still receiving updates from the Perl 5 Porters. This means it should work on any version of perl released in the last two to three years. (That is, if the most recently released version is v5.40, then this module should work on both v5.40 and v5.38.)
Although it may work on older versions of perl, no guarantee is made that the minimum required version will not be increased. The version may be increased for any reason, and there is no promise that patches will be accepted to lower the minimum required perl.
METHODS
new
my $faker = CPAN::Faker->new(\%arg);
This create the new CPAN::Faker. All arguments may be accessed later by methods of the same name. Valid arguments are:
source - the directory in which to find source files
dest - the directory in which to construct the CPAN instance; required
url - the base URL for the CPAN; a file:// URL is generated by default
dist_class - the class used to fake dists; default: Module::Faker::Dist
make_cpan
$faker->make_cpan;
This method makes the CPAN::Faker do its job. It iterates through all the files in the source directory and builds a distribution object. Distribution archives are written out into the author's directory, distribution contents are (potentially) added to the index, CHECKSUMS files are created, and the indices are then written out.
add_author
$faker->add_author($pause_id => \%info);
Low-level method for populating 01mailrc
. Only likely to be useful if you are not calling make_cpan
. If the author is already known, the info on file is replaced.
The %info
hash is expected to contain the following data:
mailbox - a string like: Ricardo Signes <rjbs@cpan.org>
index_package
$faker->index_package($package_name => \%info);
This is a low-level method for populating the structure that will used to produce the 02packages
index.
This method is only likely to be useful if you are not calling make_cpan
.
%entry
is expected to contain the following entries:
version - the version of the package (defaults to undef)
dist_version - the version of the dist (defaults to undef)
dist_filename - the file containing the package, like R/RJ/RJBS/...tar.gz
dist_author - the PAUSE id of the uploader of the dist
write_author_index
write_package_index
write_modlist_index
write_perms_index
write_perms_gz_index
All these are automatically called by make_cpan
; you probably do not need to call them yourself.
Write 01mailrc.txt.gz
, 02packages.details.txt.gz
, 03modlist.data.gz
, 06perms.txt
, and 06perms.txt.gz
respectively.
THE CPAN INTERFACE
A CPAN instance is just a set of files in known locations. At present, CPAN::Faker will create the following files:
./authors/01mailrc.txt.gz - the list of authors (PAUSE ids)
./modules/02packages.details.txt.gz - the master index of current modules
./modules/03modlist.txt.gz - the "registered" list; has no data
./authors/id/X/Y/XYZZY/Dist-1.tar.gz - each distribution in the archive
./authors/id/X/Y/XYZZY/CHECKSUMS - a CPAN checksums file for the dir
Note that while the 03modlist file is created, for the sake of the CPAN client, the file contains no data about registered modules. This may be addressed in future versions.
Other files that are not currently created, but may be in the future are:
./indices/find-ls.gz
./indices/ls-lR.gz
./modules/by-category/...
./modules/by-module/...
If there are other files that you'd like to see created (or if you want to ask to get the creation of one of the above implemented soon), please contact the current maintainer (see below).
add_dist
$faker->add_dist($dist);
This method expects a Module::Faker::Dist object, for which it will construct an archive, index the author and (maybe) the contents.
AUTHOR
Ricardo Signes <cpan@semiotic.systems>
CONTRIBUTORS
Hans Dieter Pearcey <hdp@pobox.com>
Randy Stauner <rwstauner@cpan.org>
Ricardo Signes <rjbs@semiotic.systems>
COPYRIGHT AND LICENSE
This software is copyright (c) 2008 by Ricardo Signes.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.