hachi 0.2.0 → 0.2.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
  SHA256:
3
- metadata.gz: f58d7b1ed785abfc7d69d44f261074333b779f60f21317bf6070c79bf9ea67cd
4
- data.tar.gz: 55b4a69a5aa240fc7b81e81f576ecf2afc9ae6a58598a136dc0cfa398cd7bc31
3
+ metadata.gz: a319c1c79696358c41de7fa1df683d09162eb41b9c19b28fb5ffa56bd9da89b7
4
+ data.tar.gz: 0fe4dc40cd59d0b794009d2ba91e7c1330f84bc689f2236963b618c2ec511fb1
5
5
  SHA512:
6
- metadata.gz: e127d0b1f0e49334cce18a4ee0fe1d56de814a52862ed9048e1810e851f1030a85d181d442661d42b7f13b9cdc4a71c39f4816b835d9b2d2f2646808eb9f852b
7
- data.tar.gz: c100c3044222c254321f9de7675b9417ee16c147cfe72349c803204c6ab6798528bfb1612fc36f6dd0b287b4520905efc4a8de4357b86ce3552d868916f04c99
6
+ metadata.gz: 4dc84dd512c59811549ecf92e35d78eee5a843d4ec0cf45798b01b4573bd4d819fb32be67a0a7560a57b1b86e75d56d4a804e2e639f52d759bb2f3ed6c185fb0
7
+ data.tar.gz: 05b182a298cce9505a70fc5654c87990b8fe377255816fa83422a7a09ce0e36033606f602effc09ddf6ff68d1266550d7dd3239e50daceb5d16cc79c65752e63
@@ -64,7 +64,11 @@ module Hachi
64
64
  response = http.request(req)
65
65
  json = parse_body(response.body)
66
66
 
67
- raise(Error, "Unsupported response code returned: #{response.code} (#{json&.dig('message')})") unless response.code.start_with? "20"
67
+ code = response.code
68
+ unless code.start_with? "20"
69
+ message = json.dig("message")
70
+ raise Error, "Unsupported response code returned: #{code} (#{message})"
71
+ end
68
72
 
69
73
  yield json
70
74
  end
@@ -114,8 +118,8 @@ module Hachi
114
118
  validate_range range
115
119
 
116
120
  conditions = attributes.map do |key, value|
117
- if value.is_a?(Array)
118
- { _string: value.join(", ") }
121
+ if key == :data && value.is_a?(Array)
122
+ { _or: decompose_data(value) }
119
123
  else
120
124
  { _string: "#{key}:#{value}" }
121
125
  end
@@ -134,6 +138,12 @@ module Hachi
134
138
 
135
139
  post("#{path}?range=#{range}", query: query) { |json| json }
136
140
  end
141
+
142
+ def decompose_data(data)
143
+ data.map do |elem|
144
+ { _field: "data", _value: elem }
145
+ end
146
+ end
137
147
  end
138
148
  end
139
149
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Hachi
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hachi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manabu Niseki