| CPAN-Faker documentation | view source | Contained in the CPAN-Faker distribution. |
CPAN::Faker - build a bogus CPAN instance for testing
version 0.007
use CPAN::Faker;
my $cpan = CPAN::Faker->new({
source => './eg',
dest => './will-contain-fakepan',
});
$cpan->make_cpan;
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.
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
$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.
$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
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,
and 06perms.txt respectively.
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/06perms.txt.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).
$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.
Ricardo Signes <rjbs@cpan.org>
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.
| CPAN-Faker documentation | view source | Contained in the CPAN-Faker distribution. |