| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::Groonga::HTTP::Response; |
|
2
|
1
|
|
|
1
|
|
1272
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
29
|
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
26
|
|
|
4
|
1
|
|
|
1
|
|
789
|
use utf8; |
|
|
1
|
|
|
|
|
7
|
|
|
|
1
|
|
|
|
|
4
|
|
|
5
|
1
|
|
|
1
|
|
25
|
use JSON::XS qw(decode_json); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
37
|
|
|
6
|
1
|
|
|
1
|
|
639
|
use Data::Page; |
|
|
1
|
|
|
|
|
15354
|
|
|
|
1
|
|
|
|
|
12
|
|
|
7
|
1
|
|
|
1
|
|
561
|
use Net::Groonga::Pager; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
32
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
6
|
use Mouse; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
3
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has function => ( |
|
12
|
|
|
|
|
|
|
is => 'rw', |
|
13
|
|
|
|
|
|
|
required => 1, |
|
14
|
|
|
|
|
|
|
); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has args => ( |
|
17
|
|
|
|
|
|
|
is => 'rw', |
|
18
|
|
|
|
|
|
|
required => 1, |
|
19
|
|
|
|
|
|
|
); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has http_response => ( |
|
22
|
|
|
|
|
|
|
is => 'rw', |
|
23
|
|
|
|
|
|
|
required => 1, |
|
24
|
|
|
|
|
|
|
); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has data => ( |
|
27
|
|
|
|
|
|
|
is => 'rw', |
|
28
|
|
|
|
|
|
|
builder => '_build_data', |
|
29
|
|
|
|
|
|
|
); |
|
30
|
|
|
|
|
|
|
|
|
31
|
1
|
|
|
1
|
|
280
|
no Mouse; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
4
|
|
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub is_success { |
|
34
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
35
|
0
|
|
0
|
|
|
|
return $self->http_response->code eq 200 && $self->return_code == 0; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub _build_data { |
|
39
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
40
|
0
|
0
|
|
|
|
|
return undef if $self->http_response->code ne 200; |
|
41
|
0
|
0
|
|
|
|
|
return $self->http_response->content if $self->function eq 'dump'; |
|
42
|
0
|
|
|
|
|
|
decode_json($self->http_response->content); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub return_code { |
|
46
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
47
|
0
|
0
|
|
|
|
|
Carp::croak(sprintf("%s:%s", $self->function, $self->http_response->status_line)) unless $self->data; |
|
48
|
0
|
0
|
|
|
|
|
return 0 if $self->function eq 'dump'; |
|
49
|
0
|
|
|
|
|
|
$self->data->[0]->[0]; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub start_time { |
|
53
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
54
|
0
|
0
|
|
|
|
|
Carp::croak(sprintf("%s:%s", $self->function, $self->http_response->status_line)) unless $self->data; |
|
55
|
0
|
0
|
|
|
|
|
return undef if $self->function eq 'dump'; |
|
56
|
0
|
|
|
|
|
|
$self->data->[0]->[1]; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub elapsed_time { |
|
60
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
61
|
0
|
0
|
|
|
|
|
Carp::croak(sprintf("%s:%s", $self->function, $self->http_response->status_line)) unless $self->data; |
|
62
|
0
|
0
|
|
|
|
|
return undef if $self->function eq 'dump'; |
|
63
|
0
|
|
|
|
|
|
$self->data->[0]->[2]; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub result { |
|
67
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
68
|
0
|
0
|
|
|
|
|
Carp::croak(sprintf("%s:%s:%s", $self->function, $self->http_response->status_line, substr($self->http_response->content, 0, 256))) unless $self->data; |
|
69
|
0
|
0
|
|
|
|
|
return $self->data if $self->function eq 'dump'; |
|
70
|
0
|
|
|
|
|
|
$self->data->[1]; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub pager { |
|
74
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
75
|
0
|
0
|
|
|
|
|
return unless $self->data; |
|
76
|
0
|
0
|
|
|
|
|
return unless $self->return_code == 0; |
|
77
|
0
|
0
|
|
|
|
|
return unless ref $self->data eq 'ARRAY'; |
|
78
|
0
|
0
|
|
|
|
|
return unless ref $self->data->[1] eq 'ARRAY'; |
|
79
|
0
|
0
|
|
|
|
|
return unless ref $self->data->[1]->[0] eq 'ARRAY'; |
|
80
|
0
|
0
|
|
|
|
|
return unless ref $self->data->[1]->[0]->[0] eq 'ARRAY'; |
|
81
|
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
my $total_entries = $self->data->[1]->[0]->[0]->[0]; |
|
83
|
0
|
|
0
|
|
|
|
my $limit = $self->args->{limit} || 10; |
|
84
|
0
|
|
0
|
|
|
|
my $offset = $self->args->{offset} || 0; |
|
85
|
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
Net::Groonga::Pager->new( |
|
87
|
|
|
|
|
|
|
limit => $limit, |
|
88
|
|
|
|
|
|
|
offset => $offset, |
|
89
|
|
|
|
|
|
|
total_entries => $total_entries, |
|
90
|
|
|
|
|
|
|
); |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub rows { |
|
94
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
95
|
0
|
0
|
|
|
|
|
return unless $self->data; |
|
96
|
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
my @rows = @{$self->data->[1]->[0]}; |
|
|
0
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
my $cnt = shift @rows; |
|
99
|
0
|
|
|
|
|
|
my $header = shift @rows; |
|
100
|
0
|
|
|
|
|
|
my @results; |
|
101
|
0
|
|
|
|
|
|
for my $row (@rows) { |
|
102
|
0
|
|
|
|
|
|
my %args; |
|
103
|
0
|
|
|
|
|
|
for (my $i=0; $i<@$header; ++$i) { |
|
104
|
0
|
|
|
|
|
|
my $key = $header->[$i]->[0]; |
|
105
|
0
|
|
|
|
|
|
my $val = $row->[$i]; |
|
106
|
0
|
|
|
|
|
|
$args{$key} = $val; |
|
107
|
|
|
|
|
|
|
} |
|
108
|
0
|
|
|
|
|
|
push @results, \%args; |
|
109
|
|
|
|
|
|
|
} |
|
110
|
0
|
|
|
|
|
|
return @results; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
1; |
|
114
|
|
|
|
|
|
|
__END__ |