line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
15
|
|
|
15
|
|
6098
|
use strict; |
|
15
|
|
|
|
|
34
|
|
|
15
|
|
|
|
|
389
|
|
2
|
15
|
|
|
15
|
|
71
|
use warnings; |
|
15
|
|
|
|
|
32
|
|
|
15
|
|
|
|
|
635
|
|
3
|
|
|
|
|
|
|
package MetaCPAN::API::Source; |
4
|
|
|
|
|
|
|
# ABSTRACT: Source information for MetaCPAN::API |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.51'; |
7
|
|
|
|
|
|
|
|
8
|
15
|
|
|
15
|
|
79
|
use Carp; |
|
15
|
|
|
|
|
31
|
|
|
15
|
|
|
|
|
676
|
|
9
|
15
|
|
|
15
|
|
77
|
use Moo::Role; |
|
15
|
|
|
|
|
28
|
|
|
15
|
|
|
|
|
80
|
|
10
|
15
|
|
|
15
|
|
4653
|
use namespace::autoclean; |
|
15
|
|
|
|
|
33
|
|
|
15
|
|
|
|
|
94
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# /source/{author}/{release}/{path} |
13
|
|
|
|
|
|
|
sub source { |
14
|
3
|
|
|
3
|
1
|
2813
|
my $self = shift; |
15
|
3
|
100
|
|
|
|
18
|
my %opts = @_ ? @_ : (); |
16
|
3
|
|
|
|
|
6
|
my $url = ''; |
17
|
3
|
|
|
|
|
7
|
my $error = "Provide 'author' and 'release' and 'path'"; |
18
|
|
|
|
|
|
|
|
19
|
3
|
100
|
|
|
|
143
|
%opts or croak $error; |
20
|
|
|
|
|
|
|
|
21
|
2
|
100
|
66
|
|
|
25
|
if ( |
|
|
|
66
|
|
|
|
|
22
|
|
|
|
|
|
|
defined ( my $author = $opts{'author'} ) && |
23
|
|
|
|
|
|
|
defined ( my $release = $opts{'release'} ) && |
24
|
|
|
|
|
|
|
defined ( my $path = $opts{'path'} ) |
25
|
|
|
|
|
|
|
) { |
26
|
1
|
|
|
|
|
5
|
$url = "source/$author/$release/$path"; |
27
|
|
|
|
|
|
|
} else { |
28
|
1
|
|
|
|
|
74
|
croak $error; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
7
|
$url = $self->base_url . "/$url"; |
32
|
|
|
|
|
|
|
|
33
|
1
|
|
|
|
|
25
|
my $result = $self->ua->get($url); |
34
|
|
|
|
|
|
|
$result->{'success'} |
35
|
1
|
50
|
|
|
|
971214
|
or croak "Failed to fetch '$url': " . $result->{'reason'}; |
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
|
|
67
|
return $result->{'content'}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
__END__ |