line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CPAN::Packager::ModuleNameResolver; |
2
|
2
|
|
|
2
|
|
14
|
use Mouse; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
20
|
|
3
|
2
|
|
|
2
|
|
2969
|
use LWP::UserAgent; |
|
2
|
|
|
|
|
113406
|
|
|
2
|
|
|
|
|
91
|
|
4
|
2
|
|
|
2
|
|
1475
|
use CPAN::Packager::ListUtil qw(any); |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
200
|
|
5
|
2
|
|
|
2
|
|
15
|
use Log::Log4perl qw(:easy); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
24
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
has 'ua' => ( |
8
|
|
|
|
|
|
|
is => 'rw', |
9
|
|
|
|
|
|
|
default => sub { |
10
|
|
|
|
|
|
|
my $ua = LWP::UserAgent->new; |
11
|
|
|
|
|
|
|
$ua->env_proxy; |
12
|
|
|
|
|
|
|
$ua; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub resolve { |
17
|
0
|
|
|
0
|
0
|
|
my ( $self, $module ) = @_; |
18
|
0
|
0
|
|
0
|
|
|
return $module if any { $module eq $_} ('perl', 'PerlInterp'); |
|
0
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
my $res = $self->get_or_retry( |
21
|
|
|
|
|
|
|
"http://search.cpan.org/search?query=$module&mode=module"); |
22
|
0
|
0
|
|
|
|
|
return unless $res->is_success; |
23
|
0
|
|
|
|
|
|
my ($resolved_module) |
24
|
|
|
|
|
|
|
= $res->content =~ m{}; |
25
|
|
|
|
|
|
|
|
26
|
0
|
0
|
|
|
|
|
return unless $resolved_module; |
27
|
0
|
0
|
|
|
|
|
$resolved_module =~ s/-/::/g unless $resolved_module eq 'libwww-perl'; |
28
|
0
|
|
|
|
|
|
DEBUG( ">>> resolved module name is ${resolved_module} and original module name is ${module}" |
29
|
|
|
|
|
|
|
); |
30
|
0
|
|
|
|
|
|
return $resolved_module; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub get_or_retry { |
34
|
0
|
|
|
0
|
0
|
|
my ( $self, $url ) = @_; |
35
|
0
|
|
|
|
|
|
my $res = $self->ua->get($url); |
36
|
0
|
0
|
|
|
|
|
$res->is_success ? $res : $self->ua->get($url); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
__END__ |