| 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::Source; | ||||||||||||||||||||||||||||||||||||||||||
| 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 | # /source/{author}/{release}/{path} | ||||||||||||||||||||||||||||||||||||||||||
| 12 | 3 | ▶ | sub source { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
source: called CC=7 SCAR=19.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 14 | 3 | ▶ | my %opts = @_ ? @_ : (); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 3 | my $url = ''; | |||||||||||||||||||||||||||||||||||||||||
| 16 | 3 | my $error = "Provide 'author' and 'release' and 'path'"; | |||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 3 | ▶ | %opts or croak $error; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
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"})
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | defined ( my $author = $opts{'author'} ) && | ||||||||||||||||||||||||||||||||||||||||||
| 22 | defined ( my $release = $opts{'release'} ) && | ||||||||||||||||||||||||||||||||||||||||||
| 23 | defined ( my $path = $opts{'path'} ) | ||||||||||||||||||||||||||||||||||||||||||
| 24 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | $url = "source/$author/$release/$path"; | |||||||||||||||||||||||||||||||||||||||||
| 26 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | croak $error; | |||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | $url = $self->base_url . "/$url"; | |||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | my $result = $self->ua->get($url); | |||||||||||||||||||||||||||||||||||||||||
| 33 | 1 | ▶ | $result->{'success'} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | or croak "Failed to fetch '$url': $result->{'reason'} - $result->{'content'}"; | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 1 | return $result->{'content'}; | |||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 17 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | __END__ | ||||||||||||||||||||||||||||||||||||||||||