Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Packages: add dist/author info
To allow better correlation of author/dist info to the entries
in 02packages.details - we can easily parse them out of the
'file' field using CPAN::DistnameInfo.
  • Loading branch information
mickeyn committed May 8, 2017
1 parent 7344e4e commit bad2f3e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
10 changes: 10 additions & 0 deletions lib/MetaCPAN/Script/Mapping/CPAN/Packages.pm
Expand Up @@ -12,6 +12,16 @@ sub mapping {
"index" : "not_analyzed",
"type" : "string"
},
"distribution" : {
"ignore_above" : 2048,
"index" : "not_analyzed",
"type" : "string"
},
"author" : {
"ignore_above" : 2048,
"index" : "not_analyzed",
"type" : "string"
},
"version" : {
"ignore_above" : 2048,
"index" : "not_analyzed",
Expand Down
10 changes: 7 additions & 3 deletions lib/MetaCPAN/Script/Packages.pm
Expand Up @@ -6,6 +6,7 @@ use Log::Contextual qw( :log );
use MetaCPAN::Document::Packages ();
use Parse::CPAN::Packages::Fast ();
use IO::Uncompress::Gunzip ();
use CPAN::DistnameInfo ();

with 'MooseX::Getopt', 'MetaCPAN::Role::Script';

Expand Down Expand Up @@ -55,11 +56,14 @@ sub index_packages {
chomp($line);

my ( $name, $version, $file ) = split /\s+/ => $line;
my $distinfo = CPAN::DistnameInfo->new($file);

my $doc = +{
module_name => $name,
version => $version,
file => $file,
module_name => $name,
version => $version,
file => $file,
author => $distinfo->cpanid,
distribution => $distinfo->dist,
};

$bulk_helper->update(
Expand Down
2 changes: 2 additions & 0 deletions t/server/controller/packages.t
Expand Up @@ -25,6 +25,8 @@ test_psgi app, sub {
version => '0.02',
file =>
'M/MI/MIYAGAWA/CPAN-Test-Dummy-Perl5-VersionBump-0.02.tar.gz',
author => 'MIYAGAWA',
distribution => 'CPAN-Test-Dummy-Perl5-VersionBump',
},
'Has the correct 02packages info'
);
Expand Down

0 comments on commit bad2f3e

Please sign in to comment.