File tree Expand file tree Collapse file tree 2 files changed +37
-26
lines changed Expand file tree Collapse file tree 2 files changed +37
-26
lines changed Original file line number Diff line number Diff line change
1
+ package MetaCPAN::Config ;
2
+
3
+ use warnings;
4
+ use strict;
5
+
6
+ use FindBin ();
7
+ use Config::ZOMG ();
8
+ use Module::Runtime qw( require_module ) ;
9
+
10
+ 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() );
16
+
17
+ return $config if $config ;
18
+
19
+ die " Couldn't find config file in $FindBin::RealBin /.. or "
20
+ . Git::Helpers::checkout_root();
21
+ }
22
+
23
+ sub _zomg {
24
+ my $path = shift ;
25
+
26
+ my $config = Config::ZOMG-> new(
27
+ local_suffix => $ENV {HARNESS_ACTIVE } ? ' testing' : ' local' ,
28
+ name => ' metacpan_server' ,
29
+ path => $path ,
30
+ );
31
+
32
+ return $config -> open ;
33
+ }
34
+
35
+ 1;
Original file line number Diff line number Diff line change @@ -2,10 +2,8 @@ package MetaCPAN::Role::HasConfig;
2
2
3
3
use Moose::Role;
4
4
5
- use FindBin ();
6
- use Config::ZOMG ();
5
+ use MetaCPAN::Config ();
7
6
use MetaCPAN::Types::TypeTiny qw( HashRef ) ;
8
- use Module::Runtime qw( require_module ) ;
9
7
10
8
# Done like this so can be required by a role
11
9
sub config {
@@ -20,30 +18,8 @@ has _config => (
20
18
);
21
19
22
20
sub _build_config {
23
- my $self = shift ;
24
- my $config = $self -> _zomg(" $FindBin::RealBin /.." );
25
- return $config if $config ;
26
-
27
- require_module(' Git::Helpers' );
28
- $config = $self -> _zomg( Git::Helpers::checkout_root() );
29
-
30
- return $config if $config ;
31
-
32
- die " Couldn't find config file in $FindBin::RealBin /.. or "
33
- . Git::Helpers::checkout_root();
34
- }
35
-
36
- sub _zomg {
37
21
my $self = shift ;
38
- my $path = shift ;
39
-
40
- my $config = Config::ZOMG-> new(
41
- local_suffix => $ENV {HARNESS_ACTIVE } ? ' testing' : ' local' ,
42
- name => ' metacpan_server' ,
43
- path => $path ,
44
- );
45
-
46
- return $config -> open ;
22
+ return MetaCPAN::Config::config();
47
23
}
48
24
49
25
1;
You can’t perform that action at this time.
0 commit comments