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