Skip to content

Commit

Permalink
Make bulk_size settable in Release script.
Browse files Browse the repository at this point in the history
  • Loading branch information
oalders committed Apr 19, 2015
1 parent 3b85d58 commit 7f7af78
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
25 changes: 16 additions & 9 deletions lib/MetaCPAN/Script/Release.pm
Expand Up @@ -14,7 +14,7 @@ use LWP::UserAgent;
use Log::Contextual qw( :log :dlog );
use MetaCPAN::Document::Author;
use MetaCPAN::Model::Release;
use MetaCPAN::Types qw( Dir );
use MetaCPAN::Types qw( Bool Dir HashRef Int Str );
use Moose;
use PerlIO::gzip;
use Try::Tiny;
Expand All @@ -23,41 +23,41 @@ with 'MetaCPAN::Role::Script', 'MooseX::Getopt';

has latest => (
is => 'ro',
isa => 'Bool',
isa => Bool,
default => 0,
documentation => q{run 'latest' script after each release},
);

has age => (
is => 'ro',
isa => 'Int',
isa => Int,
documentation => 'index releases no older than x hours (undef)',
);

has children => (
is => 'ro',
isa => 'Int',
isa => Int,
default => 2,
documentation => 'number of worker processes (2)',
);

has skip => (
is => 'ro',
isa => 'Bool',
isa => Bool,
default => 0,
documentation => 'skip already indexed modules (0)',
);

has status => (
is => 'ro',
isa => 'Str',
isa => Str,
default => 'cpan',
documentation => 'status of the indexed releases (cpan)',
);

has detect_backpan => (
is => 'ro',
isa => 'Bool',
isa => Bool,
default => 0,
documentation => 'enable when indexing from a backpan',
);
Expand All @@ -69,11 +69,18 @@ has backpan_index => (

has perms => (
is => 'ro',
isa => 'HashRef',
isa => HashRef,
lazy_build => 1,
traits => ['NoGetopt'],
);

has _bulk_size => (
is => 'ro',
isa => Int,
init_arg => 'bulk_size',
default => 10,
);

sub run {
my $self = shift;
my ( undef, @args ) = @{ $self->extra_argv };
Expand Down Expand Up @@ -178,7 +185,7 @@ sub import_archive {

my $cpan = $self->index;
my $d = CPAN::DistnameInfo->new($archive_path);
my $bulk = $cpan->bulk( size => 10 );
my $bulk = $cpan->bulk( size => $self->_bulk_size );

my $model = MetaCPAN::Model::Release->new(
bulk => $bulk,
Expand Down
2 changes: 1 addition & 1 deletion t/darkpan.t
Expand Up @@ -14,6 +14,6 @@ my $server = MetaCPAN::TestServer->new( cpan_dir => $darkpan->base_dir );
# create DarkPAN
$darkpan->run;

$server->index_releases;
$server->index_releases( bulk_size => 1 );

done_testing();
8 changes: 6 additions & 2 deletions t/lib/MetaCPAN/TestServer.pm
Expand Up @@ -145,10 +145,14 @@ sub put_mappings {

sub index_releases {
my $self = shift;
my %args = @_;

local @ARGV = ( 'release', $self->_cpan_dir, '--children', 0 );
ok( MetaCPAN::Script::Release->new_with_options( $self->_config )->run,
'index fakecpan' );
ok(
MetaCPAN::Script::Release->new_with_options( %{ $self->_config },
%args )->run,
'index fakecpan'
);
}

sub set_latest {
Expand Down

0 comments on commit 7f7af78

Please sign in to comment.