| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
17
|
|
|
17
|
|
248804
|
use strict; |
|
|
17
|
|
|
|
|
38
|
|
|
|
17
|
|
|
|
|
669
|
|
|
2
|
17
|
|
|
17
|
|
89
|
use warnings; |
|
|
17
|
|
|
|
|
41
|
|
|
|
17
|
|
|
|
|
1423
|
|
|
3
|
|
|
|
|
|
|
package MetaCPAN::API::POD; |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.52'; |
|
6
|
|
|
|
|
|
|
|
|
7
|
17
|
|
|
17
|
|
105
|
use Carp; |
|
|
17
|
|
|
|
|
31
|
|
|
|
17
|
|
|
|
|
1142
|
|
|
8
|
17
|
|
|
17
|
|
640
|
use Moo::Role; |
|
|
17
|
|
|
|
|
20126
|
|
|
|
17
|
|
|
|
|
112
|
|
|
9
|
17
|
|
|
17
|
|
9853
|
use namespace::autoclean; |
|
|
17
|
|
|
|
|
23638
|
|
|
|
17
|
|
|
|
|
204
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# /pod/{module} |
|
12
|
|
|
|
|
|
|
# /pod/{author}/{release}/{path} |
|
13
|
|
|
|
|
|
|
sub pod { |
|
14
|
9
|
|
|
9
|
1
|
9507
|
my $self = shift; |
|
15
|
9
|
100
|
|
|
|
55
|
my %opts = @_ ? @_ : (); |
|
16
|
9
|
|
|
|
|
15
|
my $url = ''; |
|
17
|
9
|
|
|
|
|
16
|
my $error = "Either provide 'module' or 'author and 'release' and 'path'"; |
|
18
|
|
|
|
|
|
|
|
|
19
|
9
|
100
|
|
|
|
210
|
%opts or croak $error; |
|
20
|
|
|
|
|
|
|
|
|
21
|
8
|
100
|
66
|
|
|
40
|
if ( defined ( my $module = $opts{'module'} ) ) { |
|
|
|
100
|
66
|
|
|
|
|
|
22
|
6
|
|
|
|
|
16
|
$url = "pod/$module"; |
|
23
|
|
|
|
|
|
|
} elsif ( |
|
24
|
|
|
|
|
|
|
defined ( my $author = $opts{'author'} ) && |
|
25
|
|
|
|
|
|
|
defined ( my $release = $opts{'release'} ) && |
|
26
|
|
|
|
|
|
|
defined ( my $path = $opts{'path'} ) |
|
27
|
|
|
|
|
|
|
) { |
|
28
|
1
|
|
|
|
|
3
|
$url = "pod/$author/$release/$path"; |
|
29
|
|
|
|
|
|
|
} else { |
|
30
|
1
|
|
|
|
|
100
|
croak $error; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# check content-type |
|
34
|
7
|
|
|
|
|
17
|
my %extra = (); |
|
35
|
7
|
100
|
|
|
|
31
|
if ( defined ( my $type = $opts{'content-type'} ) ) { |
|
36
|
5
|
100
|
|
|
|
214
|
$type =~ m{^ text/ (?: html|plain|x-pod|x-markdown ) $}x |
|
37
|
|
|
|
|
|
|
or croak 'Incorrect content-type provided'; |
|
38
|
|
|
|
|
|
|
|
|
39
|
4
|
|
|
|
|
31
|
$extra{headers}{'content-type'} = $type; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
6
|
|
|
|
|
45
|
$url = $self->base_url . "/$url"; |
|
43
|
|
|
|
|
|
|
|
|
44
|
6
|
|
|
|
|
322
|
my $result = $self->ua->get( $url, \%extra ); |
|
45
|
6
|
50
|
|
|
|
389988
|
$result->{'success'} |
|
46
|
|
|
|
|
|
|
or croak "Failed to fetch '$url': $result->{'reason'} - $result->{'content'}"; |
|
47
|
|
|
|
|
|
|
|
|
48
|
6
|
|
|
|
|
163
|
return $result->{'content'}; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |