algoliasearch 1.7.0 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +4 -0
- data/Gemfile +1 -4
- data/Gemfile.lock +5 -13
- data/README.md +1634 -254
- data/algoliasearch.gemspec +1 -1
- data/lib/algolia/index.rb +1 -0
- data/lib/algolia/version.rb +1 -1
- data/lib/algolia/webmock.rb +22 -22
- data/spec/client_spec.rb +17 -9
- metadata +5 -5
data/algoliasearch.gemspec
CHANGED
@@ -50,7 +50,7 @@ Gem::Specification.new do |s|
|
|
50
50
|
s.specification_version = 4
|
51
51
|
|
52
52
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
53
|
-
s.add_runtime_dependency(%q<httpclient>, ["~> 2.
|
53
|
+
s.add_runtime_dependency(%q<httpclient>, ["~> 2.7.1"])
|
54
54
|
s.add_runtime_dependency(%q<json>, [">= 1.5.1"])
|
55
55
|
s.add_development_dependency "travis"
|
56
56
|
s.add_development_dependency "rake"
|
data/lib/algolia/index.rb
CHANGED
@@ -336,6 +336,7 @@ module Algolia
|
|
336
336
|
# @param objectID the unique identifier of object to delete
|
337
337
|
#
|
338
338
|
def delete_object(objectID)
|
339
|
+
raise ArgumentError.new('objectID must not be blank') if objectID.nil? || objectID == ''
|
339
340
|
client.delete(Protocol.object_uri(name, objectID))
|
340
341
|
end
|
341
342
|
|
data/lib/algolia/version.rb
CHANGED
data/lib/algolia/webmock.rb
CHANGED
@@ -6,41 +6,41 @@ rescue LoadError
|
|
6
6
|
end
|
7
7
|
|
8
8
|
# list indexes
|
9
|
-
WebMock.stub_request(:get, /.*\.algolia
|
9
|
+
WebMock.stub_request(:get, /.*\.algolia(net\.com|\.net)\/1\/indexes/).to_return(:body => '{ "items": [] }')
|
10
10
|
# query index
|
11
|
-
WebMock.stub_request(:get, /.*\.algolia
|
11
|
+
WebMock.stub_request(:get, /.*\.algolia(net\.com|\.net)\/1\/indexes\/[^\/]+/).to_return(:body => '{ "hits": [ { "objectID": 42 } ], "page": 1, "hitsPerPage": 1 }')
|
12
12
|
# delete index
|
13
|
-
WebMock.stub_request(:delete, /.*\.algolia
|
13
|
+
WebMock.stub_request(:delete, /.*\.algolia(net\.com|\.net)\/1\/indexes\/[^\/]+/).to_return(:body => '{ "taskID": 42 }')
|
14
14
|
# clear index
|
15
|
-
WebMock.stub_request(:post, /.*\.algolia
|
15
|
+
WebMock.stub_request(:post, /.*\.algolia(net\.com|\.net)\/1\/indexes\/[^\/]+\/clear/).to_return(:body => '{ "taskID": 42 }')
|
16
16
|
# add object
|
17
|
-
WebMock.stub_request(:post, /.*\.algolia
|
17
|
+
WebMock.stub_request(:post, /.*\.algolia(net\.com|\.net)\/1\/indexes\/[^\/]+/).to_return(:body => '{ "taskID": 42 }')
|
18
18
|
# save object
|
19
|
-
WebMock.stub_request(:put, /.*\.algolia
|
19
|
+
WebMock.stub_request(:put, /.*\.algolia(net\.com|\.net)\/1\/indexes\/[^\/]+\/[^\/]+/).to_return(:body => '{ "taskID": 42 }')
|
20
20
|
# partial update
|
21
|
-
WebMock.stub_request(:put, /.*\.algolia
|
21
|
+
WebMock.stub_request(:put, /.*\.algolia(net\.com|\.net)\/1\/indexes\/[^\/]+\/[^\/]+\/partial/).to_return(:body => '{ "taskID": 42 }')
|
22
22
|
# get object
|
23
|
-
WebMock.stub_request(:get, /.*\.algolia
|
23
|
+
WebMock.stub_request(:get, /.*\.algolia(net\.com|\.net)\/1\/indexes\/[^\/]+\/[^\/]+/).to_return(:body => '{}')
|
24
24
|
# delete object
|
25
|
-
WebMock.stub_request(:delete, /.*\.algolia
|
25
|
+
WebMock.stub_request(:delete, /.*\.algolia(net\.com|\.net)\/1\/indexes\/[^\/]+\/[^\/]+/).to_return(:body => '{ "taskID": 42 }')
|
26
26
|
# batch
|
27
|
-
WebMock.stub_request(:post, /.*\.algolia
|
27
|
+
WebMock.stub_request(:post, /.*\.algolia(net\.com|\.net)\/1\/indexes\/[^\/]+\/batch/).to_return(:body => '{ "taskID": 42 }')
|
28
28
|
# settings
|
29
|
-
WebMock.stub_request(:get, /.*\.algolia
|
30
|
-
WebMock.stub_request(:put, /.*\.algolia
|
29
|
+
WebMock.stub_request(:get, /.*\.algolia(net\.com|\.net)\/1\/indexes\/[^\/]+\/settings/).to_return(:body => '{}')
|
30
|
+
WebMock.stub_request(:put, /.*\.algolia(net\.com|\.net)\/1\/indexes\/[^\/]+\/settings/).to_return(:body => '{ "taskID": 42 }')
|
31
31
|
# browse
|
32
|
-
WebMock.stub_request(:get, /.*\.algolia
|
32
|
+
WebMock.stub_request(:get, /.*\.algolia(net\.com|\.net)\/1\/indexes\/[^\/]+\/browse/).to_return(:body => '{}')
|
33
33
|
# operations
|
34
|
-
WebMock.stub_request(:post, /.*\.algolia
|
34
|
+
WebMock.stub_request(:post, /.*\.algolia(net\.com|\.net)\/1\/indexes\/[^\/]+\/operation/).to_return(:body => '{ "taskID": 42 }')
|
35
35
|
# tasks
|
36
|
-
WebMock.stub_request(:get, /.*\.algolia
|
36
|
+
WebMock.stub_request(:get, /.*\.algolia(net\.com|\.net)\/1\/indexes\/[^\/]+\/task\/[^\/]+/).to_return(:body => '{ "status": "published" }')
|
37
37
|
# index keys
|
38
|
-
WebMock.stub_request(:post, /.*\.algolia
|
39
|
-
WebMock.stub_request(:get, /.*\.algolia
|
38
|
+
WebMock.stub_request(:post, /.*\.algolia(net\.com|\.net)\/1\/indexes\/[^\/]+\/keys/).to_return(:body => '{ }')
|
39
|
+
WebMock.stub_request(:get, /.*\.algolia(net\.com|\.net)\/1\/indexes\/[^\/]+\/keys/).to_return(:body => '{ "keys": [] }')
|
40
40
|
# global keys
|
41
|
-
WebMock.stub_request(:post, /.*\.algolia
|
42
|
-
WebMock.stub_request(:get, /.*\.algolia
|
43
|
-
WebMock.stub_request(:get, /.*\.algolia
|
44
|
-
WebMock.stub_request(:delete, /.*\.algolia
|
41
|
+
WebMock.stub_request(:post, /.*\.algolia(net\.com|\.net)\/1\/keys/).to_return(:body => '{ }')
|
42
|
+
WebMock.stub_request(:get, /.*\.algolia(net\.com|\.net)\/1\/keys/).to_return(:body => '{ "keys": [] }')
|
43
|
+
WebMock.stub_request(:get, /.*\.algolia(net\.com|\.net)\/1\/keys\/[^\/]+/).to_return(:body => '{ }')
|
44
|
+
WebMock.stub_request(:delete, /.*\.algolia(net\.com|\.net)\/1\/keys\/[^\/]+/).to_return(:body => '{ }')
|
45
45
|
# query POST
|
46
|
-
WebMock.stub_request(:post, /.*\.algolia
|
46
|
+
WebMock.stub_request(:post, /.*\.algolia(net\.com|\.net)\/1\/indexes\/[^\/]+\/query/).to_return(:body => '{ "hits": [ { "objectID": 42 } ], "page": 1, "hitsPerPage": 1 }')
|
data/spec/client_spec.rb
CHANGED
@@ -196,6 +196,16 @@ describe 'Client' do
|
|
196
196
|
@index.search('')['nbHits'].should eq(0)
|
197
197
|
end
|
198
198
|
|
199
|
+
it "should not delete the index because the objectID is blank" do
|
200
|
+
@index.clear
|
201
|
+
@index.add_object!({:firstname => "Robert"})
|
202
|
+
res = @index.search('')
|
203
|
+
@index.search('')['nbHits'].should eq(1)
|
204
|
+
expect { @index.delete_object('') }.to raise_error(ArgumentError)
|
205
|
+
expect { @index.delete_object!(nil) }.to raise_error(ArgumentError)
|
206
|
+
@index.search('')['nbHits'].should eq(1)
|
207
|
+
end
|
208
|
+
|
199
209
|
it "should delete several objects" do
|
200
210
|
@index.clear
|
201
211
|
@index.add_object!({:firstname => "Robert1"})
|
@@ -367,18 +377,18 @@ describe 'Client' do
|
|
367
377
|
resIndex = @index.list_user_keys
|
368
378
|
newIndexKey = @index.add_user_key(['search'])
|
369
379
|
newIndexKey['key'].should_not eq("")
|
370
|
-
sleep
|
380
|
+
sleep 5 # no task ID here
|
371
381
|
resIndexAfter = @index.list_user_keys
|
372
382
|
is_include(resIndex['keys'], 'value', newIndexKey['key']).should eq(false)
|
373
383
|
is_include(resIndexAfter['keys'], 'value', newIndexKey['key']).should eq(true)
|
374
384
|
indexKey = @index.get_user_key(newIndexKey['key'])
|
375
385
|
indexKey['acl'][0].should eq('search')
|
376
386
|
@index.update_user_key(newIndexKey['key'], ['addObject'])
|
377
|
-
sleep
|
387
|
+
sleep 5 # no task ID here
|
378
388
|
indexKey = @index.get_user_key(newIndexKey['key'])
|
379
389
|
indexKey['acl'][0].should eq('addObject')
|
380
390
|
@index.delete_user_key(newIndexKey['key'])
|
381
|
-
sleep
|
391
|
+
sleep 5 # no task ID here
|
382
392
|
resIndexEnd = @index.list_user_keys
|
383
393
|
is_include(resIndexEnd['keys'], 'value', newIndexKey['key']).should eq(false)
|
384
394
|
|
@@ -386,22 +396,20 @@ describe 'Client' do
|
|
386
396
|
res = Algolia.list_user_keys
|
387
397
|
newKey = Algolia.add_user_key(['search'])
|
388
398
|
newKey['key'].should_not eq("")
|
389
|
-
sleep
|
399
|
+
sleep 5 # no task ID here
|
390
400
|
resAfter = Algolia.list_user_keys
|
391
401
|
is_include(res['keys'], 'value', newKey['key']).should eq(false)
|
392
402
|
is_include(resAfter['keys'], 'value', newKey['key']).should eq(true)
|
393
403
|
key = Algolia.get_user_key(newKey['key'])
|
394
404
|
key['acl'][0].should eq('search')
|
395
405
|
Algolia.update_user_key(newKey['key'], ['addObject'])
|
396
|
-
sleep
|
406
|
+
sleep 5 # no task ID here
|
397
407
|
key = Algolia.get_user_key(newKey['key'])
|
398
408
|
key['acl'][0].should eq('addObject')
|
399
409
|
Algolia.delete_user_key(newKey['key'])
|
400
|
-
sleep
|
410
|
+
sleep 5 # no task ID here
|
401
411
|
resEnd = Algolia.list_user_keys
|
402
412
|
is_include(resEnd['keys'], 'value', newKey['key']).should eq(false)
|
403
|
-
|
404
|
-
|
405
413
|
end
|
406
414
|
|
407
415
|
it "should check functions" do
|
@@ -606,7 +614,7 @@ describe 'Client' do
|
|
606
614
|
newIndexKey['key'].should be_a(String)
|
607
615
|
newIndexKey.should have_key('createdAt')
|
608
616
|
newIndexKey['createdAt'].should be_a(String)
|
609
|
-
sleep
|
617
|
+
sleep 5 # no task ID here
|
610
618
|
resIndex = @index.list_user_keys
|
611
619
|
resIndex.should have_key('keys')
|
612
620
|
resIndex['keys'].should be_a(Array)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: algoliasearch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Algolia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.7.1
|
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:
|
26
|
+
version: 2.7.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: json
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -131,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
131
|
version: '0'
|
132
132
|
requirements: []
|
133
133
|
rubyforge_project:
|
134
|
-
rubygems_version: 2.
|
134
|
+
rubygems_version: 2.5.1
|
135
135
|
signing_key:
|
136
136
|
specification_version: 4
|
137
137
|
summary: A simple Ruby client for the algolia.com REST API
|