algoliasearch 1.1.15 → 1.1.16

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: 24e44bd6f2d0d045a075065b88349b5ea57dec1d
4
- data.tar.gz: 171671f8ae4eb263e94eabd10634c34c3d3b535e
3
+ metadata.gz: 9a5b805f07b381464702a5730df66afaf269deab
4
+ data.tar.gz: 20ec0ac8649ed6260de80004ffc71bda15f04f3c
5
5
  SHA512:
6
- metadata.gz: f368ba248cd7d98bb6fdbdceacaca32e914aa3d2095b0a109c6cf60fed173177a9e23fb3cc09700465907fefbe25e902e455336f1fb5129235a51d1033458d26
7
- data.tar.gz: 4b9322065da7cd0cd59c48b813da27772b73f260591b2fb58ee77d38e245fa5e010933c77376844b0abb6aacdd38ea80ddc51aea73bd84763c338bd05ae1b512
6
+ metadata.gz: ca22ebe2ea6f5bf41069c668119981da77bb2f36b982b1f4b12a8097bf0fcce98944664fd4f8d9ced69211eaca2f6ed56c6a171fc2544e6b05c873de1896363f
7
+ data.tar.gz: 0502436b3c8f7ba247595b97aa7ac3d47ba172631dfd2267e8804544524ccbcac2161c76eee07473f407d3dc3b0b40109b62be5a91a643214da4b9b7ed69922f
data/.travis.yml CHANGED
@@ -5,7 +5,6 @@ branches:
5
5
  rvm:
6
6
  - 2.0.0
7
7
  - 1.9.3
8
- - rbx-2.2.1
9
8
  env:
10
9
  global:
11
10
  - secure: lBLtTjQyeJW7+TWgGmf1mmsXgUzsTnq3/KHvCk+BvOGwoHXTBR1Y6yiczWWHEP4/wBeXXm31xUQC+VoYc/7Ev/2NNB/mqlXAgGw+D0nwQriNXjYt1WV6lQvyoiaUzQ+w+7VahWdx0LuKvSYI+khe8M8BfHQqYacu0VlpAUnjb2I=
data/ChangeLog CHANGED
@@ -1,5 +1,11 @@
1
1
  CHANGELOG
2
2
 
3
+ 2013-12-16 1.1.16
4
+
5
+ * Add arguments type-checking
6
+ * Normalize save_object/partial_update/add_object signatures
7
+ * Force dependencies versions
8
+
3
9
  2013-12-16 1.1.15
4
10
 
5
11
  * Embed ca-bundle.crt
data/Gemfile CHANGED
@@ -1,15 +1,15 @@
1
- source "http://rubygems.org"
1
+ source 'http://rubygems.org'
2
2
 
3
- gem "curb"
3
+ gem 'curb', '~> 0.8'
4
+ gem 'json', '>= 1.5.1'
4
5
 
5
6
  group :development do
6
- gem "bundler"
7
- gem "jeweler"
8
- gem "travis"
7
+ gem 'jeweler'
8
+ gem 'travis'
9
9
  end
10
10
 
11
11
  group :test do
12
- gem 'rspec'
12
+ gem 'rspec', '>= 2.5.0'
13
13
  gem 'autotest'
14
14
  gem 'autotest-fsevent'
15
15
  gem 'redgreen'
data/Gemfile.lock CHANGED
@@ -1,28 +1,28 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- ZenTest (4.9.4)
4
+ ZenTest (4.9.5)
5
5
  addressable (2.3.5)
6
6
  autotest (4.4.6)
7
7
  ZenTest (>= 4.4.1)
8
- autotest-fsevent (0.2.8)
8
+ autotest-fsevent (0.2.9)
9
9
  sys-uname
10
10
  autotest-growl (0.2.16)
11
11
  backports (3.3.5)
12
12
  builder (3.2.2)
13
- coderay (1.0.9)
13
+ coderay (1.1.0)
14
14
  crack (0.4.1)
15
15
  safe_yaml (~> 0.9.0)
16
16
  curb (0.8.5)
17
- diff-lcs (1.2.4)
18
- ethon (0.6.1)
17
+ diff-lcs (1.2.5)
18
+ ethon (0.6.2)
19
19
  ffi (>= 1.3.0)
20
20
  mime-types (~> 1.18)
21
21
  faraday (0.8.8)
22
22
  multipart-post (~> 1.2.0)
23
23
  faraday_middleware (0.9.0)
24
24
  faraday (>= 0.7.4, < 0.9)
25
- ffi (1.9.0)
25
+ ffi (1.9.3)
26
26
  gh (0.13.0)
27
27
  addressable
28
28
  backports
@@ -39,7 +39,7 @@ GEM
39
39
  nokogiri (~> 1.5.2)
40
40
  oauth2
41
41
  hashie (2.0.5)
42
- highline (1.6.19)
42
+ highline (1.6.20)
43
43
  httpauth (0.2.0)
44
44
  jeweler (1.8.8)
45
45
  builder
@@ -50,19 +50,18 @@ GEM
50
50
  nokogiri (= 1.5.10)
51
51
  rake
52
52
  rdoc
53
- json (1.8.0)
53
+ json (1.8.1)
54
54
  jwt (0.1.8)
55
55
  multi_json (>= 1.5)
56
- launchy (2.3.0)
56
+ launchy (2.4.2)
57
57
  addressable (~> 2.3)
58
58
  method_source (0.8.2)
59
- mime-types (1.25)
59
+ mime-types (1.25.1)
60
60
  multi_json (1.8.2)
61
61
  multi_xml (0.5.5)
62
62
  multipart-post (1.2.0)
63
63
  net-http-persistent (2.9)
64
64
  net-http-pipeline (1.0.1)
65
- netrc (0.7.7)
66
65
  nokogiri (1.5.10)
67
66
  oauth2 (0.9.2)
68
67
  faraday (~> 0.8)
@@ -71,15 +70,14 @@ GEM
71
70
  multi_json (~> 1.0)
72
71
  multi_xml (~> 0.5)
73
72
  rack (~> 1.2)
74
- pry (0.9.12.2)
75
- coderay (~> 1.0.5)
73
+ pry (0.9.12.4)
74
+ coderay (~> 1.0)
76
75
  method_source (~> 0.8)
77
76
  slop (~> 3.4)
78
- pusher-client (0.3.1)
79
- ruby-hmac (~> 0.4.0)
77
+ pusher-client (0.4.0)
80
78
  websocket (~> 1.0.0)
81
79
  rack (1.5.2)
82
- rake (10.1.0)
80
+ rake (10.1.1)
83
81
  rdoc (4.0.1)
84
82
  json (~> 1.4)
85
83
  redgreen (1.2.2)
@@ -87,31 +85,28 @@ GEM
87
85
  rspec-core (~> 2.14.0)
88
86
  rspec-expectations (~> 2.14.0)
89
87
  rspec-mocks (~> 2.14.0)
90
- rspec-core (2.14.5)
91
- rspec-expectations (2.14.3)
88
+ rspec-core (2.14.7)
89
+ rspec-expectations (2.14.4)
92
90
  diff-lcs (>= 1.1.3, < 2.0)
93
- rspec-mocks (2.14.3)
94
- ruby-hmac (0.4.0)
91
+ rspec-mocks (2.14.4)
95
92
  safe_yaml (0.9.7)
96
- slop (3.4.6)
93
+ slop (3.4.7)
97
94
  sys-uname (0.9.2)
98
95
  ffi (>= 1.0.0)
99
- terminal-notifier (1.5.1)
100
- travis (1.5.5)
96
+ travis (1.6.6)
97
+ addressable (~> 2.3)
101
98
  backports
102
99
  faraday (~> 0.8.7)
103
100
  faraday_middleware (~> 0.9)
104
101
  gh (~> 0.13)
105
102
  highline (~> 1.6)
106
103
  launchy (~> 2.1)
107
- netrc (~> 0.7)
108
104
  pry (~> 0.9)
109
- pusher-client (~> 0.3, >= 0.3.1)
110
- terminal-notifier (>= 1.4.2)
105
+ pusher-client (~> 0.4)
111
106
  typhoeus (~> 0.6)
112
- typhoeus (0.6.5)
113
- ethon (~> 0.6.1)
114
- webmock (1.13.0)
107
+ typhoeus (0.6.7)
108
+ ethon (~> 0.6.2)
109
+ webmock (1.16.1)
115
110
  addressable (>= 2.2.7)
116
111
  crack (>= 0.3.2)
117
112
  websocket (1.0.7)
@@ -123,10 +118,10 @@ DEPENDENCIES
123
118
  autotest
124
119
  autotest-fsevent
125
120
  autotest-growl
126
- bundler
127
- curb
121
+ curb (~> 0.8)
128
122
  jeweler
123
+ json (>= 1.5.1)
129
124
  redgreen
130
- rspec
125
+ rspec (>= 2.5.0)
131
126
  travis
132
127
  webmock
@@ -2,15 +2,15 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: algoliasearch 1.1.15 ruby lib
5
+ # stub: algoliasearch 1.1.16 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "algoliasearch"
9
- s.version = "1.1.15"
9
+ s.version = "1.1.16"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.authors = ["Algolia"]
13
- s.date = "2013-12-16"
13
+ s.date = "2013-12-20"
14
14
  s.description = "A simple Ruby client for the algolia.com REST API"
15
15
  s.email = "contact@algolia.com"
16
16
  s.extra_rdoc_files = [
@@ -51,19 +51,19 @@ Gem::Specification.new do |s|
51
51
  s.specification_version = 4
52
52
 
53
53
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
54
- s.add_runtime_dependency(%q<curb>, [">= 0"])
55
- s.add_development_dependency(%q<bundler>, [">= 0"])
54
+ s.add_runtime_dependency(%q<curb>, ["~> 0.8"])
55
+ s.add_runtime_dependency(%q<json>, [">= 1.5.1"])
56
56
  s.add_development_dependency(%q<jeweler>, [">= 0"])
57
57
  s.add_development_dependency(%q<travis>, [">= 0"])
58
58
  else
59
- s.add_dependency(%q<curb>, [">= 0"])
60
- s.add_dependency(%q<bundler>, [">= 0"])
59
+ s.add_dependency(%q<curb>, ["~> 0.8"])
60
+ s.add_dependency(%q<json>, [">= 1.5.1"])
61
61
  s.add_dependency(%q<jeweler>, [">= 0"])
62
62
  s.add_dependency(%q<travis>, [">= 0"])
63
63
  end
64
64
  else
65
- s.add_dependency(%q<curb>, [">= 0"])
66
- s.add_dependency(%q<bundler>, [">= 0"])
65
+ s.add_dependency(%q<curb>, ["~> 0.8"])
66
+ s.add_dependency(%q<json>, [">= 1.5.1"])
67
67
  s.add_dependency(%q<jeweler>, [">= 0"])
68
68
  s.add_dependency(%q<travis>, [">= 0"])
69
69
  end
data/lib/algolia/index.rb CHANGED
@@ -12,20 +12,20 @@ module Algolia
12
12
 
13
13
  # Delete an index
14
14
  #
15
- # return an object of the form array(:deletedAt => "2013-01-18T15:33:13.556Z")
15
+ # return an hash of the form { "deletedAt" => "2013-01-18T15:33:13.556Z" }
16
16
  def delete
17
17
  Algolia.client.delete(Protocol.index_uri(name))
18
18
  end
19
19
 
20
20
  # Add an object in this index
21
21
  #
22
- # @param content contains the object to add inside the index.
22
+ # @param obj the object to add to the index.
23
23
  # The object is represented by an associative array
24
24
  # @param objectID (optional) an objectID you want to attribute to this object
25
- # (if the attribute already exist the old object will be overwrite)
25
+ # (if the attribute already exist the old object will be overridden)
26
26
  def add_object(obj, objectID = nil)
27
- raise ArgumentError.new("argument must not be an array") if obj.is_a?(Array)
28
- if objectID == nil
27
+ check_object obj
28
+ if objectID.nil?
29
29
  Algolia.client.post(Protocol.index_uri(name), obj.to_json)
30
30
  else
31
31
  Algolia.client.put(Protocol.object_uri(name, objectID), obj.to_json)
@@ -34,10 +34,10 @@ module Algolia
34
34
 
35
35
  # Add an object in this index and wait end of indexing
36
36
  #
37
- # @param content contains the object to add inside the index.
37
+ # @param obj the object to add to the index.
38
38
  # The object is represented by an associative array
39
39
  # @param objectID (optional) an objectID you want to attribute to this object
40
- # (if the attribute already exist the old object will be overwrite)
40
+ # (if the attribute already exist the old object will be overridden)
41
41
  def add_object!(obj, objectID = nil)
42
42
  res = add_object(obj, objectID)
43
43
  wait_task(res["taskID"])
@@ -46,27 +46,23 @@ module Algolia
46
46
 
47
47
  # Add several objects in this index
48
48
  #
49
- # @param content contains the object to add inside the index.
50
- # The object is represented by an associative array
51
- # @param objectID (optional) an objectID you want to attribute to this object
52
- # (if the attribute already exist the old object will be overwrite)
49
+ # @param objs the array of objects to add inside the index.
50
+ # Each object is represented by an associative array
53
51
  def add_objects(objs)
54
- raise ArgumentError.new("argument must be an array of object") if !objs.is_a?(Array)
55
- requests = []
56
- objs.each do |obj|
57
- raise ArgumentError.new("argument must be an array of object") if obj.is_a?(Array)
58
- requests.push({"action" => "addObject", "body" => obj})
59
- end
60
- request = {"requests" => requests};
61
- Algolia.client.post(Protocol.batch_uri(name), request.to_json)
52
+ check_array objs
53
+ requests = []
54
+ objs.each do |obj|
55
+ check_object obj, true
56
+ requests.push({"action" => "addObject", "body" => obj})
57
+ end
58
+ request = {"requests" => requests};
59
+ Algolia.client.post(Protocol.batch_uri(name), request.to_json)
62
60
  end
63
61
 
64
62
  # Add several objects in this index and wait end of indexing
65
63
  #
66
- # @param content contains the object to add inside the index.
67
- # The object is represented by an associative array
68
- # @param objectID (optional) an objectID you want to attribute to this object
69
- # (if the attribute already exist the old object will be overwrite)
64
+ # @param objs the array of objects to add inside the index.
65
+ # Each object is represented by an associative array
70
66
  def add_objects!(obj)
71
67
  res = add_objects(obj)
72
68
  wait_task(res["taskID"])
@@ -152,7 +148,7 @@ module Algolia
152
148
  # @param attributesToRetrieve (optional) if set, contains the list of attributes to retrieve as a string separated by ","
153
149
  #
154
150
  def get_object(objectID, attributesToRetrieve = nil)
155
- if attributesToRetrieve == nil
151
+ if attributesToRetrieve.nil?
156
152
  Algolia.client.get(Protocol.object_uri(name, objectID, nil))
157
153
  else
158
154
  Algolia.client.get(Protocol.object_uri(name, objectID, {"attributes" => attributesToRetrieve}))
@@ -169,46 +165,55 @@ module Algolia
169
165
  loop do
170
166
  status = Algolia.client.get(Protocol.task_uri(name, taskID))["status"]
171
167
  if status == "published"
172
- return
168
+ return
173
169
  end
174
170
  sleep(timeBeforeRetry.to_f / 1000)
175
171
  end
176
172
  end
177
173
 
178
- # Override the content of object
174
+ # Override the content of an object
179
175
  #
180
- # @param object contains the object to save, the object must contains an objectID attribute
176
+ # @param obj the object to save
177
+ # @param objectID the associated objectID, if nil 'obj' must contain an 'objectID' key
181
178
  #
182
- def save_object(obj)
183
- Algolia.client.put(Protocol.object_uri(name, obj["objectID"]), obj.to_json)
179
+ def save_object(obj, objectID = nil)
180
+ check_object obj
181
+ objectID ||= obj[:objectID] || obj["objectID"]
182
+ raise ArgumentError.new("Missing 'objectID'") if objectID.nil?
183
+ Algolia.client.put(Protocol.object_uri(name, objectID), obj.to_json)
184
184
  end
185
185
 
186
186
  # Override the content of object and wait indexing
187
187
  #
188
- # @param object contains the object to save, the object must contains an objectID attribute
188
+ # @param obj the object to save
189
+ # @param objectID the associated objectID, if nil 'obj' must contain an 'objectID' key
189
190
  #
190
- def save_object!(obj)
191
- res = save_object(obj)
191
+ def save_object!(obj, objectID = nil)
192
+ res = save_object(obj, objectID)
192
193
  wait_task(res["taskID"])
193
194
  return res
194
195
  end
195
196
 
196
197
  # Override the content of several objects
197
198
  #
198
- # @param object contains the object to save, the object must contains an objectID attribute
199
+ # @param objs the array of objects to save, each object must contain an 'objectID' key
199
200
  #
200
201
  def save_objects(objs)
201
- requests = []
202
- objs.each do |obj|
203
- requests.push({"action" => "updateObject", "objectID" => obj["objectID"], "body" => obj})
204
- end
205
- request = {"requests" => requests};
206
- Algolia.client.post(Protocol.batch_uri(name), request.to_json)
202
+ check_array objs
203
+ requests = []
204
+ objs.each do |obj|
205
+ check_object obj, true
206
+ objectID = obj[:objectID] || obj["objectID"]
207
+ raise ArgumentError.new("Missing 'objectID'") if objectID.nil?
208
+ requests.push({"action" => "updateObject", "objectID" => objectID, "body" => obj})
209
+ end
210
+ request = {"requests" => requests};
211
+ Algolia.client.post(Protocol.batch_uri(name), request.to_json)
207
212
  end
208
213
 
209
214
  # Override the content of several objects and wait indexing
210
215
  #
211
- # @param object contains the object to save, the object must contains an objectID attribute
216
+ # @param objs the array of objects to save, each object must contain an objectID attribute
212
217
  #
213
218
  def save_objects!(objs)
214
219
  res = save_objects(objs)
@@ -219,46 +224,53 @@ module Algolia
219
224
  #
220
225
  # Update partially an object (only update attributes passed in argument)
221
226
  #
222
- # @param obj contains the object attributes to override, the
223
- # object must contains an objectID attribute
227
+ # @param obj the object attributes to override
228
+ # @param objectID the associated objectID, if nil 'obj' must contain an 'objectID' key
224
229
  #
225
- def partial_update_object(obj)
226
- Algolia.client.post(Protocol.partial_object_uri(name, obj["objectID"]), obj.to_json)
230
+ def partial_update_object(obj, objectID = nil)
231
+ check_object obj
232
+ objectID ||= obj[:objectID] || obj["objectID"]
233
+ raise ArgumentError.new("Missing 'objectID'") if objectID.nil?
234
+ Algolia.client.post(Protocol.partial_object_uri(name, objectID), obj.to_json)
227
235
  end
228
236
 
229
237
  #
230
238
  # Partially Override the content of several objects
231
239
  #
232
- # @param objs contains an array of objects to update (each object must contains a objectID attribute)
240
+ # @param objs an array of objects to update (each object must contains a objectID attribute)
233
241
  #
234
242
  def partial_update_objects(objs)
235
- requests = []
236
- objs.each do |obj|
237
- requests.push({"action" => "partialUpdateObject", "objectID" => obj["objectID"], "body" => obj})
238
- end
239
- request = {"requests" => requests};
240
- Algolia.client.post(Protocol.batch_uri(name), request.to_json)
243
+ check_array objs
244
+ requests = []
245
+ objs.each do |obj|
246
+ check_object obj, true
247
+ objectID = obj[:objectID] || obj["objectID"]
248
+ raise ArgumentError.new("Missing 'objectID'") if objectID.nil?
249
+ requests.push({"action" => "partialUpdateObject", "objectID" => objectID, "body" => obj})
250
+ end
251
+ request = {"requests" => requests};
252
+ Algolia.client.post(Protocol.batch_uri(name), request.to_json)
241
253
  end
242
254
 
243
255
  #
244
256
  # Partially Override the content of several objects
245
257
  #
246
- # @param objs contains an array of objects to update (each object must contains a objectID attribute)
258
+ # @param objs an array of objects to update (each object must contains a objectID attribute)
247
259
  #
248
260
  def partial_update_objects!(objs)
249
- res = partial_update_objects(obj)
250
- wait_task(res["taskID"])
251
- return res
261
+ res = partial_update_objects(obj)
262
+ wait_task(res["taskID"])
263
+ return res
252
264
  end
253
265
 
254
266
  #
255
267
  # Update partially an object (only update attributes passed in argument) and wait indexing
256
268
  #
257
- # @param obj contains the attributes to override, the
258
- # object must contains an objectID attribute
269
+ # @param obj the attributes to override
270
+ # @param objectID the associated objectID, if nil 'obj' must contain an 'objectID' key
259
271
  #
260
- def partial_update_object!(obj)
261
- res = partial_update_object(obj)
272
+ def partial_update_object!(obj, objectID = nil)
273
+ res = partial_update_object(obj, objectID)
262
274
  wait_task(res["taskID"])
263
275
  return res
264
276
  end
@@ -269,9 +281,6 @@ module Algolia
269
281
  # @param objectID the unique identifier of object to delete
270
282
  #
271
283
  def delete_object(objectID)
272
- if (objectID == nil || objectID.length == 0) then
273
- raise AlgoliaProtocolError.new(0, "objectID is required")
274
- end
275
284
  Algolia.client.delete(Protocol.object_uri(name, objectID))
276
285
  end
277
286
 
@@ -358,12 +367,12 @@ module Algolia
358
367
 
359
368
  # List all existing user keys with their associated ACLs
360
369
  def list_user_keys
361
- Algolia.client.get(Protocol.index_keys_uri(name))
370
+ Algolia.client.get(Protocol.index_keys_uri(name))
362
371
  end
363
372
 
364
373
  # Get ACL of a user key
365
374
  def get_user_key(key)
366
- Algolia.client.get(Protocol.index_key_uri(name, key))
375
+ Algolia.client.get(Protocol.index_key_uri(name, key))
367
376
  end
368
377
 
369
378
  #
@@ -381,12 +390,28 @@ module Algolia
381
390
  # @param validity the number of seconds after which the key will be automatically removed (0 means no time limit for this key)
382
391
  #
383
392
  def add_user_key(acls, validity = 0, maxQueriesPerIPPerHour = 0, maxHitsPerQuery = 0)
384
- Algolia.client.post(Protocol.index_keys_uri(name), {"acl" => acls, "validity" => validity, "maxQueriesPerIPPerHour" => maxQueriesPerIPPerHour.to_i, "maxHitsPerQuery" => maxHitsPerQuery.to_i}.to_json)
393
+ Algolia.client.post(Protocol.index_keys_uri(name), {"acl" => acls, "validity" => validity, "maxQueriesPerIPPerHour" => maxQueriesPerIPPerHour.to_i, "maxHitsPerQuery" => maxHitsPerQuery.to_i}.to_json)
385
394
  end
386
395
 
387
396
  # Delete an existing user key
388
397
  def delete_user_key(key)
389
- Algolia.client.delete(Protocol.index_key_uri(name, key))
398
+ Algolia.client.delete(Protocol.index_key_uri(name, key))
399
+ end
400
+
401
+ private
402
+ def check_array(objs)
403
+ raise ArgumentError.new("argument must be an array of objects") if !objs.is_a?(Array)
404
+ end
405
+
406
+ def check_object(obj, in_array = false)
407
+ case obj
408
+ when Array
409
+ raise ArgumentError.new(in_array ? "argument must be an array of objects" : "argument must not be an array")
410
+ when String, Integer, Float, TrueClass, FalseClass, NilClass
411
+ raise ArgumentError.new("argument must be an #{'array of' if in_array} object, got: #{obj.inspect}")
412
+ else
413
+ # ok
414
+ end
390
415
  end
391
416
 
392
417
  end
@@ -1,3 +1,3 @@
1
1
  module Algolia
2
- VERSION = "1.1.15"
2
+ VERSION = "1.1.16"
3
3
  end
data/spec/client_spec.rb CHANGED
@@ -31,6 +31,13 @@ describe 'Client' do
31
31
  it "should throw an exception if invalid argument" do
32
32
  expect { @index.add_object!([ {:name => "test"} ]) }.to raise_error(ArgumentError)
33
33
  expect { @index.add_objects!([ [ {:name => "test"} ] ]) }.to raise_error(ArgumentError)
34
+ expect { @index.save_object(1) }.to raise_error(ArgumentError)
35
+ expect { @index.save_object("test") }.to raise_error(ArgumentError)
36
+ expect { @index.save_object({ objectID: 42 }.to_json) }.to raise_error(ArgumentError)
37
+ expect { @index.save_objects([{}, ""]) }.to raise_error(ArgumentError)
38
+ expect { @index.save_objects([1]) }.to raise_error(ArgumentError)
39
+ expect { @index.save_objects!([1]) }.to raise_error(ArgumentError)
40
+ expect { @index.save_object({ foo: 42 }) }.to raise_error(ArgumentError) # missing objectID
34
41
  end
35
42
 
36
43
  it "should be thread safe" do
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: algoliasearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.15
4
+ version: 1.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Algolia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-16 00:00:00.000000000 Z
11
+ date: 2013-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: curb
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '0.8'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '0.8'
27
27
  - !ruby/object:Gem::Dependency
28
- name: bundler
28
+ name: json
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '>='
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
33
+ version: 1.5.1
34
+ type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '>='
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 1.5.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: jeweler
43
43
  requirement: !ruby/object:Gem::Requirement