line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
15
|
|
|
15
|
|
7406
|
use strict; |
|
15
|
|
|
|
|
30
|
|
|
15
|
|
|
|
|
534
|
|
2
|
15
|
|
|
15
|
|
73
|
use warnings; |
|
15
|
|
|
|
|
21
|
|
|
15
|
|
|
|
|
682
|
|
3
|
|
|
|
|
|
|
package MetaCPAN::API::Source; |
4
|
|
|
|
|
|
|
# ABSTRACT: Source information for MetaCPAN::API |
5
|
|
|
|
|
|
|
$MetaCPAN::API::Source::VERSION = '0.50'; |
6
|
15
|
|
|
15
|
|
73
|
use Carp; |
|
15
|
|
|
|
|
24
|
|
|
15
|
|
|
|
|
832
|
|
7
|
15
|
|
|
15
|
|
76
|
use Moo::Role; |
|
15
|
|
|
|
|
21
|
|
|
15
|
|
|
|
|
91
|
|
8
|
15
|
|
|
15
|
|
4612
|
use namespace::autoclean; |
|
15
|
|
|
|
|
26
|
|
|
15
|
|
|
|
|
100
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# /source/{author}/{release}/{path} |
11
|
|
|
|
|
|
|
sub source { |
12
|
3
|
|
|
3
|
1
|
1809
|
my $self = shift; |
13
|
3
|
100
|
|
|
|
15
|
my %opts = @_ ? @_ : (); |
14
|
3
|
|
|
|
|
4
|
my $url = ''; |
15
|
3
|
|
|
|
|
3
|
my $error = "Provide 'author' and 'release' and 'path'"; |
16
|
|
|
|
|
|
|
|
17
|
3
|
100
|
|
|
|
152
|
%opts or croak $error; |
18
|
|
|
|
|
|
|
|
19
|
2
|
100
|
66
|
|
|
18
|
if ( |
|
|
|
66
|
|
|
|
|
20
|
|
|
|
|
|
|
defined ( my $author = $opts{'author'} ) && |
21
|
|
|
|
|
|
|
defined ( my $release = $opts{'release'} ) && |
22
|
|
|
|
|
|
|
defined ( my $path = $opts{'path'} ) |
23
|
|
|
|
|
|
|
) { |
24
|
1
|
|
|
|
|
5
|
$url = "source/$author/$release/$path"; |
25
|
|
|
|
|
|
|
} else { |
26
|
1
|
|
|
|
|
104
|
croak $error; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
5
|
$url = $self->base_url . "/$url"; |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
6
|
my $result = $self->ua->get($url); |
32
|
1
|
50
|
|
|
|
23396
|
$result->{'success'} |
33
|
|
|
|
|
|
|
or croak "Failed to fetch '$url': " . $result->{'reason'}; |
34
|
|
|
|
|
|
|
|
35
|
1
|
|
|
|
|
32
|
return $result->{'content'}; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
__END__ |