Tumblr/Result.pm

filter: Statementstmt 47.2% 17 / 36 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 40.0% 4 / 10 Podpod 0.0% 0 / 1 totaltotal 41.1% 21 / 51 CC 3 SCAR 11.0
CC
3
Cov
42%
content
6.0
__ANON__
6.0
_error
2.0
CRAP 3.0
« Tumblr.pm ↑ Summary Tumblr/Dispatch.pm »
1 package WebService::Tumblr::Result;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use Any::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 3 has dispatch => qw/ is ro required 1 isa WebService::Tumblr::Dispatch /, handles => [qw/ tumblr /];
10 3 has request => qw/ is ro required 1 isa HTTP::Request /;
11 3 has response => qw/ is ro required 1 isa HTTP::Response /, handles => [qw/ is_success /];
12  
13 0 ▶sub _error {
Subroutine _error: not called CC=1 SCAR=6.9
14 0 my $self = shift;
15 0 my $error = shift;
16 0 $error .= ": " . $self->response->status_line;
17 0 return $error;
18 }
19  
20 0 ▶sub _content {
Subroutine _content: not called CC=1 SCAR=6.9
21 0 my $self = shift;
22 0 return $self->response->decoded_content;
23 }
24  
25 0 ▶sub content {
Subroutine content: not called CC=2 SCAR=17.9
Pod undocumented
26 0 my $self = shift;
27 0 my $response = $self->response;
28 0 ▶ die $self->_error( "*** Invalid response" ) unless $response->is_success;
Branch: 1 branch
BranchTrueFalseTotal
unless $response->is_success 0 0 0
29 0 return $response->decoded_content;
30 }
31  
32 3 has value => qw/ is ro lazy_build 1 /;
33 0 ▶sub _build_value {
Subroutine _build_value: not called CC=1 SCAR=6.9
34 0 my $self = shift;
35 0 my $value = $self->content;
36 0 ▶ try {
Subroutine __ANON__: not called CC=2 SCAR=17.9
37 0 ▶ if ( $self->response->content_type =~ m/json/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->response->content_type =~ /json/) 0 0 0
38 0 $value =~ s/^var tumblr_api_read = //;
39 0 $value =~ s/;$//;
40 0 $value = WebService::Tumblr::json->decode( $value );
41 }
42 }
43 0 ▶ catch {
Subroutine __ANON__: not called CC=1 SCAR=6.9
44 0 die $self->_error( "*** Unable to parse: $_[0]" );
45 0 };
46 0 return $value;
47 }
48  
49 3 1;
« Tumblr.pm ↑ Summary Tumblr/Dispatch.pm »