algoliasearch 1.26.1 → 1.27.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -1
- data/CHANGELOG.md +47 -0
- data/Gemfile.lock +42 -54
- data/README.md +7 -2
- data/algoliasearch.gemspec +7 -3
- data/lib/algolia/account_client.rb +1 -1
- data/lib/algolia/client.rb +23 -1
- data/lib/algolia/error.rb +9 -1
- data/lib/algolia/index.rb +92 -0
- data/lib/algolia/version.rb +1 -1
- data/resources/ca-bundle.crt +37 -24
- data/spec/account_client_spec.rb +3 -6
- data/spec/client_spec.rb +91 -1
- metadata +15 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d05a0e17139977680099b2b1e1ee1e0901834ad0aeb20f8061a54d9f74def4d9
|
4
|
+
data.tar.gz: ad1178bb101f66b3dafb95d2e17f40abd6efa1593482b9d7ddd8965d73afbcf9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfc4fce2c92ca1aa22a814ca43051070600be031227dda2667348eea5ae6e0392c73534b35daf6b1966e6fdb6b380a1bc60d21a4669b3da6d6e6493901ebe330
|
7
|
+
data.tar.gz: acb939243bb56bb478ee96fd842b201631d39847296a51cf39e610420b2f5abd7d523bd1141b90eef0fa2dc0f2196f7936eca5417389b0a435299b1b98043cb4
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,52 @@
|
|
1
1
|
# ChangeLog
|
2
2
|
|
3
|
+
## Unreleased
|
4
|
+
|
5
|
+
## [1.27.4](https://github.com/algolia/algoliasearch-client-ruby/compare/1.27.3...1.27.4) (2020-09-16)
|
6
|
+
|
7
|
+
**Fixed**
|
8
|
+
|
9
|
+
* Retrieve all objects when using `copy_index` from `AccountClient` class ([399](https://github.com/algolia/algoliasearch-client-ruby/pull/399))
|
10
|
+
|
11
|
+
## [1.27.3](https://github.com/algolia/algoliasearch-client-ruby/compare/1.27.2...1.27.3) (2020-06-03)
|
12
|
+
|
13
|
+
**Fixed**
|
14
|
+
|
15
|
+
* Replace expired certificate within embedded certificate chain ([9087dd1](https://github.com/algolia/algoliasearch-client-ruby/commit/9087dd14a97bf77c9391a3360c4803edf686086d))
|
16
|
+
|
17
|
+
## [1.27.2](https://github.com/algolia/algoliasearch-client-ruby/compare/1.27.1...1.27.2) (2020-04-28)
|
18
|
+
|
19
|
+
**Fixed**
|
20
|
+
|
21
|
+
* In `search_user_id`, retrieve param `cluster` instead of `clusterName`. [368](https://github.com/algolia/algoliasearch-client-ruby/issues/368)
|
22
|
+
|
23
|
+
## [1.27.1](https://github.com/algolia/algoliasearch-client-ruby/compare/1.27.0...1.27.1) (2019-09-26)
|
24
|
+
|
25
|
+
**Fixed**
|
26
|
+
|
27
|
+
* Update `Algolia::Index.exists` method to `Algolia::Index.exists?`. [364](https://github.com/algolia/algoliasearch-client-ruby/issues/364)
|
28
|
+
|
29
|
+
## [1.27.0](https://github.com/algolia/algoliasearch-client-ruby/releases/tag/1.27.0) (2019-09-16)
|
30
|
+
|
31
|
+
**Added**
|
32
|
+
|
33
|
+
* Introduce `Algolia::Index.exists` method. [358](https://github.com/algolia/algoliasearch-client-ruby/issues/358)
|
34
|
+
|
35
|
+
Check whether an index exists or not.
|
36
|
+
|
37
|
+
* Introduce `Algolia::Index.find_object` method. [359](https://github.com/algolia/algoliasearch-client-ruby/issues/359)
|
38
|
+
|
39
|
+
Find object by the given condition.
|
40
|
+
|
41
|
+
* Introduce `Algolia::Index.get_object_position` method. [359](https://github.com/algolia/algoliasearch-client-ruby/issues/359)
|
42
|
+
|
43
|
+
Retrieve the given object position in a set of results.
|
44
|
+
|
45
|
+
* Introduce `Algolia.get_secured_api_key_remaining_validity` method. [361](https://github.com/algolia/algoliasearch-client-ruby/issues/361)
|
46
|
+
|
47
|
+
Returns the remaining validity time for the given API key in seconds.
|
48
|
+
|
49
|
+
|
3
50
|
## [1.26.1](https://github.com/algolia/algoliasearch-client-ruby/compare/1.26.0...1.26.1) (2019-07-31)
|
4
51
|
|
5
52
|
### Chore
|
data/Gemfile.lock
CHANGED
@@ -1,73 +1,66 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
algoliasearch (1.
|
4
|
+
algoliasearch (1.27.3)
|
5
5
|
httpclient (~> 2.8, >= 2.8.3)
|
6
6
|
json (>= 1.5.1)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
addressable (2.
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
rest-client (= 1.6.7)
|
16
|
-
simplecov (>= 0.7)
|
17
|
-
term-ansicolor (= 1.2.2)
|
18
|
-
thor (= 0.18.1)
|
11
|
+
addressable (2.7.0)
|
12
|
+
public_suffix (>= 2.0.2, < 5.0)
|
13
|
+
backports (3.18.2)
|
14
|
+
connection_pool (2.2.3)
|
19
15
|
crack (0.4.3)
|
20
16
|
safe_yaml (~> 1.0.0)
|
21
|
-
diff-lcs (1.
|
17
|
+
diff-lcs (1.4.4)
|
22
18
|
docile (1.3.2)
|
23
19
|
ethon (0.12.0)
|
24
20
|
ffi (>= 1.3.0)
|
25
|
-
faraday (0.
|
21
|
+
faraday (0.17.3)
|
26
22
|
multipart-post (>= 1.2, < 3)
|
27
|
-
faraday_middleware (0.
|
23
|
+
faraday_middleware (0.14.0)
|
28
24
|
faraday (>= 0.7.4, < 1.0)
|
29
|
-
ffi (1.
|
25
|
+
ffi (1.13.1)
|
30
26
|
ffi2-generators (0.1.1)
|
31
|
-
gh (0.
|
32
|
-
addressable
|
27
|
+
gh (0.14.0)
|
28
|
+
addressable
|
33
29
|
backports
|
34
30
|
faraday (~> 0.8)
|
35
31
|
multi_json (~> 1.0)
|
36
|
-
net-http-persistent (
|
32
|
+
net-http-persistent (>= 2.7)
|
37
33
|
net-http-pipeline
|
38
|
-
hashdiff (1.0.
|
34
|
+
hashdiff (1.0.1)
|
39
35
|
highline (1.7.10)
|
40
36
|
httpclient (2.8.3)
|
41
|
-
json (2.
|
42
|
-
launchy (2.
|
43
|
-
addressable (~> 2.
|
44
|
-
|
45
|
-
mime-types-data (~> 3.2015)
|
46
|
-
mime-types-data (3.2019.0331)
|
47
|
-
multi_json (1.13.1)
|
37
|
+
json (2.3.1)
|
38
|
+
launchy (2.5.0)
|
39
|
+
addressable (~> 2.7)
|
40
|
+
multi_json (1.15.0)
|
48
41
|
multipart-post (2.1.1)
|
49
|
-
net-http-persistent (
|
42
|
+
net-http-persistent (4.0.0)
|
43
|
+
connection_pool (~> 2.2)
|
50
44
|
net-http-pipeline (1.0.1)
|
45
|
+
public_suffix (4.0.6)
|
51
46
|
pusher-client (0.6.2)
|
52
47
|
json
|
53
48
|
websocket (~> 1.0)
|
54
|
-
rake (
|
55
|
-
rdoc (6.
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
rspec-
|
60
|
-
|
61
|
-
rspec-
|
62
|
-
rspec-
|
63
|
-
rspec-support (~> 3.8.0)
|
64
|
-
rspec-expectations (3.8.4)
|
49
|
+
rake (13.0.1)
|
50
|
+
rdoc (6.2.1)
|
51
|
+
rspec (3.9.0)
|
52
|
+
rspec-core (~> 3.9.0)
|
53
|
+
rspec-expectations (~> 3.9.0)
|
54
|
+
rspec-mocks (~> 3.9.0)
|
55
|
+
rspec-core (3.9.2)
|
56
|
+
rspec-support (~> 3.9.3)
|
57
|
+
rspec-expectations (3.9.2)
|
65
58
|
diff-lcs (>= 1.2.0, < 2.0)
|
66
|
-
rspec-support (~> 3.
|
67
|
-
rspec-mocks (3.
|
59
|
+
rspec-support (~> 3.9.0)
|
60
|
+
rspec-mocks (3.9.1)
|
68
61
|
diff-lcs (>= 1.2.0, < 2.0)
|
69
|
-
rspec-support (~> 3.
|
70
|
-
rspec-support (3.
|
62
|
+
rspec-support (~> 3.9.0)
|
63
|
+
rspec-support (3.9.3)
|
71
64
|
rubysl (2.2.0)
|
72
65
|
rubysl-abbrev (~> 2.0)
|
73
66
|
rubysl-base64 (~> 2.0)
|
@@ -175,7 +168,7 @@ GEM
|
|
175
168
|
rubysl-curses (2.0.1)
|
176
169
|
rubysl-date (2.0.9)
|
177
170
|
rubysl-delegate (2.0.1)
|
178
|
-
rubysl-digest (2.
|
171
|
+
rubysl-digest (2.1)
|
179
172
|
rubysl-drb (2.0.1)
|
180
173
|
rubysl-e2mmap (2.0.0)
|
181
174
|
rubysl-english (2.0.0)
|
@@ -225,7 +218,7 @@ GEM
|
|
225
218
|
rubysl-observer (2.0.0)
|
226
219
|
rubysl-open-uri (2.0.0)
|
227
220
|
rubysl-open3 (2.0.0)
|
228
|
-
rubysl-openssl (2.
|
221
|
+
rubysl-openssl (2.13)
|
229
222
|
rubysl-optparse (2.0.1)
|
230
223
|
rubysl-shellwords (~> 2.0)
|
231
224
|
rubysl-ostruct (2.1.0)
|
@@ -271,16 +264,11 @@ GEM
|
|
271
264
|
rubysl-yaml (2.1.0)
|
272
265
|
rubysl-zlib (2.0.1)
|
273
266
|
safe_yaml (1.0.5)
|
274
|
-
simplecov (0.
|
267
|
+
simplecov (0.19.0)
|
275
268
|
docile (~> 1.1)
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
term-ansicolor (1.2.2)
|
280
|
-
tins (~> 0.8)
|
281
|
-
thor (0.18.1)
|
282
|
-
tins (0.13.2)
|
283
|
-
travis (1.8.10)
|
269
|
+
simplecov-html (~> 0.11)
|
270
|
+
simplecov-html (0.12.2)
|
271
|
+
travis (1.8.13)
|
284
272
|
backports
|
285
273
|
faraday (~> 0.9)
|
286
274
|
faraday_middleware (~> 0.9, >= 0.9.1)
|
@@ -291,7 +279,7 @@ GEM
|
|
291
279
|
typhoeus (~> 0.6, >= 0.6.8)
|
292
280
|
typhoeus (0.8.0)
|
293
281
|
ethon (>= 0.8.0)
|
294
|
-
webmock (3.
|
282
|
+
webmock (3.8.3)
|
295
283
|
addressable (>= 2.3.6)
|
296
284
|
crack (>= 0.3.2)
|
297
285
|
hashdiff (>= 0.4.0, < 2.0.0)
|
@@ -302,7 +290,7 @@ PLATFORMS
|
|
302
290
|
|
303
291
|
DEPENDENCIES
|
304
292
|
algoliasearch!
|
305
|
-
|
293
|
+
gh (<= 0.14.0)
|
306
294
|
rake
|
307
295
|
rdoc
|
308
296
|
rspec (>= 2.5.0)
|
@@ -312,4 +300,4 @@ DEPENDENCIES
|
|
312
300
|
webmock
|
313
301
|
|
314
302
|
BUNDLED WITH
|
315
|
-
|
303
|
+
1.17.2
|
data/README.md
CHANGED
@@ -7,8 +7,8 @@
|
|
7
7
|
|
8
8
|
<p align="center">
|
9
9
|
<a href="https://travis-ci.org/algolia/algoliasearch-client-ruby"><img src="https://img.shields.io/travis/algolia/algoliasearch-client-ruby/master.svg" alt="Build Status"></a>
|
10
|
-
<a href="https://rubygems.org/gems/algoliasearch
|
11
|
-
<a href="https://rubygems.org/gems/algoliasearch
|
10
|
+
<a href="https://rubygems.org/gems/algoliasearch"><img src="https://badge.fury.io/rb/algoliasearch.svg" alt="Gem Version"></a>
|
11
|
+
<a href="https://rubygems.org/gems/algoliasearch"><img src="https://img.shields.io/badge/licence-MIT-blue.svg" alt="License"></a>
|
12
12
|
</p>
|
13
13
|
</p>
|
14
14
|
|
@@ -18,6 +18,7 @@
|
|
18
18
|
<a href="https://discourse.algolia.com" target="_blank">Community Forum</a> •
|
19
19
|
<a href="http://stackoverflow.com/questions/tagged/algolia" target="_blank">Stack Overflow</a> •
|
20
20
|
<a href="https://github.com/algolia/algoliasearch-client-ruby/issues" target="_blank">Report a bug</a> •
|
21
|
+
<a href="https://www.algolia.com/doc/api-client/troubleshooting/faq/ruby/" target="_blank">FAQ</a> •
|
21
22
|
<a href="https://www.algolia.com/support" target="_blank">Support</a>
|
22
23
|
</p>
|
23
24
|
|
@@ -51,6 +52,10 @@ objects = index.search('Fo')
|
|
51
52
|
|
52
53
|
For full documentation, visit the **[Algolia Ruby API Client](https://www.algolia.com/doc/api-client/getting-started/install/ruby/)**.
|
53
54
|
|
55
|
+
## ❓ Troubleshooting
|
56
|
+
|
57
|
+
Encountering an issue? Before reaching out to support, we recommend heading to our [FAQ](https://www.algolia.com/doc/api-client/troubleshooting/faq/ruby/) where you will find answers for the most common issues and gotchas with the client.
|
58
|
+
|
54
59
|
## 📄 License
|
55
60
|
|
56
61
|
Algolia Ruby API Client is an open-sourced software licensed under the [MIT license](LICENSE.md).
|
data/algoliasearch.gemspec
CHANGED
@@ -64,17 +64,21 @@ Gem::Specification.new do |s|
|
|
64
64
|
s.specification_version = 4
|
65
65
|
|
66
66
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
67
|
+
if defined?(RUBY_VERSION) && RUBY_VERSION < '2.0'
|
68
|
+
s.add_runtime_dependency 'json', '>= 1.5.1', '< 2.3'
|
69
|
+
else
|
70
|
+
s.add_runtime_dependency 'json', '>= 1.5.1'
|
71
|
+
end
|
67
72
|
s.add_runtime_dependency 'httpclient', '~> 2.8', '>= 2.8.3'
|
68
|
-
s.add_runtime_dependency 'json', '>= 1.5.1'
|
69
73
|
s.add_development_dependency 'travis', '~> 0'
|
70
74
|
s.add_development_dependency 'rake', '~> 0'
|
71
75
|
s.add_development_dependency 'rdoc', '~> 0'
|
72
76
|
else
|
73
77
|
s.add_dependency 'httpclient', '~> 2.8', '>= 2.8.3'
|
74
|
-
s.add_dependency 'json', '>= 1.5.1'
|
78
|
+
s.add_dependency 'json', '>= 1.5.1', '< 2.3'
|
75
79
|
end
|
76
80
|
else
|
77
81
|
s.add_dependency 'httpclient', '~> 2.8', '>= 2.8.3'
|
78
|
-
s.add_dependency 'json', '>= 1.5.1'
|
82
|
+
s.add_dependency 'json', '>= 1.5.1', '< 2.3'
|
79
83
|
end
|
80
84
|
end
|
data/lib/algolia/client.rb
CHANGED
@@ -552,7 +552,7 @@ module Algolia
|
|
552
552
|
|
553
553
|
def search_user_id(query, cluster_name = nil, page = nil, hits_per_page = nil, request_options = {})
|
554
554
|
body = { :query => query }
|
555
|
-
body[:
|
555
|
+
body[:cluster] = cluster_name unless cluster_name.nil?
|
556
556
|
body[:page] = page unless page.nil?
|
557
557
|
body[:hitsPerPage] = hits_per_page unless hits_per_page.nil?
|
558
558
|
post(Protocol.search_user_id_uri, body.to_json, :read, request_options)
|
@@ -774,6 +774,28 @@ module Algolia
|
|
774
774
|
end
|
775
775
|
end
|
776
776
|
|
777
|
+
#
|
778
|
+
# Returns the remaining validity time for the given API key in seconds
|
779
|
+
#
|
780
|
+
# @param [String] secured_api_key the secured API key to check
|
781
|
+
#
|
782
|
+
# @return [Integer] remaining validity in seconds
|
783
|
+
#
|
784
|
+
def Algolia.get_secured_api_key_remaining_validity(secured_api_key)
|
785
|
+
now = Time.now.to_i
|
786
|
+
decoded_key = Base64.decode64(secured_api_key)
|
787
|
+
regex = 'validUntil=(\d+)'
|
788
|
+
matches = decoded_key.match(regex)
|
789
|
+
|
790
|
+
if matches === nil
|
791
|
+
raise ValidUntilNotFoundError.new('The SecuredAPIKey doesn\'t have a validUntil parameter.')
|
792
|
+
end
|
793
|
+
|
794
|
+
valid_until = matches[1].to_i
|
795
|
+
|
796
|
+
valid_until - now
|
797
|
+
end
|
798
|
+
|
777
799
|
#
|
778
800
|
# This method allows to query multiple indexes with one API call
|
779
801
|
#
|
data/lib/algolia/error.rb
CHANGED
@@ -20,4 +20,12 @@ module Algolia
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
|
23
|
+
# An exception class raised when the given object was not found.
|
24
|
+
class AlgoliaObjectNotFoundError < AlgoliaError
|
25
|
+
end
|
26
|
+
|
27
|
+
# An exception class raised when the validUntil parameter is not found
|
28
|
+
class ValidUntilNotFoundError < AlgoliaError
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
data/lib/algolia/index.rb
CHANGED
@@ -264,6 +264,75 @@ module Algolia
|
|
264
264
|
client.post(Protocol.objects_uri, { :requests => requests }.to_json, :read, request_options)['results']
|
265
265
|
end
|
266
266
|
|
267
|
+
#
|
268
|
+
# Find object by the given condition.
|
269
|
+
#
|
270
|
+
# Options can be passed in request_options body:
|
271
|
+
# - query (string): pass a query
|
272
|
+
# - paginate (bool): choose if you want to iterate through all the
|
273
|
+
# documents (true) or only the first page (false). Default is true.
|
274
|
+
# The function takes a block to filter the results from search query
|
275
|
+
# Usage example:
|
276
|
+
# index.find_object({'query' => '', 'paginate' => true}) {|obj| obj.key?('company') and obj['company'] == 'Apple'}
|
277
|
+
#
|
278
|
+
# @param request_options contains extra parameters to send with your query
|
279
|
+
#
|
280
|
+
# @return [Hash] the matching object and its position in the result set
|
281
|
+
#
|
282
|
+
def find_object(request_options = {})
|
283
|
+
paginate = true
|
284
|
+
page = 0
|
285
|
+
|
286
|
+
query = request_options[:query] || request_options['query'] || ''
|
287
|
+
request_options.delete(:query)
|
288
|
+
request_options.delete('query')
|
289
|
+
|
290
|
+
if request_options.has_key? :paginate
|
291
|
+
paginate = request_options[:paginate]
|
292
|
+
end
|
293
|
+
|
294
|
+
if request_options.has_key? 'paginate'
|
295
|
+
paginate = request_options['paginate']
|
296
|
+
end
|
297
|
+
|
298
|
+
request_options.delete(:paginate)
|
299
|
+
request_options.delete('paginate')
|
300
|
+
|
301
|
+
while true
|
302
|
+
request_options['page'] = page
|
303
|
+
res = search(query, request_options)
|
304
|
+
|
305
|
+
res['hits'].each_with_index do |hit, i|
|
306
|
+
if yield(hit)
|
307
|
+
return {
|
308
|
+
'object' => hit,
|
309
|
+
'position' => i,
|
310
|
+
'page' => page,
|
311
|
+
}
|
312
|
+
end
|
313
|
+
end if block_given?
|
314
|
+
|
315
|
+
has_next_page = page + 1 < res['nbPages']
|
316
|
+
if !paginate || !has_next_page
|
317
|
+
raise AlgoliaObjectNotFoundError.new('Object not found')
|
318
|
+
end
|
319
|
+
|
320
|
+
page += 1
|
321
|
+
end
|
322
|
+
end
|
323
|
+
|
324
|
+
#
|
325
|
+
# Retrieve the given object position in a set of results.
|
326
|
+
#
|
327
|
+
# @param [Array] objects the result set to browse
|
328
|
+
# @param [String] object_id the object to look for
|
329
|
+
#
|
330
|
+
# @return [Integer] position of the object, or -1 if it's not in the array
|
331
|
+
#
|
332
|
+
def self.get_object_position(objects, object_id)
|
333
|
+
objects['hits'].find_index { |hit| hit['objectID'] == object_id } || -1
|
334
|
+
end
|
335
|
+
|
267
336
|
#
|
268
337
|
# Check the status of a task on the server.
|
269
338
|
# All server task are asynchronous and you can check the status of a task with this method.
|
@@ -1208,6 +1277,29 @@ module Algolia
|
|
1208
1277
|
res
|
1209
1278
|
end
|
1210
1279
|
|
1280
|
+
#
|
1281
|
+
# Check whether an index exists or not
|
1282
|
+
#
|
1283
|
+
# @return [Boolean]
|
1284
|
+
#
|
1285
|
+
def exists
|
1286
|
+
begin
|
1287
|
+
get_settings
|
1288
|
+
rescue AlgoliaProtocolError => e
|
1289
|
+
if e.code === 404
|
1290
|
+
return false
|
1291
|
+
end
|
1292
|
+
|
1293
|
+
raise e
|
1294
|
+
end
|
1295
|
+
return true
|
1296
|
+
end
|
1297
|
+
|
1298
|
+
#
|
1299
|
+
# Aliases the exists method
|
1300
|
+
#
|
1301
|
+
alias :exists? :exists
|
1302
|
+
|
1211
1303
|
# Deprecated
|
1212
1304
|
alias_method :get_user_key, :get_api_key
|
1213
1305
|
alias_method :list_user_keys, :list_api_keys
|
data/lib/algolia/version.rb
CHANGED
data/resources/ca-bundle.crt
CHANGED
@@ -16,6 +16,43 @@
|
|
16
16
|
|
17
17
|
# @(#) $RCSfile: certdata.txt,v $ $Revision: 1.87 $ $Date: 2012/12/29 16:32:45 $
|
18
18
|
|
19
|
+
USERTrust RSA root CA
|
20
|
+
=====================
|
21
|
+
-----BEGIN CERTIFICATE-----
|
22
|
+
MIIF3jCCA8agAwIBAgIQAf1tMPyjylGoG7xkDjUDLTANBgkqhkiG9w0BAQwFADCB
|
23
|
+
iDELMAkGA1UEBhMCVVMxEzARBg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cIiuPhnPQCjY/MiQu12ZIvVS5ljFH4gxQ+6IHdfG
|
53
|
+
jjxDah2nGN59PRbxYvnKkKj9
|
54
|
+
-----END CERTIFICATE-----
|
55
|
+
|
19
56
|
GTE CyberTrust Global Root
|
20
57
|
==========================
|
21
58
|
-----BEGIN CERTIFICATE-----
|
@@ -551,30 +588,6 @@ mYbvP33zGDLKe8bjq2RGlfgmadlVg3sslgf/WSxEo8bl6ancoWOAWiFeIc9TVPC6b4nbqKqVz4vj
|
|
551
588
|
ccweGyBECMB6tkD9xOQ14R0WHNC8K47Wcdk=
|
552
589
|
-----END CERTIFICATE-----
|
553
590
|
|
554
|
-
AddTrust External Root
|
555
|
-
======================
|
556
|
-
-----BEGIN CERTIFICATE-----
|
557
|
-
MIIENjCCAx6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBvMQswCQYDVQQGEwJTRTEUMBIGA1UEChML
|
558
|
-
QWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFkZFRydXN0IEV4dGVybmFsIFRUUCBOZXR3b3JrMSIwIAYD
|
559
|
-
VQQDExlBZGRUcnVzdCBFeHRlcm5hbCBDQSBSb290MB4XDTAwMDUzMDEwNDgzOFoXDTIwMDUzMDEw
|
560
|
-
NDgzOFowbzELMAkGA1UEBhMCU0UxFDASBgNVBAoTC0FkZFRydXN0IEFCMSYwJAYDVQQLEx1BZGRU
|
561
|
-
cnVzdCBFeHRlcm5hbCBUVFAgTmV0d29yazEiMCAGA1UEAxMZQWRkVHJ1c3QgRXh0ZXJuYWwgQ0Eg
|
562
|
-
Um9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALf3GjPm8gAELTngTlvtH7xsD821
|
563
|
-
+iO2zt6bETOXpClMfZOfvUq8k+0DGuOPz+VtUFrWlymUWoCwSXrbLpX9uMq/NzgtHj6RQa1wVsfw
|
564
|
-
Tz/oMp50ysiQVOnGXw94nZpAPA6sYapeFI+eh6FqUNzXmk6vBbOmcZSccbNQYArHE504B4YCqOmo
|
565
|
-
aSYYkKtMsE8jqzpPhNjfzp/haW+710LXa0Tkx63ubUFfclpxCDezeWWkWaCUN/cALw3CknLa0Dhy
|
566
|
-
2xSoRcRdKn23tNbE7qzNE0S3ySvdQwAl+mG5aWpYIxG3pzOPVnVZ9c0p10a3CitlttNCbxWyuHv7
|
567
|
-
7+ldU9U0WicCAwEAAaOB3DCB2TAdBgNVHQ4EFgQUrb2YejS0Jvf6xCZU7wO94CTLVBowCwYDVR0P
|
568
|
-
BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wgZkGA1UdIwSBkTCBjoAUrb2YejS0Jvf6xCZU7wO94CTL
|
569
|
-
VBqhc6RxMG8xCzAJBgNVBAYTAlNFMRQwEgYDVQQKEwtBZGRUcnVzdCBBQjEmMCQGA1UECxMdQWRk
|
570
|
-
VHJ1c3QgRXh0ZXJuYWwgVFRQIE5ldHdvcmsxIjAgBgNVBAMTGUFkZFRydXN0IEV4dGVybmFsIENB
|
571
|
-
IFJvb3SCAQEwDQYJKoZIhvcNAQEFBQADggEBALCb4IUlwtYj4g+WBpKdQZic2YR5gdkeWxQHIzZl
|
572
|
-
j7DYd7usQWxHYINRsPkyPef89iYTx4AWpb9a/IfPeHmJIZriTAcKhjW88t5RxNKWt9x+Tu5w/Rw5
|
573
|
-
6wwCURQtjr0W4MHfRnXnJK3s9EK0hZNwEGe6nQY1ShjTK3rMUUKhemPR5ruhxSvCNr4TDea9Y355
|
574
|
-
e6cJDUCrat2PisP29owaQgVR1EX1n6diIWgVIEM8med8vSTYqZEXc4g/VhsxOBi0cQ+azcgOno4u
|
575
|
-
G+GMmIPLHzHxREzGBHNJdmAPx/i9F4BrLunMTA5amnkPIAou1Z5jJh5VkpTYghdae9C8x49OhgQ=
|
576
|
-
-----END CERTIFICATE-----
|
577
|
-
|
578
591
|
AddTrust Public Services Root
|
579
592
|
=============================
|
580
593
|
-----BEGIN CERTIFICATE-----
|
data/spec/account_client_spec.rb
CHANGED
@@ -47,9 +47,7 @@ describe 'Account client' do
|
|
47
47
|
|
48
48
|
it 'should perform a cross app copy index and assert that destination must not exist' do
|
49
49
|
|
50
|
-
@index_1.save_objects!
|
51
|
-
{:objectID => 'one'},
|
52
|
-
])
|
50
|
+
@index_1.save_objects!(1.upto(1500).map { |i| { :objectID => i, :i => i } })
|
53
51
|
|
54
52
|
@index_1.batch_rules! ([
|
55
53
|
{
|
@@ -67,9 +65,8 @@ describe 'Account client' do
|
|
67
65
|
|
68
66
|
Algolia::AccountClient.copy_index!(@index_1, @index_3)
|
69
67
|
|
70
|
-
res = @index_3.search('')
|
71
|
-
res['nbHits'].should eq(
|
72
|
-
res['hits'][0]['objectID'].should eq('one')
|
68
|
+
res = @index_3.search('')
|
69
|
+
res['nbHits'].should eq(1500)
|
73
70
|
|
74
71
|
res = @index_3.search_rules('')['hits']
|
75
72
|
res.size.should eq(1)
|
data/spec/client_spec.rb
CHANGED
@@ -175,6 +175,16 @@ describe 'Client' do
|
|
175
175
|
@index.delete_index rescue "not fatal"
|
176
176
|
end
|
177
177
|
|
178
|
+
it "should tell if index exists" do
|
179
|
+
@index.add_object!({ :name => "John Doe", :email => "john@doe.org" }, "1")
|
180
|
+
expect(@index.exists?).to be true
|
181
|
+
end
|
182
|
+
|
183
|
+
it "should tell if index does not exist" do
|
184
|
+
index = Algolia::Index.new('nonexistent_index')
|
185
|
+
expect(index.exists?).to be false
|
186
|
+
end
|
187
|
+
|
178
188
|
it "should add a simple object" do
|
179
189
|
@index.add_object!({ :name => "John Doe", :email => "john@doe.org" }, "1")
|
180
190
|
res = @index.search("john")
|
@@ -436,6 +446,73 @@ describe 'Client' do
|
|
436
446
|
end
|
437
447
|
end
|
438
448
|
|
449
|
+
it 'should find objects when needed' do
|
450
|
+
index = Algolia::Index.new(safe_index_name("àlgol?à"))
|
451
|
+
|
452
|
+
index.save_objects!([
|
453
|
+
{:company => 'Algolia', :name => 'Julien Lemoine', :objectID => 'julien-lemoine'},
|
454
|
+
{:company => 'Algolia', :name => 'Nicolas Dessaigne', :objectID => 'nicolas-dessaigne'},
|
455
|
+
{:company => 'Amazon', :name =>' "Jeff Bezos', :objectID => '162590850'},
|
456
|
+
{:company => 'Apple', :name => 'Steve Jobs', :objectID => '162590860'},
|
457
|
+
{:company => 'Apple', :name => 'Steve Wozniak', :objectID => '162590870'},
|
458
|
+
{:company => 'Arista Networks', :name => 'Jayshree Ullal', :objectID => '162590880'},
|
459
|
+
{:company => 'Google', :name => 'Larry Page', :objectID => '162590890'},
|
460
|
+
{:company => 'Google', :name => 'Rob Pike', :objectID => '162590900'},
|
461
|
+
{:company => 'Google', :name => 'Sergueï Brin', :objectID => '162590910'},
|
462
|
+
{:company => 'Microsoft', :name => 'Bill Gates', :objectID => '162590920'},
|
463
|
+
{:company => 'SpaceX', :name => 'Elon Musk', :objectID => '162590930'},
|
464
|
+
{:company => 'Tesla', :name => 'Elon Musk', :objectID => '162590940'},
|
465
|
+
{:company => 'Yahoo', :name => 'Marissa Mayer', :objectID => '162590950'},
|
466
|
+
])
|
467
|
+
|
468
|
+
res = index.search('algolia')
|
469
|
+
Algolia::Index.get_object_position(res, 'nicolas-dessaigne').should eq(0)
|
470
|
+
Algolia::Index.get_object_position(res, 'julien-lemoine').should eq(1)
|
471
|
+
Algolia::Index.get_object_position(res, '').should eq(-1)
|
472
|
+
|
473
|
+
expect {
|
474
|
+
index.find_object({'query' => '', 'paginate' => true})
|
475
|
+
}.to raise_exception(
|
476
|
+
Algolia::AlgoliaObjectNotFoundError,
|
477
|
+
'Object not found'
|
478
|
+
)
|
479
|
+
|
480
|
+
expect {
|
481
|
+
index.find_object({'query' => '', 'paginate' => true}) { false }
|
482
|
+
}.to raise_exception(
|
483
|
+
Algolia::AlgoliaObjectNotFoundError,
|
484
|
+
'Object not found'
|
485
|
+
)
|
486
|
+
|
487
|
+
obj = index.find_object({'query' => '', 'paginate' => true}) { true }
|
488
|
+
obj['position'].should eq(0)
|
489
|
+
obj['page'].should eq(0)
|
490
|
+
|
491
|
+
# we use a lambda and convert it to a block with `&`
|
492
|
+
# so as not to repeat the condition
|
493
|
+
condition = lambda do |obj|
|
494
|
+
obj.key?('company') and obj['company'] == 'Apple'
|
495
|
+
end
|
496
|
+
|
497
|
+
expect {
|
498
|
+
index.find_object({'query' => 'algolia', 'paginate' => true}, &condition)
|
499
|
+
}.to raise_exception(
|
500
|
+
Algolia::AlgoliaObjectNotFoundError,
|
501
|
+
'Object not found'
|
502
|
+
)
|
503
|
+
|
504
|
+
expect {
|
505
|
+
index.find_object({'query' => '', 'paginate' => false, 'hitsPerPage' => 5}, &condition)
|
506
|
+
}.to raise_exception(
|
507
|
+
Algolia::AlgoliaObjectNotFoundError,
|
508
|
+
'Object not found'
|
509
|
+
)
|
510
|
+
|
511
|
+
obj = index.find_object({'query' => '', 'paginate' => true, 'hitsPerPage' => 5}, &condition)
|
512
|
+
obj['position'].should eq(0)
|
513
|
+
obj['page'].should eq(2)
|
514
|
+
end
|
515
|
+
|
439
516
|
it "should copy the index" do
|
440
517
|
index = Algolia::Index.new(safe_index_name("àlgol?à"))
|
441
518
|
begin
|
@@ -615,7 +692,7 @@ describe 'Client' do
|
|
615
692
|
expect { Algolia.multiple_queries([{"query" => ""}]) }.to raise_error(ArgumentError)
|
616
693
|
end
|
617
694
|
|
618
|
-
it "
|
695
|
+
it "should accept custom batch" do
|
619
696
|
@index.clear_index! rescue "Not fatal"
|
620
697
|
request = { "requests" => [
|
621
698
|
{
|
@@ -1277,6 +1354,19 @@ describe 'Client' do
|
|
1277
1354
|
expect{Algolia.list_indexes('headers' => { 'X-Algolia-API-Key' => 'NotExistentAPIKey' })}.to raise_error(Algolia::AlgoliaProtocolError)
|
1278
1355
|
end
|
1279
1356
|
|
1357
|
+
it 'should retrieve the remaining validity time in seconds' do
|
1358
|
+
now = Time.now.to_i
|
1359
|
+
|
1360
|
+
key = Algolia.generate_secured_api_key('foo', :validUntil => now - (10 * 60))
|
1361
|
+
expect(Algolia.get_secured_api_key_remaining_validity(key)).to be < 0
|
1362
|
+
|
1363
|
+
key = Algolia.generate_secured_api_key('foo', :validUntil => now + (10 * 60))
|
1364
|
+
expect(Algolia.get_secured_api_key_remaining_validity(key)).to be > 0
|
1365
|
+
|
1366
|
+
key = Algolia.generate_secured_api_key('foo', [])
|
1367
|
+
expect { Algolia.get_secured_api_key_remaining_validity(key) }.to raise_error(Algolia::ValidUntilNotFoundError)
|
1368
|
+
end
|
1369
|
+
|
1280
1370
|
context 'DNS timeout' do
|
1281
1371
|
before(:each) do
|
1282
1372
|
@client = Algolia::Client.new :application_id => ENV['ALGOLIA_APPLICATION_ID'], :api_key => ENV['ALGOLIA_API_KEY'],
|
metadata
CHANGED
@@ -1,49 +1,49 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: algoliasearch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.27.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Algolia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: json
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '2.8'
|
20
17
|
- - ">="
|
21
18
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
19
|
+
version: 1.5.1
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- - "~>"
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '2.8'
|
30
24
|
- - ">="
|
31
25
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
26
|
+
version: 1.5.1
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
|
-
name:
|
28
|
+
name: httpclient
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
36
30
|
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.8'
|
37
34
|
- - ">="
|
38
35
|
- !ruby/object:Gem::Version
|
39
|
-
version:
|
36
|
+
version: 2.8.3
|
40
37
|
type: :runtime
|
41
38
|
prerelease: false
|
42
39
|
version_requirements: !ruby/object:Gem::Requirement
|
43
40
|
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '2.8'
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
46
|
+
version: 2.8.3
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: travis
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
145
|
- !ruby/object:Gem::Version
|
146
146
|
version: '0'
|
147
147
|
requirements: []
|
148
|
-
rubygems_version: 3.0.
|
148
|
+
rubygems_version: 3.0.4
|
149
149
|
signing_key:
|
150
150
|
specification_version: 4
|
151
151
|
summary: A simple Ruby client for the algolia.com REST API
|