| 1 | # Copyright (C) 2021-2022 Horimoto Yasuhiro <horimoto@clear-code.com> | ||||||||||
| 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 <https://www.gnu.org/licenses/>. | ||||||||||
| 15 | |||||||||||
| 16 | package Groonga::HTTP; | ||||||||||
| 17 | |||||||||||
| 18 | 1 | ▶ | use LWP::UserAgent; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | |||||||||||
| 20 | 1 | ▶ | use Groonga::ResultSet; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 1 | ▶ | use Groonga::Escape; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | |||||||||||
| 23 | 1 | ▶ | use Groonga::HTTP::Client; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 24 | |||||||||||
| 25 | 1 | ▶ | use Groonga::Commands::Delete; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 26 | 1 | ▶ | use Groonga::Commands::Load; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 27 | 1 | ▶ | use Groonga::Commands::Status; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 28 | 1 | ▶ | use Groonga::Commands::Select; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 29 | |||||||||||
| 30 | |||||||||||
| 31 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 32 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 33 | |||||||||||
| 34 | 1 | our $VERSION = "1.11"; | |||||||||
| 35 | |||||||||||
| 36 | 1 | my $host = '127.0.0.1'; | |||||||||
| 37 | 1 | my $port = 10041; | |||||||||
| 38 | 1 | my $groonga_http_client = undef; | |||||||||
| 39 | |||||||||||
| 40 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 41 | 0 | my ($class, %args) = @_; | |||||||||
| 42 | 0 | my $self = {%args}; | |||||||||
| 43 | |||||||||||
| 44 | 0 | ▶ | if ($self->{host}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 45 | 0 | $host = $self->{host}; | |||||||||
| 46 | } | ||||||||||
| 47 | 0 | ▶ | if ($self->{port}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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 | 0 | ▶ | sub status { | ||||||||
|
Subroutine
status: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 57 | 0 | my $status = | |||||||||
| 58 | Groonga::Commands::Status->new(client => $groonga_http_client); | ||||||||||
| 59 | 0 | return $status->execute; | |||||||||
| 60 | } | ||||||||||
| 61 | |||||||||||
| 62 | 0 | ▶ | sub select { | ||||||||
|
Subroutine
select: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 63 | 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 | 0 | ▶ | sub load { | ||||||||
|
Subroutine
load: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 73 | 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 | 0 | ▶ | sub delete { | ||||||||
|
Subroutine
delete: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 83 | 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 | 0 | ▶ | sub groonga_query_escape { | ||||||||
|
Subroutine
groonga_query_escape: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 93 | 0 | my ($client, $raw_query) = @_; | |||||||||
| 94 | 0 | return Groonga::Escape->escape($raw_query); | |||||||||
| 95 | } | ||||||||||
| 96 | |||||||||||
| 97 | 1 | 1; | |||||||||
| 98 | __END__ | ||||||||||