| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
17
|
|
|
17
|
|
167697
|
use strict; |
|
|
17
|
|
|
|
|
42
|
|
|
|
17
|
|
|
|
|
687
|
|
|
2
|
17
|
|
|
17
|
|
82
|
use warnings; |
|
|
17
|
|
|
|
|
29
|
|
|
|
17
|
|
|
|
|
1487
|
|
|
3
|
|
|
|
|
|
|
package MetaCPAN::API::Source; |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.52'; |
|
6
|
|
|
|
|
|
|
|
|
7
|
17
|
|
|
17
|
|
103
|
use Carp; |
|
|
17
|
|
|
|
|
31
|
|
|
|
17
|
|
|
|
|
1712
|
|
|
8
|
17
|
|
|
17
|
|
486
|
use Moo::Role; |
|
|
17
|
|
|
|
|
13001
|
|
|
|
17
|
|
|
|
|
112
|
|
|
9
|
17
|
|
|
17
|
|
9381
|
use namespace::autoclean; |
|
|
17
|
|
|
|
|
17201
|
|
|
|
17
|
|
|
|
|
127
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# /source/{author}/{release}/{path} |
|
12
|
|
|
|
|
|
|
sub source { |
|
13
|
3
|
|
|
3
|
1
|
2248
|
my $self = shift; |
|
14
|
3
|
100
|
|
|
|
13
|
my %opts = @_ ? @_ : (); |
|
15
|
3
|
|
|
|
|
4
|
my $url = ''; |
|
16
|
3
|
|
|
|
|
5
|
my $error = "Provide 'author' and 'release' and 'path'"; |
|
17
|
|
|
|
|
|
|
|
|
18
|
3
|
100
|
|
|
|
133
|
%opts or croak $error; |
|
19
|
|
|
|
|
|
|
|
|
20
|
2
|
100
|
66
|
|
|
12
|
if ( |
|
|
|
|
66
|
|
|
|
|
|
21
|
|
|
|
|
|
|
defined ( my $author = $opts{'author'} ) && |
|
22
|
|
|
|
|
|
|
defined ( my $release = $opts{'release'} ) && |
|
23
|
|
|
|
|
|
|
defined ( my $path = $opts{'path'} ) |
|
24
|
|
|
|
|
|
|
) { |
|
25
|
1
|
|
|
|
|
3
|
$url = "source/$author/$release/$path"; |
|
26
|
|
|
|
|
|
|
} else { |
|
27
|
1
|
|
|
|
|
77
|
croak $error; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
1
|
|
|
|
|
21
|
$url = $self->base_url . "/$url"; |
|
31
|
|
|
|
|
|
|
|
|
32
|
1
|
|
|
|
|
28
|
my $result = $self->ua->get($url); |
|
33
|
1
|
50
|
|
|
|
328768
|
$result->{'success'} |
|
34
|
|
|
|
|
|
|
or croak "Failed to fetch '$url': $result->{'reason'} - $result->{'content'}"; |
|
35
|
|
|
|
|
|
|
|
|
36
|
1
|
|
|
|
|
35
|
return $result->{'content'}; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
__END__ |