| 1 | 17 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 2 | 17 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 3 | package MetaCPAN::API::POD; | ||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||
| 5 | 17 | our $VERSION = '0.52'; | |||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||
| 7 | 17 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 8 | 17 | ▶ | use Moo::Role; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 9 | 17 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||
| 11 | # /pod/{module} | ||||||||||||||||||||||||||||||||||
| 12 | # /pod/{author}/{release}/{path} | ||||||||||||||||||||||||||||||||||
| 13 | 9 | ▶ | sub pod { | ||||||||||||||||||||||||||||||||
|
Subroutine
pod: called CC=10 SCAR=23.1
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 14 | 9 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 15 | 9 | ▶ | my %opts = @_ ? @_ : (); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 16 | 9 | my $url = ''; | |||||||||||||||||||||||||||||||||
| 17 | 9 | my $error = "Either provide 'module' or 'author and 'release' and 'path'"; | |||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||
| 19 | 9 | ▶ | %opts or croak $error; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||
| 21 | 8 | ▶ | if ( defined ( my $module = $opts{'module'} ) ) { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 22 | 6 | $url = "pod/$module"; | |||||||||||||||||||||||||||||||||
| 23 | ▶ | } elsif ( | |||||||||||||||||||||||||||||||||
|
Condition66%4/6
defined(my $author = $opts{"author"}) and defined(my $release = $opts{"release"}) and defined(my $path = $opts{"path"})
defined(my $author = $opts{"author"}) and defined(my $release = $opts{"release"})
MC/DC33%1/3
defined(my $author = $opts{"author"}) and defined(my $release = $opts{"release"}) and defined(my $path = $opts{"path"})
defined(my $author = $opts{"author"})
defined(my $release = $opts{"release"})
defined(my $path = $opts{"path"})
Truth table50%2/4
A and B and C
A= defined(my $author = $opts{"author"})B= defined(my $release = $opts{"release"})C= defined(my $path = $opts{"path"})
| |||||||||||||||||||||||||||||||||||
| 24 | defined ( my $author = $opts{'author'} ) && | ||||||||||||||||||||||||||||||||||
| 25 | defined ( my $release = $opts{'release'} ) && | ||||||||||||||||||||||||||||||||||
| 26 | defined ( my $path = $opts{'path'} ) | ||||||||||||||||||||||||||||||||||
| 27 | ) { | ||||||||||||||||||||||||||||||||||
| 28 | 1 | $url = "pod/$author/$release/$path"; | |||||||||||||||||||||||||||||||||
| 29 | } else { | ||||||||||||||||||||||||||||||||||
| 30 | 1 | croak $error; | |||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||
| 33 | # check content-type | ||||||||||||||||||||||||||||||||||
| 34 | 7 | my %extra = (); | |||||||||||||||||||||||||||||||||
| 35 | 7 | ▶ | if ( defined ( my $type = $opts{'content-type'} ) ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 36 | 5 | ▶ | $type =~ m{^ text/ (?: html|plain|x-pod|x-markdown ) $}x | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 37 | or croak 'Incorrect content-type provided'; | ||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||
| 39 | 4 | $extra{headers}{'content-type'} = $type; | |||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||
| 42 | 6 | $url = $self->base_url . "/$url"; | |||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||
| 44 | 6 | my $result = $self->ua->get( $url, \%extra ); | |||||||||||||||||||||||||||||||||
| 45 | 6 | ▶ | $result->{'success'} | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 46 | or croak "Failed to fetch '$url': $result->{'reason'} - $result->{'content'}"; | ||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||
| 48 | 6 | return $result->{'content'}; | |||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||
| 51 | 17 | 1; | |||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||
| 53 | __END__ | ||||||||||||||||||||||||||||||||||