line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
15
|
|
|
15
|
|
6522
|
use strict; |
|
15
|
|
|
|
|
30
|
|
|
15
|
|
|
|
|
357
|
|
2
|
15
|
|
|
15
|
|
66
|
use warnings; |
|
15
|
|
|
|
|
28
|
|
|
15
|
|
|
|
|
567
|
|
3
|
|
|
|
|
|
|
package MetaCPAN::API::POD; |
4
|
|
|
|
|
|
|
# ABSTRACT: POD information for MetaCPAN::API |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.51'; |
7
|
|
|
|
|
|
|
|
8
|
15
|
|
|
15
|
|
71
|
use Carp; |
|
15
|
|
|
|
|
24
|
|
|
15
|
|
|
|
|
590
|
|
9
|
15
|
|
|
15
|
|
65
|
use Moo::Role; |
|
15
|
|
|
|
|
29
|
|
|
15
|
|
|
|
|
72
|
|
10
|
15
|
|
|
15
|
|
4274
|
use namespace::autoclean; |
|
15
|
|
|
|
|
29
|
|
|
15
|
|
|
|
|
77
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# /pod/{module} |
13
|
|
|
|
|
|
|
# /pod/{author}/{release}/{path} |
14
|
|
|
|
|
|
|
sub pod { |
15
|
9
|
|
|
9
|
1
|
7863
|
my $self = shift; |
16
|
9
|
100
|
|
|
|
53
|
my %opts = @_ ? @_ : (); |
17
|
9
|
|
|
|
|
22
|
my $url = ''; |
18
|
9
|
|
|
|
|
16
|
my $error = "Either provide 'module' or 'author and 'release' and 'path'"; |
19
|
|
|
|
|
|
|
|
20
|
9
|
100
|
|
|
|
158
|
%opts or croak $error; |
21
|
|
|
|
|
|
|
|
22
|
8
|
100
|
66
|
|
|
45
|
if ( defined ( my $module = $opts{'module'} ) ) { |
|
|
100
|
66
|
|
|
|
|
23
|
6
|
|
|
|
|
17
|
$url = "pod/$module"; |
24
|
|
|
|
|
|
|
} elsif ( |
25
|
|
|
|
|
|
|
defined ( my $author = $opts{'author'} ) && |
26
|
|
|
|
|
|
|
defined ( my $release = $opts{'release'} ) && |
27
|
|
|
|
|
|
|
defined ( my $path = $opts{'path'} ) |
28
|
|
|
|
|
|
|
) { |
29
|
1
|
|
|
|
|
6
|
$url = "pod/$author/$release/$path"; |
30
|
|
|
|
|
|
|
} else { |
31
|
1
|
|
|
|
|
61
|
croak $error; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# check content-type |
35
|
7
|
|
|
|
|
18
|
my %extra = (); |
36
|
7
|
100
|
|
|
|
29
|
if ( defined ( my $type = $opts{'content-type'} ) ) { |
37
|
5
|
100
|
|
|
|
162
|
$type =~ m{^ text/ (?: html|plain|x-pod|x-markdown ) $}x |
38
|
|
|
|
|
|
|
or croak 'Incorrect content-type provided'; |
39
|
|
|
|
|
|
|
|
40
|
4
|
|
|
|
|
16
|
$extra{headers}{'content-type'} = $type; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
6
|
|
|
|
|
38
|
$url = $self->base_url . "/$url"; |
44
|
|
|
|
|
|
|
|
45
|
6
|
|
|
|
|
209
|
my $result = $self->ua->get( $url, \%extra ); |
46
|
|
|
|
|
|
|
$result->{'success'} |
47
|
6
|
50
|
|
|
|
3078534
|
or croak "Failed to fetch '$url': " . $result->{'reason'}; |
48
|
|
|
|
|
|
|
|
49
|
6
|
|
|
|
|
88
|
return $result->{'content'}; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__END__ |