WorePAN - creates a partial CPAN mirror for tests
use WorePAN; my $worepan = WorePAN->new( root => 'path/to/destination/', files => [qw( I/IS/ISHIGAKI/WorePAN-0.01.tar.gz )], cleanup => 1, use_backpan => 0, no_network => 0, tmp => 'path/to/tmpdir', ); # walk through a MiniCPAN to investigate META data WorePAN->new(use_minicpan => 1)->walk(sub { my $dir = shift; my $meta_yml = $dir->file('META.yml'); return unless -f $meta_yml; my $meta = eval { Parse::CPAN::Meta->load_file($meta_yml) }; ... });
WorePAN helps you to create a partial CPAN mirror with minimal indices. It's useful when you test something that requires a small part of a CPAN mirror. You can use it to build a DarkPAN as well.
The main differences between this and the friends are: this works under the Windows (hence the "W-"), and this fetches files not only from the CPAN but also from the BackPAN (and from a local directory with the same layout as of the CPAN) if necessary.
creates an instance, and fetches files/updates indices internally.
Options are:
If specified, a WorePAN mirror will be created under the specified directory; otherwise, it will be created under a temporary directory (which is accessible via root).
root
If set to true, WorePAN reads .minicpanrc file to find your local MiniCPAN and uses it as a WorePAN root.
.minicpanrc
a CPAN mirror from where you'd like to fetch files.
takes an arrayref of filenames to fetch. As of this writing they should be paths to existing files or path parts that follow http://your.CPAN.mirror/authors/id/.
http://your.CPAN.mirror/authors/id/
If network is available (see below), you can pass a hashref of distribution names (N.B. not package/module names) and required versions, which will be normalized into an array of filenames via remote API. If you don't remember who has released a specific version of a distribution, this may help.
my $worepan = WorePAN->new( dists => { 'Catalyst-Runtime' => 5.9, 'DBIx-Class' => 0, }, );
takes a path to your local CPAN mirror from where files are copied.
If set to true, WorePAN won't try to fetch files from remote sources. This is set to true by default when you're in tests.
If set to true, WorePAN also looks into the BackPAN when it fails to fetch a file from the CPAN.
a BackPAN mirror from where you'd like to fetch files.
If set to true, WorePAN removes its contents when the instance is gone (mainly for tests).
If set to true, WorePAN won't create/update indices.
WorePAN usually ignores developer releases and doesn't fetch/index them. Set this to true if you need them for whatever reasons.
If you pass a valid PAUSE::Permissions instance, it will be used while indexing.
If set, temporary directories will be created in the specified directory.
$worepan->add_files(qw{ I/IS/ISHIGAKI/WorePAN-0.01.tar.gz });
Adds files to the WorePAN mirror. When you add files with this method, you need to call update_indices by yourself.
update_indices
$worepan->add_dists( 'Catalyst-Runtime' => 5.9, 'DBIx-Class' => 0, );
Adds distributions to the WorePAN mirror. When you add distributions with this method, you need to call update_indices by yourself.
Creates/updates mailrc and packages_details indices.
$worepan->walk(sub { my $distdir = shift; my $meta_yml = $distdir->file('META.yml'); $distdir->recurse(callback => sub { my $file_in_a_dist = shift; return unless $file_in_a_dist =~ /\.pm$/; ... }); });
Walks down the WorePAN directory and extracts each distribution into a temporary directory, and runs a callback to which a Path::Extended::Tiny object for the directory is passed as an argument. Used internally to create indices.
returns a Path::Extended::Tiny object that represents the root path you specified (or created internally).
takes a relative path to a distribution ("P/PA/PAUSE/distribution.tar.gz") and returns a Path::Extended::Tiny object.
returns a Path::Extended::Tiny object that represents the "00whois.xml" file. slurp_whois returns a list of author entries parsed by Parse::CPAN::Whois.
slurp_whois
returns a Path::Extended::Tiny object that represents the "01mailrc.txt.gz" file. slurp_mailrc returns a list of lines without preambles.
slurp_mailrc
returns a Path::Extended::Tiny object that represents the "02packages.details.txt.gz" file. slurp_packages_details returns a list of lines without preambles.
slurp_packages_details
takes a package name and returns the version and the path of the package if it exists.
returns an array reference of hash references each of which holds an author's information stored in the whois file.
returns an array reference of hash references each of which holds a module name and its version stored in the packages_details file.
returns an array reference of files listed in the packages_details file.
returns an array reference of CPAN::DistnameInfo objects each of which holds a latest distribution's info stored in the packages_details file.
(w)oh-ray-PAN, not WORE-pan. "Ore" (pronounced oh-ray) indicates the first person singular in masculine speech in Japan, and the "w" adds a funny tone to it.
OrePAN, CPAN::Faker, CPAN::Mini::FromList, CPAN::ParseDistribution
Kenichi Ishigaki, <ishigaki@cpan.org>
Copyright (C) 2012 by Kenichi Ishigaki.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install WorePAN, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WorePAN
CPAN shell
perl -MCPAN -e shell install WorePAN
For more information on module installation, please visit the detailed CPAN module installation guide.