line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Tumblr::Result; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
17
|
use strict; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
106
|
|
4
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
71
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
13
|
use Any::Moose; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
45
|
|
7
|
3
|
|
|
3
|
|
1509
|
use Try::Tiny; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
1388
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has dispatch => qw/ is ro required 1 isa WebService::Tumblr::Dispatch /, handles => [qw/ tumblr /]; |
10
|
|
|
|
|
|
|
has request => qw/ is ro required 1 isa HTTP::Request /; |
11
|
|
|
|
|
|
|
has response => qw/ is ro required 1 isa HTTP::Response /, handles => [qw/ is_success /]; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub _error { |
14
|
0
|
|
|
0
|
|
|
my $self = shift; |
15
|
0
|
|
|
|
|
|
my $error = shift; |
16
|
0
|
|
|
|
|
|
$error .= ": " . $self->response->status_line; |
17
|
0
|
|
|
|
|
|
return $error; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub _content { |
21
|
0
|
|
|
0
|
|
|
my $self = shift; |
22
|
0
|
|
|
|
|
|
return $self->response->decoded_content; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub content { |
26
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
27
|
0
|
|
|
|
|
|
my $response = $self->response; |
28
|
0
|
0
|
|
|
|
|
die $self->_error( "*** Invalid response" ) unless $response->is_success; |
29
|
0
|
|
|
|
|
|
return $response->decoded_content; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
has value => qw/ is ro lazy_build 1 /; |
33
|
|
|
|
|
|
|
sub _build_value { |
34
|
0
|
|
|
0
|
|
|
my $self = shift; |
35
|
0
|
|
|
|
|
|
my $value = $self->content; |
36
|
|
|
|
|
|
|
try { |
37
|
0
|
0
|
|
0
|
|
|
if ( $self->response->content_type =~ m/json/ ) { |
38
|
0
|
|
|
|
|
|
$value =~ s/^var tumblr_api_read = //; |
39
|
0
|
|
|
|
|
|
$value =~ s/;$//; |
40
|
0
|
|
|
|
|
|
$value = WebService::Tumblr::json->decode( $value ); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
catch { |
44
|
0
|
|
|
0
|
|
|
die $self->_error( "*** Unable to parse: $_[0]" ); |
45
|
0
|
|
|
|
|
|
}; |
46
|
0
|
|
|
|
|
|
return $value; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |