Skip to content

Commit 07643e3

Browse files
authored
Merge pull request #1292 from metacpan/haarg/cleanup
various cleanups
2 parents d924853 + 7c9d5c7 commit 07643e3

File tree

16 files changed

+51
-233
lines changed

16 files changed

+51
-233
lines changed

app.psgi

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ my $static
6161

6262
my $urlmap = Plack::App::URLMap->new;
6363
$urlmap->map( '/static' => $static );
64-
$urlmap->map( '/' => MetaCPAN::Server->app );
64+
if ( $ENV{PLACK_ENV} && $ENV{PLACK_ENV} eq 'development' ) {
65+
$urlmap->map( '/v1' => MetaCPAN::Server->app );
66+
}
67+
$urlmap->map( '/' => MetaCPAN::Server->app );
6568

6669
return $urlmap->to_app;

cpanfile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ requires 'Encoding::FixLatin';
4545
requires 'Encoding::FixLatin::XS';
4646
requires 'EV';
4747
requires 'Exporter', '5.74';
48-
requires 'ExtUtils::HasCompiler';
4948
requires 'File::Basename';
5049
requires 'File::Copy';
5150
requires 'File::Find';
@@ -58,7 +57,6 @@ requires 'File::stat';
5857
requires 'File::Temp';
5958
requires 'FindBin';
6059
requires 'Getopt::Long::Descriptive', '0.103';
61-
requires 'Git::Helpers', '1.000001';
6260
requires 'Gravatar::URL';
6361
requires 'Hash::Merge::Simple';
6462
requires 'HTML::Entities';
@@ -115,9 +113,7 @@ requires 'PAUSE::Permissions', '0.17';
115113
requires 'PerlIO::gzip';
116114
requires 'Plack', '1.0048';
117115
requires 'Plack::App::Directory';
118-
requires 'Plack::Middleware::Header';
119116
requires 'Plack::Middleware::ReverseProxy';
120-
requires 'Plack::Middleware::Rewrite';
121117
requires 'Plack::Middleware::Session';
122118
requires 'Plack::Session::Store';
123119
requires 'Pod::Markdown', '3.300';
@@ -169,5 +165,4 @@ requires 'Test::Routine', '0.012';
169165
requires 'Test::Vars', '0.015';
170166

171167
# author requirements
172-
requires 'Plack::Middleware::Rewrite';
173168
requires 'App::perlimports';

cpanfile.snapshot

Lines changed: 0 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,6 @@ DISTRIBUTIONS
229229
requirements:
230230
B 0
231231
ExtUtils::MakeMaker 0
232-
Browser-Open-0.04
233-
pathname: C/CF/CFRANKS/Browser-Open-0.04.tar.gz
234-
provides:
235-
Browser::Open 0.04
236-
requirements:
237-
ExtUtils::MakeMaker 0
238-
Test::More 0.92
239-
parent 0
240232
CGI-Simple-1.281
241233
pathname: M/MA/MANWAR/CGI-Simple-1.281.tar.gz
242234
provides:
@@ -2320,23 +2312,6 @@ DISTRIBUTIONS
23202312
File::Spec 0
23212313
IO::File 0
23222314
perl 5.006
2323-
ExtUtils-HasCompiler-0.025
2324-
pathname: L/LE/LEONT/ExtUtils-HasCompiler-0.025.tar.gz
2325-
provides:
2326-
ExtUtils::HasCompiler 0.025
2327-
requirements:
2328-
Carp 0
2329-
DynaLoader 0
2330-
Exporter 0
2331-
ExtUtils::MakeMaker 0
2332-
ExtUtils::Mksymlists 0
2333-
File::Basename 0
2334-
File::Spec::Functions 0
2335-
File::Temp 0
2336-
base 0
2337-
perl 5.006
2338-
strict 0
2339-
warnings 0
23402315
ExtUtils-Helpers-0.028
23412316
pathname: L/LE/LEONT/ExtUtils-Helpers-0.028.tar.gz
23422317
provides:
@@ -2627,47 +2602,6 @@ DISTRIBUTIONS
26272602
perl 5.012
26282603
strict 0
26292604
warnings 0
2630-
Git-Helpers-1.000001
2631-
pathname: O/OA/OALDERS/Git-Helpers-1.000001.tar.gz
2632-
provides:
2633-
Git::Helpers 1.000001
2634-
Git::Helpers::CPAN 1.000001
2635-
requirements:
2636-
Browser::Open 0
2637-
Capture::Tiny 0
2638-
Carp 0
2639-
ExtUtils::MakeMaker 0
2640-
File::pushd 0
2641-
Getopt::Long 0
2642-
Git::Sub 0
2643-
MetaCPAN::Client 2.029000
2644-
Moo 0
2645-
MooX::Options 0
2646-
Pod::Usage 0
2647-
String::Trim 0
2648-
Sub::Exporter 0
2649-
Term::Choose 1.743
2650-
Try::Tiny 0
2651-
Types::Standard 0
2652-
URI 0
2653-
URI::Heuristic 0
2654-
URI::git 0
2655-
perl v5.12.0
2656-
strict 0
2657-
warnings 0
2658-
Git-Sub-0.163320
2659-
pathname: D/DO/DOLMEN/Git-Sub-0.163320.tar.gz
2660-
provides:
2661-
Git::Sub 0.163320
2662-
requirements:
2663-
Carp 0
2664-
ExtUtils::MakeMaker 0
2665-
File::Which 0
2666-
System::Sub 0.162800
2667-
perl 5.006
2668-
strict 0
2669-
subs 0
2670-
warnings 0
26712605
Gravatar-URL-1.07
26722606
pathname: M/MS/MSCHWERN/Gravatar-URL-1.07.tar.gz
26732607
provides:
@@ -6128,17 +6062,6 @@ DISTRIBUTIONS
61286062
parent 0
61296063
strict 0
61306064
warnings 0
6131-
Plack-Middleware-Header-0.04
6132-
pathname: C/CH/CHIBA/Plack-Middleware-Header-0.04.tar.gz
6133-
provides:
6134-
Plack::Middleware::Header 0.04
6135-
requirements:
6136-
ExtUtils::MakeMaker 6.42
6137-
Filter::Util::Call 0
6138-
Plack::Middleware 0
6139-
Test::More 0
6140-
parent 0
6141-
perl 5.008001
61426065
Plack-Middleware-MethodOverride-0.20
61436066
pathname: M/MI/MIYAGAWA/Plack-Middleware-MethodOverride-0.20.tar.gz
61446067
provides:
@@ -6175,18 +6098,6 @@ DISTRIBUTIONS
61756098
Test::More 0
61766099
parent 0
61776100
perl 5.008001
6178-
Plack-Middleware-Rewrite-2.102
6179-
pathname: A/AR/ARISTOTLE/Plack-Middleware-Rewrite-2.102.tar.gz
6180-
provides:
6181-
Plack::Middleware::Rewrite 2.102
6182-
requirements:
6183-
Plack 0.9942
6184-
Plack::Middleware 0
6185-
Plack::Request 0
6186-
Plack::Util 0
6187-
Plack::Util::Accessor 0
6188-
overload 0
6189-
perl 5.006
61906101
Plack-Middleware-Session-0.34
61916102
pathname: M/MI/MIYAGAWA/Plack-Middleware-Session-0.34.tar.gz
61926103
provides:
@@ -6676,18 +6587,6 @@ DISTRIBUTIONS
66766587
perl 5.012
66776588
strict 0
66786589
warnings 0
6679-
String-Trim-0.005
6680-
pathname: D/DO/DOHERTY/String-Trim-0.005.tar.gz
6681-
provides:
6682-
String::Trim 0.005
6683-
requirements:
6684-
Data::Dumper 0
6685-
Exporter 5.57
6686-
ExtUtils::MakeMaker 6.31
6687-
File::Find 0
6688-
File::Temp 0
6689-
Test::Builder 0.94
6690-
Test::More 0.94
66916590
Sub-Exporter-0.991
66926591
pathname: R/RJ/RJBS/Sub-Exporter-0.991.tar.gz
66936592
provides:
@@ -6811,23 +6710,6 @@ DISTRIBUTIONS
68116710
requirements:
68126711
Call::Context 0
68136712
ExtUtils::MakeMaker 0
6814-
System-Sub-0.162800
6815-
pathname: D/DO/DOLMEN/System-Sub-0.162800.tar.gz
6816-
provides:
6817-
System::Sub 0.162800
6818-
System::Sub::AutoLoad 0.162800
6819-
requirements:
6820-
Carp 0
6821-
ExtUtils::MakeMaker 0
6822-
File::Which 0
6823-
IPC::Run 0
6824-
Scalar::Util 1.11
6825-
Sub::Name 0
6826-
Symbol 0
6827-
constant 0
6828-
perl 5.006
6829-
strict 0
6830-
warnings 0
68316713
TOML-Tiny-0.18
68326714
pathname: O/OA/OALDERS/TOML-Tiny-0.18.tar.gz
68336715
provides:
@@ -6856,34 +6738,6 @@ DISTRIBUTIONS
68566738
Scalar::Util 1.14
68576739
perl 5.006
68586740
strict 0
6859-
Term-Choose-1.765
6860-
pathname: K/KU/KUERBIS/Term-Choose-1.765.tar.gz
6861-
provides:
6862-
Term::Choose 1.765
6863-
Term::Choose::Constants 1.765
6864-
Term::Choose::LineFold 1.765
6865-
Term::Choose::LineFold::CharWidthAmbiguousWide 1.765
6866-
Term::Choose::LineFold::CharWidthDefault 1.765
6867-
Term::Choose::Linux 1.765
6868-
Term::Choose::Opt::Mouse 1.765
6869-
Term::Choose::Opt::Search 1.765
6870-
Term::Choose::Opt::SkipItems 1.765
6871-
Term::Choose::Screen 1.765
6872-
Term::Choose::ValidateOptions 1.765
6873-
Term::Choose::Win32 1.765
6874-
requirements:
6875-
Carp 0
6876-
Exporter 0
6877-
ExtUtils::MakeMaker 0
6878-
File::Spec::Functions 0
6879-
FindBin 0
6880-
Test::Fatal 0
6881-
Test::More 0
6882-
constant 0
6883-
lib 0
6884-
perl 5.010000
6885-
strict 0
6886-
warnings 0
68876741
Term-Size-Any-0.002
68886742
pathname: F/FE/FERREIRA/Term-Size-Any-0.002.tar.gz
68896743
provides:
@@ -7962,15 +7816,6 @@ DISTRIBUTIONS
79627816
URI 1.40
79637817
URI::Nested 0.10
79647818
perl 5.008001
7965-
URI-git-0.02
7966-
pathname: M/MI/MIYAGAWA/URI-git-0.02.tar.gz
7967-
provides:
7968-
URI::git 0.02
7969-
requirements:
7970-
ExtUtils::MakeMaker 6.42
7971-
Filter::Util::Call 0
7972-
Test::More 0
7973-
URI 0
79747819
URI-ws-0.03
79757820
pathname: P/PL/PLICEASE/URI-ws-0.03.tar.gz
79767821
provides:

lib/MetaCPAN/API/Plugin/Model.pm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use Mojo::Base 'Mojolicious::Plugin';
55
use Carp ();
66

77
# Models from the catalyst app
8-
use MetaCPAN::Model::Search ();
8+
use MetaCPAN::Query::Search ();
99

1010
# New models
1111
use MetaCPAN::API::Model::Cover ();
@@ -21,9 +21,9 @@ has download => sub {
2121

2222
has search => sub {
2323
my $self = shift;
24-
return MetaCPAN::Model::Search->new(
25-
es => $self->app->es,
26-
index => 'cpan',
24+
return MetaCPAN::Query::Search->new(
25+
es => $self->app->es,
26+
index_name => 'cpan',
2727
);
2828
};
2929

lib/MetaCPAN/Model/Search.pm renamed to lib/MetaCPAN/Query/Search.pm

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package MetaCPAN::Model::Search;
1+
package MetaCPAN::Query::Search;
22

33
use MetaCPAN::Moose;
44

@@ -10,18 +10,7 @@ use MetaCPAN::Types::TypeTiny qw( Object Str );
1010
use MetaCPAN::Util qw( single_valued_arrayref_to_scalar true false );
1111
use MooseX::StrictConstructor;
1212

13-
has es => (
14-
is => 'ro',
15-
isa => Object,
16-
handles => { _run_query => 'search', },
17-
required => 1,
18-
);
19-
20-
has index => (
21-
is => 'ro',
22-
isa => Str,
23-
required => 1,
24-
);
13+
with 'MetaCPAN::Query::Role::Common';
2514

2615
const my $RESULTS_PER_RUN => 200;
2716
const my @ROGUE_DISTRIBUTIONS => qw(
@@ -368,8 +357,8 @@ sub build_query {
368357

369358
sub run_query {
370359
my ( $self, $type, $es_query ) = @_;
371-
return $self->_run_query(
372-
index => $self->index,
360+
return $self->es->search(
361+
index => $self->index_name,
373362
type => $type,
374363
body => $es_query,
375364
search_type => 'dfs_query_then_fetch',

lib/MetaCPAN/Role/HasConfig.pm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use Moose::Role;
44

55
use MetaCPAN::Server::Config ();
66
use MetaCPAN::Types::TypeTiny qw( HashRef );
7-
use MetaCPAN::Util qw( checkout_root );
87

98
# Done like this so can be required by a role
109
sub config {

lib/MetaCPAN/Role/Script.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use IO::Prompt::Tiny qw( prompt );
99
use Log::Contextual qw( :log :dlog );
1010
use MetaCPAN::Model ();
1111
use MetaCPAN::Types::TypeTiny qw( Bool HashRef Int Path Str );
12-
use MetaCPAN::Util qw( checkout_root );
12+
use MetaCPAN::Util qw( root_dir );
1313
use Mojo::Server ();
1414
use Term::ANSIColor qw( colored );
1515

@@ -123,7 +123,7 @@ has home => (
123123
isa => Path,
124124
lazy => 1,
125125
coerce => 1,
126-
default => sub { checkout_root() },
126+
default => sub { root_dir() },
127127
);
128128

129129
has quarantine => (

lib/MetaCPAN/Server.pm

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,6 @@ sub app {
107107
};
108108
};
109109

110-
if ( $ENV{PLACK_ENV} && $ENV{PLACK_ENV} eq 'development' ) {
111-
enable 'Rewrite', rules => sub {s{^/?v\d+/}{}};
112-
}
113-
114110
$class->apply_default_middlewares( $class->psgi_app );
115111
};
116112
}

lib/MetaCPAN/Server/Config.pm

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,15 @@ package MetaCPAN::Server::Config;
33
use warnings;
44
use strict;
55

6-
use Config::ZOMG ();
7-
use FindBin ();
8-
use Module::Runtime qw( require_module );
6+
use Config::ZOMG ();
7+
use MetaCPAN::Util qw(root_dir);
98

109
sub config {
11-
my $config = _zomg("$FindBin::RealBin/..");
12-
return $config if $config;
13-
14-
require_module('Git::Helpers');
15-
$config = _zomg( Git::Helpers::checkout_root() );
10+
my $root = root_dir();
11+
my $config = _zomg($root);
1612

1713
if ( !$config ) {
18-
die "Couldn't find config file in $FindBin::RealBin/.. or "
19-
. Git::Helpers::checkout_root();
14+
die "Couldn't find config file in $root";
2015
}
2116

2217
return $config;

0 commit comments

Comments
 (0)