examples/HTTP/API/Core/Example/TransportAdapters.pm

filter: Statementstmt 48.0% 24 / 50 Branchbran 25.0% 4 / 16 Conditioncond 17.3% 4 / 23 MC/DCmcdc 0.0% 0 / 13 Subroutinesub 60.0% 6 / 10 Podpod 100% 4 / 4 totaltotal 36.2% 42 / 116 CC 22 SCAR 25.4
CC
22
Cov
36%
__ANON__
30.0
mojo_user_agent
20.0
__ANON__
20.0
CRAP 12.7
« blib/lib/HTTP/API/Core/Response.pm ↑ Summary examples/HTTP/API/Core/Example/Jira.pm »
1 package HTTP::API::Core::Example::TransportAdapters;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶sub http_tiny {
Subroutine http_tiny: called CC=3 SCAR=12.3
Pod documented
7 1 my ($http) = @_;
8 1 ▶ die "HTTP::Tiny-compatible object is required\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $http and $http->can("request") 0 1 1
Condition33%1/3
$http and $http->can("request")
!ll&&!rl&&r
001
MC/DC0%0/2
$http and $http->can("request")
$http $http->can("request")
Truth table33%1/3
A and B
A= $httpB= $http->can("request")
ABresult
0X0
100
111
9 if !$http || !$http->can('request');
10  
11 1 ▶ return sub {
Subroutine __ANON__: called CC=3 SCAR=12.0
12 1 my ($method, $url, $opts) = @_;
13 return $http->request($method, $url, {
14 headers => $opts->{headers} || {},
15 1 ▶ (exists($opts->{content}) ? (content => $opts->{content}) : ()),
Branch: 1 branch
BranchTrueFalseTotal
exists $opts->{'content'} ? : 1 0 1
Condition50%1/2
$opts->{'headers'} || {}
l!l
10
MC/DC0%0/1
$opts->{'headers'} || {}
$opts->{'headers'}
Truth table50%1/2
A
A= $opts->{'headers'}
Aresult
11
00
16 });
17 1 };
18 }
19  
20 1 ▶sub lwp_user_agent {
Subroutine lwp_user_agent: called CC=3 SCAR=11.4
Pod documented
21 1 my ($ua) = @_;
22 1 ▶ die "LWP::UserAgent-compatible object is required\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $ua and $ua->can("request") 0 1 1
Condition33%1/3
$ua and $ua->can("request")
!ll&&!rl&&r
001
MC/DC0%0/2
$ua and $ua->can("request")
$ua $ua->can("request")
Truth table33%1/3
A and B
A= $uaB= $ua->can("request")
ABresult
0X0
100
111
23 if !$ua || !$ua->can('request');
24  
25 1 ▶ return sub {
Subroutine __ANON__: called CC=4 SCAR=14.0
26 1 my ($method, $url, $opts) = @_;
27  
28 1 require HTTP::Request;
29 1 my $request = HTTP::Request->new($method => $url);
30 1 ▶ my $headers = $opts->{headers} || {};
Condition50%1/2
$opts->{'headers'} || {}
l!l
10
MC/DC0%0/1
$opts->{'headers'} || {}
$opts->{'headers'}
Truth table50%1/2
A
A= $opts->{'headers'}
Aresult
11
00
31 1 $request->header($_ => $headers->{$_}) for keys %$headers;
32 1 ▶ $request->content($opts->{content}) if exists $opts->{content};
Branch: 1 branch
BranchTrueFalseTotal
if exists $opts->{"content"} 1 0 1
33  
34 1 my $response = $ua->request($request);
35 1 my %headers = $response->headers->flatten;
36  
37 return {
38 1 status => $response->code,
39 reason => $response->message,
40 headers => \%headers,
41 content => $response->content,
42 };
43 1 };
44 }
45  
46 0 ▶sub mojo_user_agent {
Subroutine mojo_user_agent: not called CC=4 SCAR=30.0
Pod documented
47 0 my ($ua) = @_;
48 0 ▶ die "Mojo::UserAgent-compatible object is required\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $ua and $ua->can("build_tx") and $ua->can("start") 0 0 0
Condition0%0/6
$ua and $ua->can("build_tx") and $ua->can("start")
!ll&&!rl&&r
000
$ua and $ua->can("build_tx")
!ll&&!rl&&r
000
MC/DC0%0/3
$ua and $ua->can("build_tx") and $ua->can("start")
$ua $ua->can("build_tx") $ua->can("start")
Truth table0%0/4
A and B and C
A= $uaB= $ua->can("build_tx")C= $ua->can("start")
ABCresult
0XX0
10X0
1100
1111
49 if !$ua || !$ua->can('build_tx') || !$ua->can('start');
50  
51 0 ▶ return sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
52 0 my ($method, $url, $opts) = @_;
53 0 ▶ my $headers = $opts->{headers} || {};
Condition0%0/2
$opts->{'headers'} || {}
l!l
00
MC/DC0%0/1
$opts->{'headers'} || {}
$opts->{'headers'}
Truth table0%0/2
A
A= $opts->{'headers'}
Aresult
11
00
54  
55 0 my $tx = $ua->build_tx($method => $url => $headers);
56 0 ▶ $tx->req->body($opts->{content}) if exists $opts->{content};
Branch: 1 branch
BranchTrueFalseTotal
if exists $opts->{"content"} 0 0 0
57 0 my $result = $ua->start($tx)->result;
58  
59 0 my %response_headers;
60 0 for my $name (@{ $result->headers->names }) {
61 0 $response_headers{$name} = $result->headers->header($name);
62 }
63  
64 return {
65 0 status => $result->code,
66 reason => $result->message,
67 headers => \%response_headers,
68 content => $result->body,
69 };
70 0 };
71 }
72  
73 0 ▶sub furl {
Subroutine furl: not called CC=3 SCAR=24.8
Pod documented
74 0 my ($furl) = @_;
75 0 ▶ die "Furl-compatible object is required\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $furl and $furl->can("request") 0 0 0
Condition0%0/3
$furl and $furl->can("request")
!ll&&!rl&&r
000
MC/DC0%0/2
$furl and $furl->can("request")
$furl $furl->can("request")
Truth table0%0/3
A and B
A= $furlB= $furl->can("request")
ABresult
0X0
100
111
76 if !$furl || !$furl->can('request');
77  
78 0 ▶ return sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
79 0 my ($method, $url, $opts) = @_;
80 0 ▶ my $headers = $opts->{headers} || {};
Condition0%0/2
$opts->{'headers'} || {}
l!l
00
MC/DC0%0/1
$opts->{'headers'} || {}
$opts->{'headers'}
Truth table0%0/2
A
A= $opts->{'headers'}
Aresult
11
00
81 0 my @headers;
82 0 push @headers, $_ => $headers->{$_} for keys %$headers;
83  
84 my $response = $furl->request(
85 method => $method,
86 url => $url,
87 headers => \@headers,
88 0 ▶ (exists($opts->{content}) ? (content => $opts->{content}) : ()),
Branch: 1 branch
BranchTrueFalseTotal
exists $opts->{'content'} ? : 0 0 0
89 );
90  
91 0 my %response_headers;
92 0 my $response_header = $response->headers;
93 0 for my $name ($response_header->header_field_names) {
94 0 $response_headers{$name} = $response_header->header($name);
95 }
96  
97 return {
98 0 status => $response->code,
99 reason => $response->message,
100 headers => \%response_headers,
101 content => $response->content,
102 };
103 0 };
104 }
105  
106 1 1;
107  
108 __END__
« blib/lib/HTTP/API/Core/Response.pm ↑ Summary examples/HTTP/API/Core/Example/Jira.pm »