API/POD.pm

filter: Statementstmt 100% 34 / 34 Branchbran 92.8% 13 / 14 Conditioncond 66.6% 4 / 6 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 92.1% 59 / 64 CC 10 SCAR 19.5
CC
10
Cov
94%
pod
10.1
BEGIN
1.0
BEGIN
1.0
CRAP 7.0
« API/Release.pm ↑ Summary API/Autocomplete.pm »
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
BranchTrueFalseTotal
@_ ? : 8 1 9
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
BranchTrueFalseTotal
%opts or croak($error) 8 1 9
20  
21 8 ▶ if ( defined ( my $module = $opts{'module'} ) ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined(my $module = $opts{'module'})) { } 6 2 8
elsif (defined(my $author = $opts{'author'}) and defined(my $release = $opts{'release'}) and defined(my $path = $opts{'path'})) { } 1 1 2
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"})
!ll&&!rl&&r
101
defined(my $author = $opts{"author"}) and defined(my $release = $opts{"release"})
!ll&&!rl&&r
101
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"})
ABCresult
0XX0
10X0
1100
1111
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
BranchTrueFalseTotal
if (defined(my $type = $opts{"content-type"})) 5 2 7
36 5 ▶ $type =~ m{^ text/ (?: html|plain|x-pod|x-markdown ) $}x
Branch: 1 branch
BranchTrueFalseTotal
$type =~ m[^ text/ (?: html|plain|x-pod|x-markdown ) $]x or croak("Incorrect content-type provided") 4 1 5
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
BranchTrueFalseTotal
$result->{"success"} or croak(qq[Failed to fetch '${url}': $result->{"reason"} - $result->{"content"}]) 6 0 6
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__
« API/Release.pm ↑ Summary API/Autocomplete.pm »