algoliasearch 1.1.2 → 1.1.3

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: b1673fe77906c67ae24f6f8beeb96c744df33a9c
4
- data.tar.gz: cbdae006907dc974cc70d14c1827b03f11326523
3
+ metadata.gz: 3e76972bfa991277d06f88eb6a26127541bf6f39
4
+ data.tar.gz: 77fcd139aea3c16ea07954bc8f2c2aa5170d5188
5
5
  SHA512:
6
- metadata.gz: ae2decbf23a90d5d2d35231ebba879e33c30b9b83b93dc17354ebb7d4d087fa61ec12f2ad3536b2c15e2b575590d1420633bf7b0236429ea5ae1db7c56148e07
7
- data.tar.gz: 6ad7e4b1fadf61a650dfed354817676da07740695c9417bfcbdb21af5746aa5d1fb2ea12f9a07ef48772c3a31a0cca1bce80ea51bd338f4190ef019216222f37
6
+ metadata.gz: 7ccb1980654aec274dec37804170e22b930234df9d9c09e1acf7a690ba78d5311e730516f7ce012b7114f199a5c02399740071cc8ca6c47da916bf960752c322
7
+ data.tar.gz: b03060f3cefaa2407ed0307350bd32ff597d2e6c356b3704dd9ba9bdb86c5b70aaffd523e69e923d961985b1990f23e406ef2d80968223738dc75600d8d07298
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ branches:
3
+ only:
4
+ - master
5
+ rvm:
6
+ - 2.0.0
7
+ - 1.9.3
8
+ - rbx-19mode
9
+ env:
10
+ global:
11
+ - secure: lBLtTjQyeJW7+TWgGmf1mmsXgUzsTnq3/KHvCk+BvOGwoHXTBR1Y6yiczWWHEP4/wBeXXm31xUQC+VoYc/7Ev/2NNB/mqlXAgGw+D0nwQriNXjYt1WV6lQvyoiaUzQ+w+7VahWdx0LuKvSYI+khe8M8BfHQqYacu0VlpAUnjb2I=
12
+ - secure: mtXQd2Tre01/I2e2MtD0Nu0nocKL9bLozN3v0qZdACpwSwAE1lr8EmAGIZUJp/FbqISOXcjMTmnjvhqp+gw6SE7pdO7vzzzuoJUVi50IrasoBFV97S+lX091n4D4/BDnP906qeA+/1apcIFwk4+8SNgrsIUcZui2eMjP3YunM4g=
data/Gemfile CHANGED
@@ -5,6 +5,7 @@ gem "curb"
5
5
  group :development do
6
6
  gem "bundler"
7
7
  gem "jeweler"
8
+ gem "travis"
8
9
  end
9
10
 
10
11
  group :test do
data/Gemfile.lock CHANGED
@@ -8,12 +8,26 @@ GEM
8
8
  autotest-fsevent (0.2.8)
9
9
  sys-uname
10
10
  autotest-growl (0.2.16)
11
+ backports (3.3.4)
11
12
  builder (3.2.2)
13
+ coderay (1.0.9)
12
14
  curb (0.8.4)
13
15
  diff-lcs (1.2.4)
16
+ ethon (0.6.1)
17
+ ffi (>= 1.3.0)
18
+ mime-types (~> 1.18)
14
19
  faraday (0.8.8)
15
20
  multipart-post (~> 1.2.0)
21
+ faraday_middleware (0.9.0)
22
+ faraday (>= 0.7.4, < 0.9)
16
23
  ffi (1.9.0)
24
+ gh (0.13.0)
25
+ addressable
26
+ backports
27
+ faraday (~> 0.8)
28
+ multi_json (~> 1.0)
29
+ net-http-persistent (>= 2.7)
30
+ net-http-pipeline
17
31
  git (1.2.6)
18
32
  github_api (0.10.1)
19
33
  addressable
@@ -37,9 +51,16 @@ GEM
37
51
  json (1.8.0)
38
52
  jwt (0.1.8)
39
53
  multi_json (>= 1.5)
54
+ launchy (2.3.0)
55
+ addressable (~> 2.3)
56
+ method_source (0.8.2)
57
+ mime-types (1.25)
40
58
  multi_json (1.8.0)
41
59
  multi_xml (0.5.5)
42
60
  multipart-post (1.2.0)
61
+ net-http-persistent (2.9)
62
+ net-http-pipeline (1.0.1)
63
+ netrc (0.7.7)
43
64
  nokogiri (1.5.10)
44
65
  oauth2 (0.9.2)
45
66
  faraday (~> 0.8)
@@ -48,6 +69,13 @@ GEM
48
69
  multi_json (~> 1.0)
49
70
  multi_xml (~> 0.5)
50
71
  rack (~> 1.2)
72
+ pry (0.9.12.2)
73
+ coderay (~> 1.0.5)
74
+ method_source (~> 0.8)
75
+ slop (~> 3.4)
76
+ pusher-client (0.3.1)
77
+ ruby-hmac (~> 0.4.0)
78
+ websocket (~> 1.0.0)
51
79
  rack (1.5.2)
52
80
  rake (10.1.0)
53
81
  rdoc (4.0.1)
@@ -61,8 +89,26 @@ GEM
61
89
  rspec-expectations (2.14.3)
62
90
  diff-lcs (>= 1.1.3, < 2.0)
63
91
  rspec-mocks (2.14.3)
92
+ ruby-hmac (0.4.0)
93
+ slop (3.4.6)
64
94
  sys-uname (0.9.2)
65
95
  ffi (>= 1.0.0)
96
+ terminal-notifier (1.5.1)
97
+ travis (1.5.4)
98
+ backports
99
+ faraday (~> 0.8.7)
100
+ faraday_middleware (~> 0.9)
101
+ gh (~> 0.13)
102
+ highline (~> 1.6)
103
+ launchy (~> 2.1)
104
+ netrc (~> 0.7)
105
+ pry (~> 0.9)
106
+ pusher-client (~> 0.3, >= 0.3.1)
107
+ terminal-notifier (>= 1.4.2)
108
+ typhoeus (~> 0.6)
109
+ typhoeus (0.6.5)
110
+ ethon (~> 0.6.1)
111
+ websocket (1.0.7)
66
112
 
67
113
  PLATFORMS
68
114
  ruby
@@ -76,3 +122,4 @@ DEPENDENCIES
76
122
  jeweler
77
123
  redgreen
78
124
  rspec
125
+ travis
data/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  Algolia Search API Client for Ruby
2
2
  ==================
3
3
 
4
- This Ruby client let you easily use the Algolia Search API from your backend.
5
- The service is currently in Beta, you can request an invite on our [website](http://www.algolia.com/pricing/).
4
+ This Ruby client let you easily use the Algolia Search API from your backend. It wraps [Algolia's REST API](http://www.algolia.com/doc/rest_api).
5
+
6
+ [![Build Status](https://travis-ci.org/algolia/algoliasearch-client-ruby.png?branch=master)](https://travis-ci.org/algolia/algoliasearch-client-ruby) [![Gem Version](https://badge.fury.io/rb/algoliasearch.png)](http://badge.fury.io/rb/algoliasearch) [![Code Climate](https://codeclimate.com/github/algolia/algoliasearch-client-ruby.png)](https://codeclimate.com/github/algolia/algoliasearch-client-ruby)
6
7
 
7
8
  Table of Content
8
9
  -------------
@@ -91,16 +92,16 @@ You can use the following optional arguments:
91
92
  * **attributes**: a string that contains the names of attributes to retrieve separated by a comma.<br/>By default all attributes are retrieved.
92
93
  * **attributesToHighlight**: a string that contains the names of attributes to highlight separated by a comma.<br/>By default indexed attributes are highlighted. Numerical attributes cannot be highlighted. A **matchLevel** is returned for each highlighted attribute and can contain: "full" if all the query terms were found in the attribute, "partial" if only some of the query terms were found, or "none" if none of the query terms were found.
93
94
  * **attributesToSnippet**: a string that contains the names of attributes to snippet alongside the number of words to return (syntax is 'attributeName:nbWords'). Attributes are separated by a comma (Example: "attributesToSnippet=name:10,content:10").<br/>By default no snippet is computed.
94
- * **minWordSizeForApprox1**: the minimum number of characters in a query word to accept one typo in this word.<br/>Defaults to 3.
95
- * **minWordSizeForApprox2**: the minimum number of characters in a query word to accept two typos in this word.<br/>Defaults to 7.
95
+ * **minWordSizefor1Typo**: the minimum number of characters in a query word to accept one typo in this word.<br/>Defaults to 3.
96
+ * **minWordSizefor2Typos**: the minimum number of characters in a query word to accept two typos in this word.<br/>Defaults to 7.
96
97
  * **getRankingInfo**: if set to 1, the result hits will contain ranking information in _rankingInfo attribute.
97
98
  * **page**: *(pagination parameter)* page to retrieve (zero base).<br/>Defaults to 0.
98
99
  * **hitsPerPage**: *(pagination parameter)* number of hits per page.<br/>Defaults to 10.
99
100
  * **aroundLatLng**: search for entries around a given latitude/longitude (specified as two floats separated by a comma).<br/>For example `aroundLatLng=47.316669,5.016670`).<br/>You can specify the maximum distance in meters with the **aroundRadius** parameter (in meters) and the precision for ranking with **aroundPrecision** (for example if you set aroundPrecision=100, two objects that are distant of less than 100m will be considered as identical for "geo" ranking parameter).<br/>At indexing, you should specify geoloc of an object with the _geoloc attribute (in the form `{"_geoloc":{"lat":48.853409, "lng":2.348800}}`)
100
101
  * **insideBoundingBox**: search entries inside a given area defined by the two extreme points of a rectangle (defined by 4 floats: p1Lat,p1Lng,p2Lat,p2Lng).<br/>For example `insideBoundingBox=47.3165,4.9665,47.3424,5.0201`).<br/>At indexing, you should specify geoloc of an object with the _geoloc attribute (in the form `{"_geoloc":{"lat":48.853409, "lng":2.348800}}`)
101
102
  * **queryType**: select how the query words are interpreted:
102
- * **prefixAll**: all query words are interpreted as prefixes (default behavior).
103
- * **prefixLast**: only the last word is interpreted as a prefix. This option is recommended if you have a lot of content to speedup the processing.
103
+ * **prefixAll**: all query words are interpreted as prefixes,
104
+ * **prefixLast**: only the last word is interpreted as a prefix (default behavior),
104
105
  * **prefixNone**: no query word is interpreted as a prefix. This option is not recommended.
105
106
  * **numerics**: specify the list of numeric filters you want to apply separated by a comma. The syntax of one filter is `attributeName` followed by `operand` followed by `value`. Supported operands are `<`, `<=`, `=`, `>` and `>=`.
106
107
  You can have multiple conditions on one attribute like for example `numerics=price>100,price<1000`.
@@ -249,15 +250,15 @@ Index Settings
249
250
 
250
251
  You can retrieve all settings using the `getSettings` function. The result will contains the following attributes:
251
252
 
252
- * **minWordSizeForApprox1**: (integer) the minimum number of characters to accept one typo (default = 3).
253
- * **minWordSizeForApprox2**: (integer) the minimum number of characters to accept two typos (default = 7).
253
+ * **minWordSizefor1Typo**: (integer) the minimum number of characters to accept one typo (default = 3).
254
+ * **minWordSizefor2Typos**: (integer) the minimum number of characters to accept two typos (default = 7).
254
255
  * **hitsPerPage**: (integer) the number of hits per page (default = 10).
255
256
  * **attributesToRetrieve**: (array of strings) default list of attributes to retrieve in objects.
256
257
  * **attributesToHighlight**: (array of strings) default list of attributes to highlight.
257
258
  * **attributesToSnippet**: (array of strings) default list of attributes to snippet alongside the number of words to return (syntax is 'attributeName:nbWords')<br/>By default no snippet is computed.
258
259
  * **attributesToIndex**: (array of strings) the list of fields you want to index.<br/>By default all textual and numerical attributes of your objects are indexed, but you should update it to get optimal results.<br/>This parameter has two important uses:
259
260
  * *Limits the attributes to index*.<br/>For example if you store a binary image in base64, you want to store it and be able to retrieve it but you don't want to search in the base64 string.
260
- * *Controls part of the ranking*.<br/>Matches in attributes at the beginning of the list will be considered more important than matches in attributes further down the list.
261
+ * *Controls part of the ranking*.<br/>Matches in attributes at the beginning of the list will be considered more important than matches in attributes further down the list. In one attribute, matching text at the beginning of the attribute will be considered more important than text after, you can disable this behavior if you add your attribute inside `unordered(AttributeName)`, for example `attributesToIndex:["title", "unordered(text)"]`.
261
262
  * **ranking**: (array of strings) controls the way hits are sorted.<br/>We have six available criteria:
262
263
  * **typo**: sort according to number of typos,
263
264
  * **geo**: sort according to decreasing distance when performing a geo-location based search,
@@ -269,8 +270,8 @@ You can retrieve all settings using the `getSettings` function. The result will
269
270
  * **customRanking**: (array of strings) lets you specify part of the ranking.<br/>The syntax of this condition is an array of strings containing attributes prefixed by asc (ascending order) or desc (descending order) operator.
270
271
  For example `"customRanking" => ["desc(population)", "asc(name)"]`
271
272
  * **queryType**: select how the query words are interpreted:
272
- * **prefixAll**: all query words are interpreted as prefixes (default behavior).
273
- * **prefixLast**: only the last word is interpreted as a prefix. This option is recommended if you have a lot of content to speedup the processing.
273
+ * **prefixAll**: all query words are interpreted as prefixes,
274
+ * **prefixLast**: only the last word is interpreted as a prefix (default behavior),
274
275
  * **prefixNone**: no query word is interpreted as a prefix. This option is not recommended.
275
276
 
276
277
  You can easily retrieve settings or update them:
data/Rakefile CHANGED
@@ -32,8 +32,6 @@ Rake::TestTask.new(:test) do |test|
32
32
  test.verbose = true
33
33
  end
34
34
 
35
- task :default => :test
36
-
37
35
  require 'rdoc/task'
38
36
  Rake::RDocTask.new do |rdoc|
39
37
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
@@ -42,3 +40,8 @@ Rake::RDocTask.new do |rdoc|
42
40
  rdoc.rdoc_files.include('README*')
43
41
  rdoc.rdoc_files.include('lib/**/*.rb')
44
42
  end
43
+
44
+ require 'rspec/core/rake_task'
45
+ RSpec::Core::RakeTask.new(:spec)
46
+
47
+ task :default => :spec
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.2
1
+ 1.1.3
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "algoliasearch"
8
- s.version = "1.1.2"
8
+ s.version = "1.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Algolia"]
12
- s.date = "2013-10-02"
12
+ s.date = "2013-10-15"
13
13
  s.description = "A simple Ruby client for the algolia.com REST API"
14
14
  s.email = "contact@algolia.com"
15
15
  s.extra_rdoc_files = [
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
18
18
  ]
19
19
  s.files = [
20
20
  ".rspec",
21
+ ".travis.yml",
21
22
  "Gemfile",
22
23
  "Gemfile.lock",
23
24
  "LICENSE.txt",
@@ -47,15 +48,18 @@ Gem::Specification.new do |s|
47
48
  s.add_runtime_dependency(%q<curb>, [">= 0"])
48
49
  s.add_development_dependency(%q<bundler>, [">= 0"])
49
50
  s.add_development_dependency(%q<jeweler>, [">= 0"])
51
+ s.add_development_dependency(%q<travis>, [">= 0"])
50
52
  else
51
53
  s.add_dependency(%q<curb>, [">= 0"])
52
54
  s.add_dependency(%q<bundler>, [">= 0"])
53
55
  s.add_dependency(%q<jeweler>, [">= 0"])
56
+ s.add_dependency(%q<travis>, [">= 0"])
54
57
  end
55
58
  else
56
59
  s.add_dependency(%q<curb>, [">= 0"])
57
60
  s.add_dependency(%q<bundler>, [">= 0"])
58
61
  s.add_dependency(%q<jeweler>, [">= 0"])
62
+ s.add_dependency(%q<travis>, [">= 0"])
59
63
  end
60
64
  end
61
65
 
@@ -7,33 +7,17 @@ module Algolia
7
7
  # A class which encapsulates the HTTPS communication with the Algolia
8
8
  # API server. Uses the Curb (Curl) library for low-level HTTP communication.
9
9
  class Client
10
- attr_accessor :hosts
11
- attr_accessor :ssl
12
- attr_accessor :application_id
13
- attr_accessor :api_key
10
+ attr_reader :hosts
11
+ attr_reader :application_id
12
+ attr_reader :api_key
14
13
 
15
14
  def initialize(data = {})
16
15
  @ssl = data[:ssl].nil? ? true : data[:ssl]
17
16
  @application_id = data[:application_id]
18
17
  @api_key = data[:api_key]
19
18
  @gzip = data[:gzip].nil? ? false : data[:gzip]
20
- rhosts = (data[:hosts] || 1.upto(3).map { |i| "#{@application_id}-#{i}.algolia.io" }).shuffle
21
-
22
- @hosts = []
23
- rhosts.each do |host|
24
- hinfo = {}
25
- hinfo["base_url"] = "http#{@ssl ? 's' : ''}://#{host}"
26
- hinfo["host"] = host
27
- hinfo["session"] = Curl::Easy.new(@base_url) do |s|
28
- s.headers[Protocol::HEADER_API_KEY] = @api_key
29
- s.headers[Protocol::HEADER_APP_ID] = @application_id
30
- s.headers["Content-Type"] = "application/json; charset=utf-8"
31
- s.headers["Accept"] = "Accept-Encoding: gzip,deflate" if @gzip
32
- s.headers["User-Agent"] = "Algolia for Ruby"
33
- s.verbose = true if data[:debug]
34
- end
35
- @hosts << hinfo
36
- end
19
+ @hosts = (data[:hosts] || 1.upto(3).map { |i| "#{@application_id}-#{i}.algolia.io" }).shuffle
20
+ @debug = data[:debug]
37
21
  end
38
22
 
39
23
  # Perform an HTTP request for the given uri and method
@@ -41,7 +25,7 @@ module Algolia
41
25
  # AlgoliaProtocolError if the response has an error status code,
42
26
  # and will return the parsed JSON body on success, if there is one.
43
27
  def request(uri, method, data = nil)
44
- @hosts.each do |host|
28
+ thread_local_hosts.each do |host|
45
29
  begin
46
30
  session = host["session"]
47
31
  session.url = host["base_url"] + uri
@@ -86,6 +70,29 @@ module Algolia
86
70
  request(uri, :DELETE)
87
71
  end
88
72
 
73
+ private
74
+
75
+ # this method returns a thread-local array of sessions
76
+ def thread_local_hosts
77
+ if Thread.current[:hosts].nil?
78
+ Thread.current[:hosts] = hosts.map do |host|
79
+ hinfo = {}
80
+ hinfo["base_url"] = "http#{@ssl ? 's' : ''}://#{host}"
81
+ hinfo["host"] = host
82
+ hinfo["session"] = Curl::Easy.new do |s|
83
+ s.headers[Protocol::HEADER_API_KEY] = api_key
84
+ s.headers[Protocol::HEADER_APP_ID] = application_id
85
+ s.headers["Content-Type"] = "application/json; charset=utf-8"
86
+ s.headers["Accept"] = "Accept-Encoding: gzip,deflate" if @gzip
87
+ s.headers["User-Agent"] = "Algolia for Ruby"
88
+ s.verbose = true if @debug
89
+ end
90
+ hinfo
91
+ end
92
+ end
93
+ Thread.current[:hosts]
94
+ end
95
+
89
96
  end
90
97
 
91
98
  # Module methods
data/lib/algolia/index.rb CHANGED
@@ -89,9 +89,9 @@ module Algolia
89
89
  # of words to return (syntax is 'attributeName:nbWords').
90
90
  # Attributes are separated by a comma (Example: "attributesToSnippet=name:10,content:10").
91
91
  # By default no snippet is computed.
92
- # - minWordSizeForApprox1: the minimum number of characters in a query word to accept one typo in this word.
92
+ # - minWordSizefor1Typo: the minimum number of characters in a query word to accept one typo in this word.
93
93
  # Defaults to 3.
94
- # - minWordSizeForApprox2: the minimum number of characters in a query word to accept two typos in this word.
94
+ # - minWordSizefor2Typos: the minimum number of characters in a query word to accept two typos in this word.
95
95
  # Defaults to 7.
96
96
  # - getRankingInfo: if set to 1, the result hits will contain ranking information in
97
97
  # _rankingInfo attribute
@@ -106,8 +106,8 @@ module Algolia
106
106
  # For example insideBoundingBox=47.3165,4.9665,47.3424,5.0201).
107
107
  # At indexing, geoloc of an object should be set with _geoloc attribute containing lat and lng attributes (for example {"_geoloc":{"lat":48.853409, "lng":2.348800}})
108
108
  # - queryType: select how the query words are interpreted:
109
- # - prefixAll: all query words are interpreted as prefixes (default behavior).
110
- # - prefixLast: only the last word is interpreted as a prefix. This option is recommended if you have a lot of content to speedup the processing.
109
+ # - prefixAll: all query words are interpreted as prefixes,
110
+ # - prefixLast: only the last word is interpreted as a prefix (default behavior),
111
111
  # - prefixNone: no query word is interpreted as a prefix. This option is not recommended.
112
112
  # - tags filter the query by a set of tags. You can AND tags by separating them by commas. To OR tags, you must add parentheses. For example, tags=tag1,(tag2,tag3) means tag1 AND (tag2 OR tag3).
113
113
  # At indexing, tags should be added in the _tags attribute of objects (for example {"_tags":["tag1","tag2"]} )
@@ -236,8 +236,8 @@ module Algolia
236
236
  # Set settings for this index
237
237
  #
238
238
  # @param settigns the settings object that can contains :
239
- # - minWordSizeForApprox1 (integer) the minimum number of characters to accept one typo (default = 3)
240
- # - minWordSizeForApprox2: (integer) the minimum number of characters to accept two typos (default = 7)
239
+ # - minWordSizefor1Typo (integer) the minimum number of characters to accept one typo (default = 3)
240
+ # - minWordSizefor2Typos: (integer) the minimum number of characters to accept two typos (default = 7)
241
241
  # - hitsPerPage: (integer) the number of hits per page (default = 10)
242
242
  # - attributesToRetrieve: (array of strings) default list of attributes to retrieve for objects
243
243
  # - attributesToHighlight: (array of strings) default list of attributes to highlight
@@ -253,6 +253,9 @@ module Algolia
253
253
  # - Control part of the ranking (see the ranking parameter for full explanation).
254
254
  # Matches in attributes at the beginning of the list will be considered more important than matches
255
255
  # in attributes further down the list.
256
+ # In one attribute, matching text at the beginning of the attribute will be considered more important than text after,
257
+ # you can disable this behavior if you add your attribute inside `unordered(AttributeName)`,
258
+ # for example `attributesToIndex:["title", "unordered(text)"]`.
256
259
  # - ranking: (array of strings) controls the way results are sorted.
257
260
  # We have four available criteria:
258
261
  # - typo (sort according to number of typos),
@@ -263,8 +266,8 @@ module Algolia
263
266
  # - custom which is user defined
264
267
  # (the standard order is ["typo", "geo", "proximity", "attribute", "exact", "custom"])
265
268
  # - queryType: select how the query words are interpreted:
266
- # - prefixAll: all query words are interpreted as prefixes (default behavior).
267
- # - prefixLast: only the last word is interpreted as a prefix. This option is recommended if you have a lot of content to speedup the processing.
269
+ # - prefixAll: all query words are interpreted as prefixes,
270
+ # - prefixLast: only the last word is interpreted as a prefix (default behavior),
268
271
  # - prefixNone: no query word is interpreted as a prefix. This option is not recommended.
269
272
  # - customRanking: (array of strings) lets you specify part of the ranking.
270
273
  # The syntax of this condition is an array of strings containing attributes prefixed
data/spec/client_spec.rb CHANGED
@@ -26,4 +26,18 @@ describe 'Client' do
26
26
  expect { @index.add_objects!([ [ {:name => "test"} ] ]) }.to raise_error(ArgumentError)
27
27
  end
28
28
 
29
+ it "should be thread safe" do
30
+ threads = []
31
+ 64.times do
32
+ t = Thread.new do
33
+ 10.times do
34
+ res = @index.search("john")
35
+ res["hits"].length.should eq(1)
36
+ end
37
+ end
38
+ threads << t
39
+ end
40
+ threads.each { |t| t.join }
41
+ end
42
+
29
43
  end
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.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Algolia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-02 00:00:00.000000000 Z
11
+ date: 2013-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: curb
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: travis
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  description: A simple Ruby client for the algolia.com REST API
56
70
  email: contact@algolia.com
57
71
  executables: []
@@ -61,6 +75,7 @@ extra_rdoc_files:
61
75
  - README.md
62
76
  files:
63
77
  - .rspec
78
+ - .travis.yml
64
79
  - Gemfile
65
80
  - Gemfile.lock
66
81
  - LICENSE.txt