VastAI/LWPIO.pm

filter: Statementstmt 92.3% 24 / 26 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 71.4% 5 / 7 Podpod 100% 1 / 1 totaltotal 86.1% 31 / 36 CC 3 SCAR 6.4
CC
3
Cov
89%
call
3.0
__ANON__
2.0
_build_user_agent
2.0
CRAP 1.9
« VastAI/Instance.pm ↑ Summary VastAI/SSHKey.pm »
1 package WWW::VastAI::LWPIO;
2 11 our $VERSION = '0.001';
3 # ABSTRACT: Default LWP::UserAgent-backed IO backend for WWW::VastAI
4  
5 11 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 11 ▶use HTTP::Request;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 11 ▶use LWP::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 11 ▶use WWW::VastAI::HTTPResponse;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 11 with 'WWW::VastAI::Role::IO';
11  
12 has user_agent => (
13 is => 'lazy',
14 0 ▶ builder => sub {
Subroutine _build_user_agent: not called CC=1 SCAR=6.9
Subroutine __ANON__: not called CC=1 SCAR=6.9
15 0 LWP::UserAgent->new(
16 agent => 'WWW-VastAI',
17 timeout => 30,
18 );
19 },
20 11 );
21  
22 1 ▶sub call {
Subroutine call: called CC=3 SCAR=11.0
Pod documented
23 1 my ($self, $req) = @_;
24  
25 1 my $http = HTTP::Request->new($req->method => $req->url);
26 1 for my $name (keys %{ $req->headers }) {
27 2 $http->header($name => $req->headers->{$name});
28 }
29 1 ▶ $http->content($req->content) if $req->has_content;
Branch: 1 branch
BranchTrueFalseTotal
if $req->has_content 1 0 1
30  
31 1 my $response = $self->user_agent->request($http);
32  
33 1 return WWW::VastAI::HTTPResponse->new(
34 status => $response->code,
35 content => $response->decoded_content,
36 );
37 }
38  
39 11 1;
40  
41 __END__
« VastAI/Instance.pm ↑ Summary VastAI/SSHKey.pm »