TropicalCyclone/HTTP.pm

filter: Statementstmt 100% 27 / 27 Branchbran 100% 4 / 4 Conditioncond 72.2% 13 / 18 MC/DCmcdc 44.4% 4 / 9 Subroutinesub 100% 8 / 8 Podpod 75.0% 3 / 4 totaltotal 84.2% 59 / 70 CC 9 SCAR 15.6
CC
9
Cov
90%
_assert_success
8.3
new
2.0
BEGIN
1.0
CRAP 4.8
« TropicalCyclone/Validation.pm ↑ Summary TropicalCyclone/Storm.pm »
1 package Weather::NHC::TropicalCyclone::HTTP;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use HTTP::Tiny ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 7 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
Pod documented
8 7 my ( $class, %args ) = @_;
9 7 ▶ my $client = $args{client} || HTTP::Tiny->new;
Condition66%2/3
$args{'client'} || 'HTTP::Tiny'->new
l!l&&r!l&&!r
610
MC/DC0%0/2
$args{'client'} || 'HTTP::Tiny'->new
$args{'client'} 'HTTP::Tiny'->new
Truth table66%2/3
A || B
A= $args{'client'}B= 'HTTP::Tiny'->new
ABresult
1X1
011
000
10 7 return bless { client => $client }, $class;
11 }
12  
13 55 ▶sub client { return $_[0]->{client} }
Subroutine client: called CC=1 SCAR=0.0
Pod undocumented
14  
15 28 ▶sub get {
Subroutine get: called CC=1 SCAR=0.0
Pod documented
16 28 my ( $self, $url ) = @_;
17 28 my $response = $self->client->get($url);
18 27 _assert_success( $response, "Fetching of $url failed" );
19 23 return $response;
20 }
21  
22 25 ▶sub mirror {
Subroutine mirror: called CC=1 SCAR=0.0
Pod documented
23 25 my ( $self, $url, $file ) = @_;
24 25 my $response = $self->client->mirror( $url, $file );
25 25 _assert_success( $response, "Download of $url failed" );
26 24 return $response;
27 }
28  
29 52 ▶sub _assert_success {
Subroutine _assert_success: called CC=8 SCAR=21.2
30 52 my ( $response, $message ) = @_;
31 52 ▶ my $ok = $response && ( $response->{success} || ( defined $response->{status} && $response->{status} >= 200 && $response->{status} < 300 ) );
Condition75%9/12
$response && ($response->{'success'} || defined $response->{'status'} && $response->{'status'} >= 200 && $response->{'status'} < 300)
!ll&&!rl&&r
1447
$response->{"success"} or defined $response->{"status"} and $response->{"status"} >= 200 and $response->{"status"} < 300
l!l&&r!l&&!r
4614
defined $response->{"status"} and $response->{"status"} >= 200 and $response->{"status"} < 300
!ll&&!rl&&r
041
defined $response->{"status"} and $response->{"status"} >= 200
!ll&&!rl&&r
005
MC/DC60%3/5
$response && ($response->{'success'} || defined $response->{'status'} && $response->{'status'} >= 200 && $response->{'status'} < 300)
$response $response->{"success"} defined $response->{"status"} $response->{"status"} >= 200 $response->{"status"} < 300
Truth table66%4/6
A && B or C and D and E
A= $responseB= $response->{"success"}C= defined $response->{"status"}D= $response->{"status"} >= 200E= $response->{"status"} < 300
ABCDEresult
0XXXX0
100XX0
1010X0
101100
11XXX1
101111
32 52 ▶ return 1 if $ok;
Branch: 1 branch
BranchTrueFalseTotal
if $ok 47 5 52
33 5 ▶ my $status = $response && defined $response->{status} ? $response->{status} : q{Unknown};
Branch: 1 branch
BranchTrueFalseTotal
$response && defined $response->{'status'} ? : 4 1 5
Condition66%2/3
$response and defined $response->{"status"}
!ll&&!rl&&r
104
MC/DC50%1/2
$response and defined $response->{"status"}
$response defined $response->{"status"}
Truth table66%2/3
A and B
A= $responseB= defined $response->{"status"}
ABresult
0X0
100
111
34 5 die "$message. HTTP status: $status\n";
35 }
36  
37 4 1;
38  
39 __END__
« TropicalCyclone/Validation.pm ↑ Summary TropicalCyclone/Storm.pm »