API/File.pm

filter: Statementstmt 100% 30 / 30 Branchbran 100% 8 / 8 Conditioncond 80.0% 4 / 5 MC/DCmcdc 66.6% 2 / 3 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 96.2% 51 / 53 CC 7 SCAR 15.0
CC
7
Cov
98%
file
7.0
BEGIN
1.0
BEGIN
1.0
CRAP 4.5
« API/Distribution.pm ↑ Summary API.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::File;
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 # /module/{module}
12 # /file/{author}/{release}/{path}
13 # /file/{author}/{release}
14 # /file/{id}
15 6 ▶sub file {
Subroutine file: called CC=7 SCAR=19.5
Pod documented
16 6 my $self = shift;
17 6 my $url = '';
18 6 my $error = "Either provide a module name, 'id', or 'author and 'release' and an optional 'path'";
19  
20 6 ▶ if ( @_ == 1 ) {
Branch: 2 branches
BranchTrueFalseTotal
if (@_ == 1) { } 1 5 6
elsif (@_) { } 4 1 5
21 1 $url = 'module/' . shift;
22 } elsif ( @_ ) {
23 4 my %opts = @_;
24  
25 4 ▶ if ( defined ( my $id = $opts{'id'} ) ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined(my $id = $opts{'id'})) { } 1 3 4
elsif (defined(my $author = $opts{'author'}) and defined(my $release = $opts{'release'})) { } 2 1 3
26 1 $url = "file/$id";
27 ▶ } elsif (
Condition66%2/3
defined(my $author = $opts{"author"}) and defined(my $release = $opts{"release"})
!ll&&!rl&&r
102
MC/DC50%1/2
defined(my $author = $opts{"author"}) and defined(my $release = $opts{"release"})
defined(my $author = $opts{"author"}) defined(my $release = $opts{"release"})
Truth table66%2/3
A and B
A= defined(my $author = $opts{"author"})B= defined(my $release = $opts{"release"})
ABresult
0X0
100
111
28 defined ( my $author = $opts{'author'} ) &&
29 defined ( my $release = $opts{'release'} )
30 ) {
31 2 ▶ my $path = $opts{'path'} || '';
Condition100%2/2
$opts{'path'} || ''
l!l
11
MC/DC100%1/1
$opts{'path'} || ''
$opts{'path'}
Truth table100%2/2
A
A= $opts{'path'}
Aresult
11
00
32 2 $url = "file/$author/$release/$path";
33 } else {
34 1 croak $error;
35 }
36 } else {
37 1 croak $error;
38 }
39  
40  
41 4 return $self->fetch( $url );
42 }
43  
44 17 1;
45  
46 __END__
« API/Distribution.pm ↑ Summary API.pm »