NAME
OrePAN2::Injector - Inject a distribution to your DarkPAN
SYNOPSIS
use OrePAN2::Injector;
my $injector = OrePAN2::Injector->new(directory => '/path/to/darkpan');
$injector->inject(
'http://cpan.metacpan.org/authors/id/M/MA/MAHITO/Acme-Hoge-0.03.tar.gz',
{ author => 'MAHITO' },
);
DESCRIPTION
OrePAN2::Injector allows you to inject a distribution into your DarkPAN.
METHODS
my $injector = OrePAN2::Injector->new(%attr)
Constructor. Here %attr
might be:
directory
Your DarkPAN directory path. This is required.
author
Default author of distributions. If you omit this, then
DUMMY
will be used.BETA: As of OrePAN2 0.37, the author attribute accepts a code reference, so that you can calculate author whenever injecting distributions:
my $author_cb = sub { my $source = shift; $source =~ m{authors/id/./../([^/]+)} ? $1 : "DUMMY"; }; my $injector = OrePAN2::Injector->new( directory => '/path/to/darkpan', author => $author_cb, ); $injector->inject( 'http://cpan.metacpan.org/authors/id/M/MA/MAHITO/Acme-Hoge-0.03.tar.gz' ); #=> Acme-Hoge-0.03 will be indexed with author MAHITO
Note that the code reference
$author_cb
will be executed under the following circumstances:* the first argument is the $source argument to the inject method * the working directory of it is the top level of the distribution in question
author_subdir
This is an optional attribute. If present it means that directory elements will be created following the author. This can be useful, for instance, if you want to make your DarkPAN have paths that exactly match the paths in CPAN. Sometimes CPAN paths look something like the following:
authors/id/<author>/modules/...
In the above case you can pass 'modules' as the value for author_subdir so that the path OrePAN2 creates looks like the above path.
$injector->inject($source, \%option)
Inject $source
to your DarkPAN. Here $source
is one of the following:
local archive file
eg: /path/to/Text-TestBase-0.10.tar.gz
HTTP url
eg: http://cpan.metacpan.org/authors/id/T/TO/TOKUHIROM/Text-TestBase-0.10.tar.gz
git repository
eg: git://github.com/tokuhirom/Text-TestBase.git@master
Note that you need to set up git repository as a installable git repo, that is, you need to put a META.json in your repository.
If you are using Minilla or Milla, your repository is already ready to install.
Supports the following URL types:
git+file://path/to/repo.git git://github.com/plack/Plack.git@1.0000 # tag git://github.com/plack/Plack.git@devel # branch
They are compatible with cpanm.
module name
eg: Data::Dumper
\%option
might be:
author
Author of the distribution. This overrides
new
's author attribute.
SEE ALSO
LICENSE
Copyright (C) tokuhirom.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
AUTHOR
tokuhirom <tokuhirom@gmail.com>