groonga-client 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1d48aabe77a551429a057a3b1ab6146ae0922806
4
- data.tar.gz: e59ee42028c1c5fa8c41297b6bd12c6ce09ac190
3
+ metadata.gz: f9c339f846c4dd77c1d102b3fa5b6a3cf4089d66
4
+ data.tar.gz: 7cc21590afb0f4999f4098180574d8624610f056
5
5
  SHA512:
6
- metadata.gz: f037cb0748f6d184a0146767b6560ab46bf1c12d7eb1d9d38fadf04be51490cd4d5ae1056bea4f0f4e55df662b532bbe6e560b93407bd94380df92a89367e1a7
7
- data.tar.gz: 39c6fbec14c2d83993078458221a73c23dd43a5536ea0a3323fb3854982b5921b21567c365c5c50bb42d1e09edf5a6798868bbbc213893d52aa14c72c24a2253
6
+ metadata.gz: 4041083e2efa90d027c789869234e17c65b68b51933c2d76012fb4b5f0c0ff72c2efa896978c5174528ae42ff2283fc23914935cca488296ef7913362f2bf994
7
+ data.tar.gz: 9a4ae8ae3f50124137312a7debcb079ef0687574e05808599c72199c69de9e195b9c634d93421d5dfe2017dec7d1c89f9d252fd741659a400bbf2916a344c0b5
@@ -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
-
@@ -16,6 +16,6 @@
16
16
 
17
17
  module Groonga
18
18
  class Client
19
- VERSION = "0.3.1"
19
+ VERSION = "0.3.2"
20
20
  end
21
21
  end
@@ -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.1
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-10-11 00:00:00.000000000 Z
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.1
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