| 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
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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)
$response->{"success"} or defined $response->{"status"} and $response->{"status"} >= 200 and $response->{"status"} < 300
defined $response->{"status"} and $response->{"status"} >= 200 and $response->{"status"} < 300
defined $response->{"status"} and $response->{"status"} >= 200
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 52 | ▶ | return 1 if $ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 5 | ▶ | my $status = $response && defined $response->{status} ? $response->{status} : q{Unknown}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$response and defined $response->{"status"}
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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 5 | die "$message. HTTP status: $status\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||