File Coverage

blib/lib/Groonga/HTTP.pm
Criterion Covered Total %
statement 30 51 58.8
branch 0 4 0.0
condition n/a
subroutine 10 16 62.5
pod 0 6 0.0
total 40 77 51.9


line stmt bran cond sub pod time code
1             # Copyright (C) 2021-2022 Horimoto Yasuhiro
2             #
3             # This program is free software: you can redistribute it and/or modify
4             # it under the terms of the GNU General Public License as published by
5             # the Free Software Foundation, either version 3 of the License, or
6             # (at your option) any later version.
7             #
8             # This program is distributed in the hope that it will be useful,
9             # but WITHOUT ANY WARRANTY; without even the implied warranty of
10             # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11             # GNU General Public License for more details.
12             #
13             # You should have received a copy of the GNU General Public License
14             # along with this program. If not, see .
15              
16             package Groonga::HTTP;
17              
18 1     1   1084 use LWP::UserAgent;
  1         37747  
  1         28  
19              
20 1     1   315 use Groonga::ResultSet;
  1         2  
  1         23  
21 1     1   310 use Groonga::Escape;
  1         2  
  1         24  
22              
23 1     1   328 use Groonga::HTTP::Client;
  1         2  
  1         23  
24              
25 1     1   320 use Groonga::Commands::Delete;
  1         2  
  1         26  
26 1     1   328 use Groonga::Commands::Load;
  1         1  
  1         24  
27 1     1   294 use Groonga::Commands::Status;
  1         2  
  1         23  
28 1     1   314 use Groonga::Commands::Select;
  1         2  
  1         27  
29              
30              
31 1     1   5 use strict;
  1         1  
  1         16  
32 1     1   4 use warnings;
  1         1  
  1         270  
33              
34             our $VERSION = "1.11";
35              
36             my $host = '127.0.0.1';
37             my $port = 10041;
38             my $groonga_http_client = undef;
39              
40             sub new {
41 0     0 0   my ($class, %args) = @_;
42 0           my $self = {%args};
43              
44 0 0         if ($self->{host}) {
45 0           $host = $self->{host};
46             }
47 0 0         if ($self->{port}) {
48 0           $port = $self->{port};
49             }
50              
51             $groonga_http_client =
52 0           Groonga::HTTP::Client->new(host => $host, port => $port);
53 0           return bless $self, $class;
54             }
55              
56             sub status {
57 0     0 0   my $status =
58             Groonga::Commands::Status->new(client => $groonga_http_client);
59 0           return $status->execute;
60             }
61              
62             sub select {
63 0     0 0   my ($client, %args) = @_;
64 0           my $select =
65             Groonga::Commands::Select->new(
66             client => $groonga_http_client,
67             %args
68             );
69 0           return $select->execute;
70             }
71              
72             sub load {
73 0     0 0   my ($client, %args) = @_;
74 0           my $load =
75             Groonga::Commands::Load->new(
76             client => $groonga_http_client,
77             %args
78             );
79 0           return $load->execute;
80             }
81              
82             sub delete {
83 0     0 0   my ($client, %args) = @_;
84 0           my $delete =
85             Groonga::Commands::Delete->new(
86             client => $groonga_http_client,
87             %args
88             );
89 0           return $delete->execute;
90             }
91              
92             sub groonga_query_escape {
93 0     0 0   my ($client, $raw_query) = @_;
94 0           return Groonga::Escape->escape($raw_query);
95             }
96              
97             1;
98             __END__