algoliasearch 1.2.11 → 1.2.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +9 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +2 -2
- data/README.md +6 -4
- data/algoliasearch.gemspec +2 -2
- data/lib/algolia/client.rb +34 -32
- data/lib/algolia/version.rb +1 -1
- data/spec/client_spec.rb +4 -4
- metadata +17 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce03495d8a65c3fc3df2ecce17d405ea3b06ec10
|
4
|
+
data.tar.gz: ce3aca4b079c7ae6c904bc72ed8a717e4d6d052f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 496951be33beaee2a259bdacd641774f7718644ac5f36b2d70b71420e715db3f6db3341de6ff8a955224cf46e184f13421ab3d26a76765a747f88526001ce5b9
|
7
|
+
data.tar.gz: 782d7260a5083a9d2c34006694cd94d393f8ec658a20fd209eca9b352a286df0cd081f46c179e4578f2d01a4e6c34a32aa5664dae79bb45e8522f77a06384699
|
data/ChangeLog
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
|
3
|
+
2014-10-08 1.2.12
|
4
|
+
|
5
|
+
* Upgrade to httpclient 2.4
|
6
|
+
* Do not reset the timeout on each requests
|
7
|
+
|
8
|
+
2014-09-14 1.2.11
|
9
|
+
|
10
|
+
* Ability to update API keys
|
11
|
+
|
3
12
|
2014-08-22 1.2.10
|
4
13
|
|
5
14
|
* Using Digest to remove "Digest::Digest is deprecated; Use Digest" warning (author: @dglancy)
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -37,7 +37,7 @@ GEM
|
|
37
37
|
net-http-persistent (>= 2.7)
|
38
38
|
net-http-pipeline
|
39
39
|
highline (1.6.21)
|
40
|
-
httpclient (2.
|
40
|
+
httpclient (2.4.0)
|
41
41
|
json (1.8.1)
|
42
42
|
json (1.8.1-java)
|
43
43
|
launchy (2.4.2)
|
@@ -325,7 +325,7 @@ DEPENDENCIES
|
|
325
325
|
autotest-fsevent
|
326
326
|
autotest-growl
|
327
327
|
coveralls
|
328
|
-
httpclient (~> 2.
|
328
|
+
httpclient (~> 2.4)
|
329
329
|
json (>= 1.5.1)
|
330
330
|
mime-types (< 2.0)
|
331
331
|
rake
|
data/README.md
CHANGED
@@ -148,6 +148,8 @@ puts index.search('jim').to_json
|
|
148
148
|
|
149
149
|
|
150
150
|
|
151
|
+
|
152
|
+
|
151
153
|
Documentation
|
152
154
|
================
|
153
155
|
|
@@ -255,10 +257,10 @@ You can use the following optional arguments:
|
|
255
257
|
* **prefixAll**: all query words are interpreted as prefixes,
|
256
258
|
* **prefixLast**: only the last word is interpreted as a prefix (default behavior),
|
257
259
|
* **prefixNone**: no query word is interpreted as a prefix. This option is not recommended.
|
258
|
-
* **
|
259
|
-
* **
|
260
|
-
* **
|
261
|
-
* **
|
260
|
+
* **removeWordsIfNoResults**: This option to select a strategy to avoid having an empty result page. There is three different option:
|
261
|
+
* **lastWords**: when a query does not return any result, the last word will be added as optional (the process is repeated with n-1 word, n-2 word, ... until there is results),
|
262
|
+
* **firstWords**: when a query does not return any result, the first word will be added as optional (the process is repeated with second word, third word, ... until there is results),
|
263
|
+
* **none**: No specific processing is done when a query does not return any result (default behavior).
|
262
264
|
* **typoTolerance**: if set to false, disable the typo-tolerance. Defaults to true.
|
263
265
|
* **minWordSizefor1Typo**: the minimum number of characters in a query word to accept one typo in this word.<br/>Defaults to 4.
|
264
266
|
* **minWordSizefor2Typos**: the minimum number of characters in a query word to accept two typos in this word.<br/>Defaults to 8.
|
data/algoliasearch.gemspec
CHANGED
@@ -6,12 +6,12 @@
|
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "algoliasearch"
|
9
|
-
s.version = "1.2.
|
9
|
+
s.version = "1.2.12"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Algolia"]
|
14
|
-
s.date = "2014-08
|
14
|
+
s.date = "2014-10-08"
|
15
15
|
s.description = "A simple Ruby client for the algolia.com REST API"
|
16
16
|
s.email = "contact@algolia.com"
|
17
17
|
s.extra_rdoc_files = [
|
data/lib/algolia/client.rb
CHANGED
@@ -36,9 +36,9 @@ module Algolia
|
|
36
36
|
# and will return the parsed JSON body on success, if there is one.
|
37
37
|
def request(uri, method, data = nil, timeout = nil)
|
38
38
|
exceptions = []
|
39
|
-
thread_local_hosts.each do |host|
|
39
|
+
thread_local_hosts(timeout).each do |host|
|
40
40
|
begin
|
41
|
-
return perform_request(host[:session], host[:base_url] + uri, method, data
|
41
|
+
return perform_request(host[:session], host[:base_url] + uri, method, data)
|
42
42
|
rescue AlgoliaProtocolError => e
|
43
43
|
raise if e.code != Protocol::ERROR_TIMEOUT and e.code != Protocol::ERROR_UNAVAILABLE
|
44
44
|
exceptions << e
|
@@ -58,55 +58,57 @@ module Algolia
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def put(uri, body = {}, timeout = nil)
|
61
|
-
request(uri, :PUT, body)
|
61
|
+
request(uri, :PUT, body, timeout)
|
62
62
|
end
|
63
63
|
|
64
64
|
def delete(uri, timeout = nil)
|
65
|
-
request(uri, :DELETE)
|
65
|
+
request(uri, :DELETE, nil, timeout)
|
66
66
|
end
|
67
67
|
|
68
68
|
private
|
69
69
|
|
70
|
-
#
|
71
|
-
|
72
|
-
|
70
|
+
# This method returns a thread-local array of sessions
|
71
|
+
#
|
72
|
+
# Since the underlying httpclient library resets the connections pool
|
73
|
+
# if you change any of its attributes, we cannot change the timeout
|
74
|
+
# of an HTTP session dynamically. That being said, having 1 pool per
|
75
|
+
# timeout appears to be the only acceptable solution
|
76
|
+
def thread_local_hosts(forced_timeout)
|
77
|
+
Thread.current[:algolia_hosts] ||= {}
|
78
|
+
Thread.current[:algolia_hosts][forced_timeout.to_s] ||= hosts.map do |host|
|
73
79
|
hinfo = {
|
74
80
|
:base_url => "http#{@ssl ? 's' : ''}://#{host}",
|
75
81
|
:session => HTTPClient.new
|
76
82
|
}
|
77
83
|
hinfo[:session].transparent_gzip_decompression = true
|
78
84
|
hinfo[:session].connect_timeout = @connect_timeout if @connect_timeout
|
79
|
-
|
80
|
-
|
85
|
+
if forced_timeout
|
86
|
+
hinfo[:session].send_timeout = hinfo[:session].receive_timeout = forced_timeout
|
87
|
+
else
|
88
|
+
hinfo[:session].send_timeout = @send_timeout if @send_timeout
|
89
|
+
hinfo[:session].receive_timeout = @receive_timeout if @receive_timeout
|
90
|
+
end
|
81
91
|
hinfo[:session].ssl_config.add_trust_ca File.join(File.dirname(__FILE__), '..', '..', 'resources', 'ca-bundle.crt')
|
82
92
|
hinfo
|
83
93
|
end
|
84
94
|
end
|
85
95
|
|
86
96
|
private
|
87
|
-
def perform_request(session, url, method, data
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
session.delete(url, { :header => @headers })
|
101
|
-
end
|
102
|
-
if response.code >= 400 || response.code < 200
|
103
|
-
raise AlgoliaProtocolError.new(response.code, "Cannot #{method} to #{url}: #{response.content} (#{response.code})")
|
104
|
-
end
|
105
|
-
return JSON.parse(response.content)
|
106
|
-
ensure
|
107
|
-
session.send_timeout = original_send_timeout
|
108
|
-
session.receive_timeout = original_receive_timeout
|
97
|
+
def perform_request(session, url, method, data)
|
98
|
+
response = case method
|
99
|
+
when :GET
|
100
|
+
session.get(url, { :header => @headers })
|
101
|
+
when :POST
|
102
|
+
session.post(url, { :body => data, :header => @headers })
|
103
|
+
when :PUT
|
104
|
+
session.put(url, { :body => data, :header => @headers })
|
105
|
+
when :DELETE
|
106
|
+
session.delete(url, { :header => @headers })
|
107
|
+
end
|
108
|
+
if response.code >= 400 || response.code < 200
|
109
|
+
raise AlgoliaProtocolError.new(response.code, "Cannot #{method} to #{url}: #{response.content} (#{response.code})")
|
109
110
|
end
|
111
|
+
return JSON.parse(response.content)
|
110
112
|
end
|
111
113
|
|
112
114
|
end
|
@@ -347,7 +349,7 @@ module Algolia
|
|
347
349
|
|
348
350
|
# Used mostly for testing. Lets you delete the api key global vars.
|
349
351
|
def Algolia.destroy
|
350
|
-
@@client = nil
|
352
|
+
@@client = Thread.current[:algolia_hosts] = nil
|
351
353
|
self
|
352
354
|
end
|
353
355
|
|
data/lib/algolia/version.rb
CHANGED
data/spec/client_spec.rb
CHANGED
@@ -614,13 +614,13 @@ describe 'Client' do
|
|
614
614
|
|
615
615
|
it 'should generate secured api keys' do
|
616
616
|
key = Algolia.generate_secured_api_key('my_api_key', '(public,user1)')
|
617
|
-
key.should eq(OpenSSL::HMAC.hexdigest(OpenSSL::Digest
|
617
|
+
key.should eq(OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), 'my_api_key', '(public,user1)'))
|
618
618
|
key = Algolia.generate_secured_api_key('my_api_key', '(public,user1)', 42)
|
619
|
-
key.should eq(OpenSSL::HMAC.hexdigest(OpenSSL::Digest
|
619
|
+
key.should eq(OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), 'my_api_key', '(public,user1)42'))
|
620
620
|
key = Algolia.generate_secured_api_key('my_api_key', ['public'])
|
621
|
-
key.should eq(OpenSSL::HMAC.hexdigest(OpenSSL::Digest
|
621
|
+
key.should eq(OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), 'my_api_key', 'public'))
|
622
622
|
key = Algolia.generate_secured_api_key('my_api_key', ['public', ['premium','vip']])
|
623
|
-
key.should eq(OpenSSL::HMAC.hexdigest(OpenSSL::Digest
|
623
|
+
key.should eq(OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), 'my_api_key', 'public,(premium,vip)'))
|
624
624
|
end
|
625
625
|
|
626
626
|
it 'Check attributes multipleQueries' do
|
metadata
CHANGED
@@ -1,83 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: algoliasearch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Algolia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08
|
11
|
+
date: 2014-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '2.3'
|
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
26
|
version: '2.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: json
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 1.5.1
|
34
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
40
|
version: 1.5.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: travis
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rdoc
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
description: A simple Ruby client for the algolia.com REST API
|
@@ -89,8 +89,8 @@ extra_rdoc_files:
|
|
89
89
|
- LICENSE.txt
|
90
90
|
- README.md
|
91
91
|
files:
|
92
|
-
- .rspec
|
93
|
-
- .travis.yml
|
92
|
+
- ".rspec"
|
93
|
+
- ".travis.yml"
|
94
94
|
- ChangeLog
|
95
95
|
- Gemfile
|
96
96
|
- Gemfile.lock
|
@@ -121,17 +121,17 @@ require_paths:
|
|
121
121
|
- lib
|
122
122
|
required_ruby_version: !ruby/object:Gem::Requirement
|
123
123
|
requirements:
|
124
|
-
- -
|
124
|
+
- - ">="
|
125
125
|
- !ruby/object:Gem::Version
|
126
126
|
version: '0'
|
127
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- -
|
129
|
+
- - ">="
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '0'
|
132
132
|
requirements: []
|
133
133
|
rubyforge_project:
|
134
|
-
rubygems_version: 2.
|
134
|
+
rubygems_version: 2.2.2
|
135
135
|
signing_key:
|
136
136
|
specification_version: 4
|
137
137
|
summary: A simple Ruby client for the algolia.com REST API
|