SimpleDB/Response.pm

filter: Statementstmt 28.5% 14 / 49 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 30.7% 4 / 13 Podpod 100% 9 / 9 totaltotal 29.0% 27 / 93 CC 10 SCAR 39.3
CC
10
Cov
21%
new
110.0
type
2.0
http_response
2.0
CRAP 50.9
↑ Summary SimpleDB/Item.pm »
1 package Amazon::SimpleDB::Response;
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 3 ▶use XML::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 our %SPECIALS = (
9 'ErrorResponse' => 1,
10 'ListDomainsResponse' => 1,
11 'GetAttributesResponse' => 1,
12 'QueryResponse' => 1,
13 );
14  
15 0 ▶sub new {
Subroutine new: not called CC=10 SCAR=47.0
Pod documented
16 0 my $class = shift;
17 0 ▶ my $args = shift || {};
Condition0%0/2
shift() || {}
l!l
00
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
18 0 ▶ croak "No account" unless $args->{account};
Branch: 1 branch
BranchTrueFalseTotal
unless $args->{"account"} 0 0 0
19 0 my $r = $args->{http_response};
20 0 ▶ croak 'No HTTP::Response object in http_response'
Branch: 1 branch
BranchTrueFalseTotal
unless ref $r and $r->isa("HTTP::Response") 0 0 0
Condition0%0/3
ref $r and $r->isa("HTTP::Response")
!ll&&!rl&&r
000
MC/DC0%0/2
ref $r and $r->isa("HTTP::Response")
ref $r $r->isa("HTTP::Response")
Truth table0%0/3
A and B
A= ref $rB= $r->isa("HTTP::Response")
ABresult
0X0
100
111
21 unless ref $r && $r->isa('HTTP::Response');
22 0 my $tree;
23 0 eval {
24 0 my $content = $r->content;
25 0 $tree =
26 XMLin(
27 $content,
28 'ForceArray' => ['Attribute', 'DomainName', 'ItemName'],
29 'KeepRoot' => 1
30 );
31 };
32 0 ▶ croak $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
33 0 my ($type) = keys %$tree;
34 0 ▶ if ($r->is_error) {
Branch: 2 branches
BranchTrueFalseTotal
if ($r->is_error) { } 0 0 0
elsif ($Amazon::SimpleDB::Response::SPECIALS{$type}) { } 0 0 0
35 0 require Amazon::SimpleDB::ErrorResponse;
36 0 $class = 'Amazon::SimpleDB::ErrorResponse';
37 } elsif ($SPECIALS{$type}) {
38 0 $class = "Amazon::SimpleDB::${type}";
39 0 eval "use $class";
40 0 ▶ croak $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
41 }
42 0 my $self = bless {}, $class;
43 0 $self->{'account'} = $args->{account};
44 0 $self->{'http_response'} = $r;
45 0 $self->{'http_status'} = $r->code;
46 0 $self->{'content'} = $tree;
47 0 $self->{'response_type'} = $type;
48 0 ▶ if ($r->is_success) { # errors are stored differently
Branch: 1 branch
BranchTrueFalseTotal
if ($r->is_success) 0 0 0
49 0 $self->{'request_id'} = $tree->{$type}{ResponseMetadata}{RequestId};
50 0 $self->{'box_usage'} = $tree->{$type}{ResponseMetadata}{BoxUsage};
51 }
52 0 return $self;
53 }
54  
55 0 ▶sub type { return $_[0]->{'response_type'} }
Subroutine type: not called CC=1 SCAR=6.9
Pod documented
56 0 ▶sub http_response { return $_[0]->{'http_response'} }
Subroutine http_response: not called CC=1 SCAR=6.9
Pod documented
57 0 ▶sub http_status { return $_[0]->{'http_status'} }
Subroutine http_status: not called CC=1 SCAR=6.9
Pod documented
58 0 ▶sub content { return $_[0]->{'content'} }
Subroutine content: not called CC=1 SCAR=6.9
Pod documented
59 0 ▶sub request_id { return $_[0]->{'request_id'} }
Subroutine request_id: not called CC=1 SCAR=6.9
Pod documented
60 0 ▶sub box_usage { return $_[0]->{'box_usage'} }
Subroutine box_usage: not called CC=1 SCAR=6.9
Pod documented
61 0 ▶sub is_success { return $_[0]->{'http_response'}->is_success }
Subroutine is_success: not called CC=1 SCAR=6.9
Pod documented
62 0 ▶sub is_error { return $_[0]->{'http_response'}->is_error }
Subroutine is_error: not called CC=1 SCAR=6.9
Pod documented
63  
64 3 1;
65  
66 __END__
↑ Summary SimpleDB/Item.pm »