groonga-client 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/doc/text/news.md +8 -0
- data/lib/groonga/client/response/load.rb +27 -3
- data/lib/groonga/client/version.rb +1 -1
- data/test/response/test-load.rb +78 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9c339f846c4dd77c1d102b3fa5b6a3cf4089d66
|
4
|
+
data.tar.gz: 7cc21590afb0f4999f4098180574d8624610f056
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4041083e2efa90d027c789869234e17c65b68b51933c2d76012fb4b5f0c0ff72c2efa896978c5174528ae42ff2283fc23914935cca488296ef7913362f2bf994
|
7
|
+
data.tar.gz: 9a4ae8ae3f50124137312a7debcb079ef0687574e05808599c72199c69de9e195b9c634d93421d5dfe2017dec7d1c89f9d252fd741659a400bbf2916a344c0b5
|
data/doc/text/news.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# NEWS
|
2
2
|
|
3
|
+
## 0.3.2 - 2016-12-06
|
4
|
+
|
5
|
+
### Improvements
|
6
|
+
|
7
|
+
* `Groonga::Load#n_loaded_records`: Added. It's a convenience method to get the number of loaded records.
|
8
|
+
|
9
|
+
* `Groonga::Load#ids`: Added. It's for `load --output_ids yes --command_version 3` that can be used with Groonga 6.1.2 or later.
|
10
|
+
|
3
11
|
## 0.3.1 - 2016-10-11
|
4
12
|
|
5
13
|
### Improvements
|
@@ -1,6 +1,5 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
#
|
3
1
|
# Copyright (C) 2013 Haruka Yoshihara <yoshihara@clear-code.com>
|
2
|
+
# Copyright (C) 2016 Kouhei Sutou <kou@clear-code.com>
|
4
3
|
#
|
5
4
|
# This library is free software; you can redistribute it and/or
|
6
5
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -23,8 +22,33 @@ module Groonga
|
|
23
22
|
module Response
|
24
23
|
class Load < Base
|
25
24
|
Response.register("load", self)
|
25
|
+
|
26
|
+
# @return [Integer] The number of loaded records.
|
27
|
+
attr_accessor :n_loaded_records
|
28
|
+
|
29
|
+
# @return [::Array<Integer>] The IDs of loaded records. ID is
|
30
|
+
# `0` if the corresponding record is failed to add.
|
31
|
+
#
|
32
|
+
# If you don't specify `yes` to `output_ids` `load`
|
33
|
+
# parameter, this is always an empty array.
|
34
|
+
attr_accessor :ids
|
35
|
+
|
36
|
+
def body=(body)
|
37
|
+
super(body)
|
38
|
+
parse_body(body)
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
def parse_body(body)
|
43
|
+
if body.is_a?(::Hash)
|
44
|
+
@n_loaded_records = body["n_loaded_records"]
|
45
|
+
@ids = body["ids"] || []
|
46
|
+
else
|
47
|
+
@n_loaded_records = body
|
48
|
+
@ids = []
|
49
|
+
end
|
50
|
+
end
|
26
51
|
end
|
27
52
|
end
|
28
53
|
end
|
29
54
|
end
|
30
|
-
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# Copyright (C) 2016 Kouhei Sutou <kou@clear-code.com>
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library 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 GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
require "response/helper"
|
18
|
+
|
19
|
+
class TestResponseLoad < Test::Unit::TestCase
|
20
|
+
private
|
21
|
+
def create_response(command, body)
|
22
|
+
header = {
|
23
|
+
"return_code" => 0,
|
24
|
+
"start_time" => 1372430096.70991,
|
25
|
+
"elapsed_time" => 0.000522851943969727,
|
26
|
+
}
|
27
|
+
Groonga::Client::Response::Load.new(command, header, body)
|
28
|
+
end
|
29
|
+
|
30
|
+
sub_test_case("#n_loaded_records") do
|
31
|
+
test("command_version=1") do
|
32
|
+
command = Groonga::Command::Load.new("load",
|
33
|
+
{"command_version" => "1"})
|
34
|
+
response = create_response(command, 29)
|
35
|
+
assert_equal(29, response.n_loaded_records)
|
36
|
+
end
|
37
|
+
|
38
|
+
test("command_version=3") do
|
39
|
+
command = Groonga::Command::Load.new("load",
|
40
|
+
{"command_version" => "3"})
|
41
|
+
response = create_response(command, {"n_loaded_records" => 29})
|
42
|
+
assert_equal(29, response.n_loaded_records)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
sub_test_case("#ids") do
|
47
|
+
test("command_version=1") do
|
48
|
+
command = Groonga::Command::Load.new("load",
|
49
|
+
{"command_version" => "1"})
|
50
|
+
response = create_response(command, 29)
|
51
|
+
assert_equal([], response.ids)
|
52
|
+
end
|
53
|
+
|
54
|
+
sub_test_case("command_version=3") do
|
55
|
+
test("no output_ids") do
|
56
|
+
command = Groonga::Command::Load.new("load",
|
57
|
+
{"command_version" => "3"})
|
58
|
+
response = create_response(command, {"n_loaded_records" => 29})
|
59
|
+
assert_equal(29, response.n_loaded_records)
|
60
|
+
end
|
61
|
+
|
62
|
+
test("output_ids=yes") do
|
63
|
+
command = Groonga::Command::Load.new("load",
|
64
|
+
{
|
65
|
+
"command_version" => "3",
|
66
|
+
"output_ids" => "yes",
|
67
|
+
})
|
68
|
+
ids = [1, 2, 0, 4, 3]
|
69
|
+
response = create_response(command,
|
70
|
+
{
|
71
|
+
"n_loaded_records" => 4,
|
72
|
+
"ids" => ids,
|
73
|
+
})
|
74
|
+
assert_equal(ids, response.ids)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: groonga-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Haruka Yoshihara
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-12-06 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: gqtp
|
@@ -216,6 +216,7 @@ files:
|
|
216
216
|
- test/response/test-base.rb
|
217
217
|
- test/response/test-column-list.rb
|
218
218
|
- test/response/test-error.rb
|
219
|
+
- test/response/test-load.rb
|
219
220
|
- test/response/test-schema.rb
|
220
221
|
- test/response/test-select-command-version1.rb
|
221
222
|
- test/response/test-select-command-version3.rb
|
@@ -249,7 +250,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
249
250
|
version: '0'
|
250
251
|
requirements: []
|
251
252
|
rubyforge_project:
|
252
|
-
rubygems_version: 2.5.
|
253
|
+
rubygems_version: 2.5.2
|
253
254
|
signing_key:
|
254
255
|
specification_version: 4
|
255
256
|
summary: Groonga-client is a client for Groonga (http://groonga.org/) implemented
|
@@ -262,6 +263,7 @@ test_files:
|
|
262
263
|
- test/protocol/test-http.rb
|
263
264
|
- test/run-test.rb
|
264
265
|
- test/response/test-base.rb
|
266
|
+
- test/response/test-load.rb
|
265
267
|
- test/response/test-column-list.rb
|
266
268
|
- test/response/helper.rb
|
267
269
|
- test/response/test-error.rb
|