line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CPAN::Flatten::Distribution::Factory; |
2
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
28
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
4
|
1
|
|
|
1
|
|
867
|
use HTTP::Tiny; |
|
1
|
|
|
|
|
42124
|
|
|
1
|
|
|
|
|
33
|
|
5
|
1
|
|
|
1
|
|
466
|
use CPAN::Meta::YAML; |
|
1
|
|
|
|
|
3746
|
|
|
1
|
|
|
|
|
45
|
|
6
|
1
|
|
|
1
|
|
324
|
use CPAN::Flatten::Distribution; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
193
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
my $SELF = __PACKAGE__->_new( |
9
|
|
|
|
|
|
|
distfile_url => "http://cpanmetadb-provides.herokuapp.com/v1.2/package", |
10
|
|
|
|
|
|
|
ua => HTTP::Tiny->new(timeout => 10), |
11
|
|
|
|
|
|
|
); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub from_pacakge { |
14
|
0
|
|
|
0
|
0
|
0
|
my ($class, $package, $version) = @_; |
15
|
0
|
|
|
|
|
0
|
my $need_reason = wantarray; |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
0
|
my ($distfile, $provides, $requirements) = $SELF->fetch_distfile($package, $version); |
18
|
0
|
0
|
|
|
|
0
|
if (!$distfile) { |
19
|
0
|
0
|
|
|
|
0
|
return unless $need_reason; |
20
|
0
|
|
|
|
|
0
|
return (undef, "failed to fetch distfile for $package"); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
CPAN::Flatten::Distribution->new( |
24
|
0
|
|
|
|
|
0
|
distfile => $distfile, |
25
|
|
|
|
|
|
|
provides => $provides, |
26
|
|
|
|
|
|
|
requirements => $requirements, |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub _new { |
31
|
1
|
|
|
1
|
|
79
|
my ($class, %opt) = @_; |
32
|
1
|
|
|
|
|
3
|
bless {%opt}, $class; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub fetch_distfile { |
36
|
0
|
|
|
0
|
0
|
|
my ($self, $package, $version) = @_; |
37
|
0
|
|
|
|
|
|
my $res = $self->{ua}->get( $self->{distfile_url} . "/$package" ); |
38
|
0
|
0
|
|
|
|
|
return unless $res->{success}; |
39
|
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
|
if (my $yaml = CPAN::Meta::YAML->read_string($res->{content})) { |
41
|
0
|
0
|
|
|
|
|
my $meta = $yaml->[0] or return; |
42
|
0
|
|
|
|
|
|
return ($meta->{distfile}, $meta->{provides}, $meta->{requirements}); |
43
|
|
|
|
|
|
|
} |
44
|
0
|
|
|
|
|
|
return; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |