groonga-client 0.4.0 → 0.4.1

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: b10f2746556ebf27bbe22c67f37fe6758aab8400
4
- data.tar.gz: 5f96d9789517af65942d155c12053d88283b2d3e
3
+ metadata.gz: 227bf7a979643ac2f17b20d32b4b3ed0129f8321
4
+ data.tar.gz: 6e7b2e2451b0d0bf59313a639f2c7c819b4aba7b
5
5
  SHA512:
6
- metadata.gz: 6dddafd8f52e38d9d9a6a53cf24a5ab475de32a106d955743c289a64c87d1907cfc13777a4a1c1cfc3be711ec9d6d4287d832e10861f308b1710c240b8b05117
7
- data.tar.gz: 69fb56a8c4322708287bf815f883d1c04748476bba5b54048ae35070314d45b96374ada729ade886c4562047001a8f9752367cab04a1fb19c35ccc8221a52d8f
6
+ metadata.gz: 842ff5602d19852b2ebceb64c470efe15eb48a85ef24c539dfd3e7e09458139a9cba3c899cffce26a29cb25cd2c771f815550aaf283c69f62d740161122e0504
7
+ data.tar.gz: 66bd127398051d6314c7df147688297244dd609c89b7a06eca59351634d4f7c2e06676eb0bb695af55a34553b7a24162e48c28c2eb67a98b77401a75cd741592
data/doc/text/news.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # NEWS
2
2
 
3
+ ## 0.4.1 - 2016-02-07
4
+
5
+ ### Improvements
6
+
7
+ * `Groonga::Client::Request::Base`: Supported number as parameter
8
+ value.
9
+
10
+ * `Groonga::Client::Response::Load#errors`: Added for `load
11
+ --output_errors yes --command_version 3`.
12
+
13
+ * `Groonga::Client::Request::Select::DynamicColumnWindow#group_keys`:
14
+ Added for `select --columns[LABEL].window.group_keys`. You can use
15
+ this method by `request.columns(LABEL).window.group_keys(KEYS)`.
16
+
3
17
  ## 0.4.0 - 2016-01-12
4
18
 
5
19
  ### Improvements
@@ -88,6 +88,8 @@ module Groonga
88
88
  when String
89
89
  return {} if @value.empty?
90
90
  value = @value
91
+ when Numeric
92
+ value = @value.to_s
91
93
  when NilClass
92
94
  return {}
93
95
  else
@@ -114,6 +114,9 @@ module Groonga
114
114
  def paginate(page, per_page: 10)
115
115
  page ||= 1
116
116
  page = page.to_i
117
+ per_page = per_page.to_i
118
+ per_page = 10 if per_page <= 0
119
+
117
120
  if page <= 0
118
121
  offset = 0
119
122
  else
@@ -254,6 +257,17 @@ module Groonga
254
257
  alias_method :sortby, :sort_keys
255
258
  alias_method :sort, :sort_keys
256
259
 
260
+ # Sets `columns[LABEL].window.group_keys` parameter.
261
+ #
262
+ # @return [Groonga::Client::Request::Select] The current
263
+ # request object.
264
+ #
265
+ # @since 0.4.1
266
+ def group_keys(value)
267
+ add_parameter(OverwriteMerger,
268
+ ValuesParameter.new([:"#{prefix}group_keys"], value))
269
+ end
270
+
257
271
  private
258
272
  def prefix
259
273
  "columns[#{@label}].window."
@@ -37,6 +37,16 @@ module Groonga
37
37
  # @since 0.3.3
38
38
  attr_accessor :loaded_ids
39
39
 
40
+ # @return [::Array<Groonga::Client::Response::Load::Error>]
41
+ # The errors of loaded records. `error.return_code` isn't
42
+ # `0` if the corresponding record is failed to load.
43
+ #
44
+ # If you don't specify `yes` to `output_errors` `load`
45
+ # parameter, this is always an empty array.
46
+ #
47
+ # @since 0.4.1
48
+ attr_accessor :errors
49
+
40
50
  def body=(body)
41
51
  super(body)
42
52
  parse_body(body)
@@ -47,11 +57,19 @@ module Groonga
47
57
  if body.is_a?(::Hash)
48
58
  @n_loaded_records = body["n_loaded_records"]
49
59
  @loaded_ids = body["loaded_ids"] || []
60
+ @errors = (body["errors"] || []).collect do |error|
61
+ Error.new(error["return_code"] || 0,
62
+ error["message"])
63
+ end
50
64
  else
51
65
  @n_loaded_records = body
52
66
  @loaded_ids = []
67
+ @errors = []
53
68
  end
54
69
  end
70
+
71
+ class Error < Struct.new(:return_code, :message)
72
+ end
55
73
  end
56
74
  end
57
75
  end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2016 Kouhei Sutou <kou@clear-code.com>
1
+ # Copyright (C) 2013-2017 Kouhei Sutou <kou@clear-code.com>
2
2
  #
3
3
  # This library is free software; you can redistribute it and/or
4
4
  # modify it under the terms of the GNU Lesser General Public
@@ -16,6 +16,6 @@
16
16
 
17
17
  module Groonga
18
18
  class Client
19
- VERSION = "0.4.0"
19
+ VERSION = "0.4.1"
20
20
  end
21
21
  end
@@ -158,7 +158,7 @@ class TestRequestSelect < Test::Unit::TestCase
158
158
  test "Integer" do
159
159
  assert_equal({
160
160
  :table => "posts",
161
- :"drilldowns[label].offset" => 29,
161
+ :"drilldowns[label].offset" => "29",
162
162
  },
163
163
  drilldown.offset(29).to_parameters)
164
164
  end
@@ -168,7 +168,7 @@ class TestRequestSelect < Test::Unit::TestCase
168
168
  test "Integer" do
169
169
  assert_equal({
170
170
  :table => "posts",
171
- :"drilldowns[label].limit" => 29,
171
+ :"drilldowns[label].limit" => "29",
172
172
  },
173
173
  drilldown.limit(29).to_parameters)
174
174
  end
@@ -248,6 +248,141 @@ class TestRequestSelect < Test::Unit::TestCase
248
248
  },
249
249
  column.window.sort_keys("_id").to_parameters)
250
250
  end
251
+
252
+ test "#group_keys" do
253
+ assert_equal({
254
+ :table => "posts",
255
+ :"columns[label].window.group_keys" => "day, tag",
256
+ },
257
+ column.window.group_keys(["day", "tag"]).to_parameters)
258
+ end
259
+ end
260
+ end
261
+
262
+ sub_test_case("#paginate") do
263
+ def paginate(*args)
264
+ @request.paginate(*args).to_parameters
265
+ end
266
+
267
+ sub_test_case("page") do
268
+ test("nil") do
269
+ assert_equal({
270
+ :table => "posts",
271
+ :offset => "0",
272
+ :limit => "10",
273
+ },
274
+ paginate(nil))
275
+ end
276
+
277
+ test("0") do
278
+ assert_equal({
279
+ :table => "posts",
280
+ :offset => "0",
281
+ :limit => "10",
282
+ },
283
+ paginate(0))
284
+ end
285
+
286
+ test("1") do
287
+ assert_equal({
288
+ :table => "posts",
289
+ :offset => "0",
290
+ :limit => "10",
291
+ },
292
+ paginate(1))
293
+ end
294
+
295
+ test("positive") do
296
+ assert_equal({
297
+ :table => "posts",
298
+ :offset => "80",
299
+ :limit => "10",
300
+ },
301
+ paginate(9))
302
+ end
303
+
304
+ test("negative") do
305
+ assert_equal({
306
+ :table => "posts",
307
+ :offset => "0",
308
+ :limit => "10",
309
+ },
310
+ paginate(-1))
311
+ end
312
+
313
+ test("string") do
314
+ assert_equal({
315
+ :table => "posts",
316
+ :offset => "80",
317
+ :limit => "10",
318
+ },
319
+ paginate("9"))
320
+ end
321
+ end
322
+
323
+ sub_test_case("paginate") do
324
+ test("default") do
325
+ assert_equal({
326
+ :table => "posts",
327
+ :offset => "20",
328
+ :limit => "10",
329
+ },
330
+ paginate(3))
331
+ end
332
+
333
+ test("nil") do
334
+ assert_equal({
335
+ :table => "posts",
336
+ :offset => "20",
337
+ :limit => "10",
338
+ },
339
+ paginate(3, per_page: nil))
340
+ end
341
+
342
+ test("0") do
343
+ assert_equal({
344
+ :table => "posts",
345
+ :offset => "20",
346
+ :limit => "10",
347
+ },
348
+ paginate(3, per_page: 0))
349
+ end
350
+
351
+ test("1") do
352
+ assert_equal({
353
+ :table => "posts",
354
+ :offset => "2",
355
+ :limit => "1",
356
+ },
357
+ paginate(3, per_page: 1))
358
+ end
359
+
360
+ test("positive") do
361
+ assert_equal({
362
+ :table => "posts",
363
+ :offset => "58",
364
+ :limit => "29",
365
+ },
366
+ paginate(3, per_page: 29))
367
+ end
368
+
369
+ test("negative") do
370
+ assert_equal({
371
+ :table => "posts",
372
+ :offset => "20",
373
+ :limit => "10",
374
+ },
375
+ paginate(3, per_page: -1))
376
+ end
377
+
378
+ test("string") do
379
+ assert_equal({
380
+ :table => "posts",
381
+ :offset => "58",
382
+ :limit => "29",
383
+ },
384
+ paginate(3, per_page: "29"))
385
+ end
251
386
  end
252
387
  end
253
388
  end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2016 Kouhei Sutou <kou@clear-code.com>
1
+ # Copyright (C) 2016-2017 Kouhei Sutou <kou@clear-code.com>
2
2
  #
3
3
  # This library is free software; you can redistribute it and/or
4
4
  # modify it under the terms of the GNU Lesser General Public
@@ -52,7 +52,7 @@ class TestResponseLoad < Test::Unit::TestCase
52
52
  end
53
53
 
54
54
  sub_test_case("command_version=3") do
55
- test("no output_ids") do
55
+ test("no output_*") do
56
56
  command = Groonga::Command::Load.new("load",
57
57
  {"command_version" => "3"})
58
58
  response = create_response(command, {"n_loaded_records" => 29})
@@ -73,6 +73,39 @@ class TestResponseLoad < Test::Unit::TestCase
73
73
  })
74
74
  assert_equal(loaded_ids, response.loaded_ids)
75
75
  end
76
+
77
+ test("output_errors=yes") do
78
+ command = Groonga::Command::Load.new("load",
79
+ {
80
+ "command_version" => "3",
81
+ "output_errors" => "yes",
82
+ })
83
+ raw_errors = [
84
+ {
85
+ "return_code" => 0,
86
+ "message" => nil,
87
+ },
88
+ {
89
+ "return_code" => -22,
90
+ "message" => "invalid argument",
91
+ },
92
+ {
93
+ "return_code" => 0,
94
+ "message" => nil,
95
+ },
96
+ ]
97
+ errors = [
98
+ Groonga::Client::Response::Load::Error.new(0, nil),
99
+ Groonga::Client::Response::Load::Error.new(-22, "invalid argument"),
100
+ Groonga::Client::Response::Load::Error.new(0, nil),
101
+ ]
102
+ response = create_response(command,
103
+ {
104
+ "n_loaded_records" => 3,
105
+ "errors" => raw_errors,
106
+ })
107
+ assert_equal(errors, response.errors)
108
+ end
76
109
  end
77
110
  end
78
111
  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.4.0
4
+ version: 0.4.1
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: 2017-01-12 00:00:00.000000000 Z
13
+ date: 2017-02-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: gqtp