CPAN-Local
view release on metacpan or search on metacpan
lib/CPAN/Local/Plugin/MailRc.pm view on Meta::CPAN
package CPAN::Local::Plugin::MailRc;
{
$CPAN::Local::Plugin::MailRc::VERSION = '0.010';
}
# ABSTRACT: Update 01mailrc.txt
use strict;
use warnings;
use CPAN::Index::API::File::MailRc;
use CPAN::DistnameInfo;
use IO::String;
use URI;
use Path::Class qw(file dir);
use Carp qw(croak);
use Path::Class::URI;
use List::Util qw(first);
use Regexp::Common qw(URI);
use Compress::Zlib qw(gzopen Z_STREAM_END), '$gzerrno';
use namespace::autoclean;
use Moose;
use MooseX::CoercePerAttribute;
extends 'CPAN::Local::Plugin';
with qw(CPAN::Local::Role::Initialise CPAN::Local::Role::Index);
has 'root' =>
(
is => 'ro',
isa => 'Str',
required => 1,
);
has 'source' =>
(
is => 'ro',
isa => 'ArrayRef[Str]',
traits => [qw(Array CoercePerAttribute)],
handles => { sources => 'elements' },
coerce => { Str => sub { [$_] } }
);
has 'no_update' =>
(
is => 'ro',
isa => 'Bool',
);
sub initialise
{
my $self = shift;
dir($self->root)->mkpath;
my $mailrc = CPAN::Index::API::File::MailRc->new(
repo_path => $self->root,
);
$mailrc->write_to_tarball;
}
sub index
{
my ($self, @distros) = @_;
return if $self->no_update;
my ( @authors, %seen_authors, %authors_in_repo );
# extract all author ids form the local 02packages.details file
$authors_in_repo{$_}++ for map {
CPAN::DistnameInfo->new($_->{distribution})->cpanid
} CPAN::Index::API::File::PackagesDetails->read_from_repo_path($self->root)->packages;
# also check the newly injected distros
$authors_in_repo{$_->{authorid}}++ for @distros;
foreach my $source ( $self->sources )
{
# convert a local path to a 'file://' uri for LWP::Simple::get()
# (this whole business can be handled better by IO::All)
( run in 0.864 second using v1.01-cache-2.11-cpan-39bf76dae61 )