Skip to content

Commit

Permalink
rename Packages --> Package (#633)
Browse files Browse the repository at this point in the history
* rename Packages --> Package

* Package: added dist_version field

Added the field 'dist_version' to hold the version parsed of
the file value (dist, author, ...).

This is needed as the entries hold the module version which
doesn't always match the distribution one.

* Update module name for tests as well

* fix URL in test

* Another test fix

* hopefully the last test fix
  • Loading branch information
mickeyn authored and oalders committed May 11, 2017
1 parent 4ac0127 commit 79455eb
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 19 deletions.
@@ -1,4 +1,4 @@
package MetaCPAN::Document::Packages;
package MetaCPAN::Document::Package;

use MetaCPAN::Moose;

Expand Down
6 changes: 3 additions & 3 deletions lib/MetaCPAN/Script/Mapping.pm
Expand Up @@ -13,7 +13,7 @@ use MetaCPAN::Script::Mapping::CPAN::Favorite ();
use MetaCPAN::Script::Mapping::CPAN::File ();
use MetaCPAN::Script::Mapping::CPAN::Mirror ();
use MetaCPAN::Script::Mapping::CPAN::Permission ();
use MetaCPAN::Script::Mapping::CPAN::Packages ();
use MetaCPAN::Script::Mapping::CPAN::Package ();
use MetaCPAN::Script::Mapping::CPAN::Rating ();
use MetaCPAN::Script::Mapping::CPAN::Release ();
use MetaCPAN::Script::Mapping::DeployStatement ();
Expand Down Expand Up @@ -411,8 +411,8 @@ sub deploy_mapping {
permission =>
decode_json( MetaCPAN::Script::Mapping::CPAN::Permission::mapping
),
packages =>
decode_json( MetaCPAN::Script::Mapping::CPAN::Packages::mapping
package =>
decode_json( MetaCPAN::Script::Mapping::CPAN::Package::mapping
),
rating =>
decode_json(MetaCPAN::Script::Mapping::CPAN::Rating::mapping),
Expand Down
@@ -1,4 +1,4 @@
package MetaCPAN::Script::Mapping::CPAN::Packages;
package MetaCPAN::Script::Mapping::CPAN::Package;

use strict;
use warnings;
Expand All @@ -17,6 +17,11 @@ sub mapping {
"index" : "not_analyzed",
"type" : "string"
},
"dist_version" : {
"ignore_above" : 2048,
"index" : "not_analyzed",
"type" : "string"
},
"author" : {
"ignore_above" : 2048,
"index" : "not_analyzed",
Expand Down
@@ -1,12 +1,11 @@
package MetaCPAN::Script::Packages;
package MetaCPAN::Script::Package;

use Moose;

use Log::Contextual qw( :log );
use MetaCPAN::Document::Packages ();
use Parse::CPAN::Packages::Fast ();
use IO::Uncompress::Gunzip ();
use CPAN::DistnameInfo ();
use MetaCPAN::Document::Package ();
use IO::Uncompress::Gunzip ();
use CPAN::DistnameInfo ();

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

Expand Down Expand Up @@ -47,7 +46,7 @@ sub index_packages {

my $bulk_helper = $self->es->bulk_helper(
index => $self->index->name,
type => 'packages',
type => 'package',
);

# read the rest of the file line-by-line (too big to slurp)
Expand All @@ -64,6 +63,7 @@ sub index_packages {
file => $file,
author => $distinfo->cpanid,
distribution => $distinfo->dist,
dist_version => $distinfo->version,
};

$bulk_helper->update(
Expand All @@ -86,10 +86,10 @@ __PACKAGE__->meta->make_immutable;
=head1 SYNOPSIS
Parse out CPAN packages details.
Parse out CPAN package details (02packages.details).
my $packages = MetaCPAN::Script::Packages->new;
my $result = $packages->index_packages;
my $package = MetaCPAN::Script::Package->new;
my $result = $package->index_packages;
=head2 index_packages
Expand Down
@@ -1,4 +1,4 @@
package MetaCPAN::Server::Controller::Packages;
package MetaCPAN::Server::Controller::Package;

use Moose;
use namespace::autoclean;
Expand Down
4 changes: 2 additions & 2 deletions t/lib/MetaCPAN/TestServer.pm
Expand Up @@ -8,7 +8,7 @@ use MetaCPAN::Script::CPANTesters ();
use MetaCPAN::Script::First ();
use MetaCPAN::Script::Latest ();
use MetaCPAN::Script::Mapping ();
use MetaCPAN::Script::Packages ();
use MetaCPAN::Script::Package ();
use MetaCPAN::Script::Permission ();
use MetaCPAN::Script::Release ();
use MetaCPAN::Server ();
Expand Down Expand Up @@ -234,7 +234,7 @@ sub index_packages {
my $self = shift;

ok(
MetaCPAN::Script::Packages->new_with_options(
MetaCPAN::Script::Package->new_with_options(
%{ $self->_config },

# Eventually maybe move this to use the DarkPAN 06perms
Expand Down
2 changes: 1 addition & 1 deletion t/packages.t → t/package.t
Expand Up @@ -4,7 +4,7 @@ use warnings;
use Test::More;
use MetaCPAN::Script::Runner;

local @ARGV = ('packages');
local @ARGV = ('package');

# uses ./t/var/tmp/fakecpan/modules/02packages.details.txt
ok( MetaCPAN::Script::Runner->run, 'runs' );
Expand Down
Expand Up @@ -14,7 +14,7 @@ test_psgi app, sub {

{
my $module_name = 'CPAN::Test::Dummy::Perl5::VersionBump';
ok( my $res = $cb->( GET "/packages/$module_name" ),
ok( my $res = $cb->( GET "/package/$module_name" ),
"GET $module_name" );
is( $res->code, 200, '200 OK' );

Expand All @@ -27,6 +27,7 @@ test_psgi app, sub {
'M/MI/MIYAGAWA/CPAN-Test-Dummy-Perl5-VersionBump-0.02.tar.gz',
author => 'MIYAGAWA',
distribution => 'CPAN-Test-Dummy-Perl5-VersionBump',
dist_version => '0.02',
},
'Has the correct 02packages info'
);
Expand Down

0 comments on commit 79455eb

Please sign in to comment.