algoliasearch 1.19.2 → 1.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7415df1901dcf0b5385fb28c1e442dcf0d4dbdbff4daa47ce1373103304a2382
4
- data.tar.gz: ff76387ec82d308e1cd6388ab4f8c33969c086f4a504dc2e122e9fc20004b353
3
+ metadata.gz: 042aa8d5e6c4fd28ca302c2f6599c5ef5ec347a809ad567dde393b6633cba2c3
4
+ data.tar.gz: e99b0315c64bcf650d4496e2ae8a9bd7f0f12f0cb42b31e5209d6359dbe019eb
5
5
  SHA512:
6
- metadata.gz: 7e76676e94d0386306ad19675804020bee0146c1f2dcb2581bb0f7f5a851b25218febed68151da64b2dbf15550fb3f2feae3328a2b206d534f4fe6b566892955
7
- data.tar.gz: 5bedebce436947e4651daaff28cbba69dfc32302f2b515870663fea93fb05e85757ad0f836c20b2e19c31f9891582976fc4a56906ca91f23e98c377fcfb7c34d
6
+ metadata.gz: f184dce817dbe9309f2d97d131ef4738d0aa72e6e8bafb907cb2b182d96f8de367982c34eebffdbbe8ece916a7685fb1b524c01468fc0583f6a09be22a5111f1
7
+ data.tar.gz: d02d20d28c815d707fae14725ae5c0c1add7e056c0f2086ea18ba50d5d8f20e9cac8b06a5b35439d0ae2c13abe392e7e255c1636e9866f8cf14cdb255b5d1335
data/.travis.yml CHANGED
@@ -14,11 +14,11 @@ rvm:
14
14
  - 2.4.1
15
15
  - 2.5.0
16
16
  - jruby
17
- - rbx-2
17
+ - rbx-3
18
18
 
19
19
  matrix:
20
20
  allow_failures:
21
- - rvm: rbx-2
21
+ - rvm: rbx-3
22
22
  - rvm: jruby
23
23
 
24
24
  cache: bundler
data/ChangeLog CHANGED
@@ -1,4 +1,12 @@
1
- CHANGELOG
1
+ 2018-05-07 1.20.0
2
+ * Feat: deprecate api keys methods on index in favor of client ones (#286)
3
+ * Chore(gemfile): remove useless dependencies (#280)
4
+ * Fix(env): adding default env var (#279)
5
+ * Chore(travis): test against rubinius 3 (#281)
6
+ * Fix: prevent saving a rule with an empty objectid (#283)
7
+
8
+ 2018-04-03 1.19.2
9
+ * Fix Algolia.delete_index wrong number of arguments (#277)
2
10
 
3
11
  2017-12-18 1.19.1
4
12
  * Fix hard dependency on `hashdiff` (#262)
data/Gemfile CHANGED
@@ -6,25 +6,24 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
6
  gemspec
7
7
 
8
8
  # See https://github.com/algolia/algoliasearch-client-ruby/pull/257/files/36bcd0b1c4d05776dcbdb362c15a609c81f41cde
9
- if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('1.9.3')
9
+ if Gem::Version.new(RUBY_VERSION) <= Gem::Version.new('1.9.3')
10
10
  gem 'hashdiff', '< 0.3.6' # Hashdiff 0.3.6 no longer supports Ruby 1.8
11
+ gem 'highline', '< 1.7.0'
12
+ gem 'mime-types', '< 2.0'
13
+ gem 'rubysl', '~> 2.0', :platform => :rbx
14
+ else
15
+ gem 'rubysl', '~> 2.2', :platform => :rbx
11
16
  end
12
17
 
13
- gem 'rubysl', '~> 2.0', :platform => :rbx
14
-
15
18
  group :development do
16
- gem 'highline', '< 1.7.0'
17
19
  gem 'coveralls'
18
- gem 'safe_yaml'
19
- gem 'travis'
20
20
  gem 'rake'
21
21
  gem 'rdoc'
22
+ gem 'travis'
22
23
  end
23
24
 
24
25
  group :test do
25
26
  gem 'rspec', '>= 2.5.0'
26
- gem 'redgreen'
27
27
  gem 'webmock'
28
28
  gem 'simplecov'
29
- gem 'mime-types'
30
29
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- algoliasearch (1.19.1)
4
+ algoliasearch (1.20.0)
5
5
  httpclient (~> 2.8, >= 2.8.3)
6
6
  json (>= 1.5.1)
7
7
 
@@ -9,7 +9,7 @@ GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
11
  addressable (2.4.0)
12
- backports (3.11.1)
12
+ backports (3.11.2)
13
13
  coveralls (0.7.2)
14
14
  multi_json (~> 1.3)
15
15
  rest-client (= 1.6.7)
@@ -19,7 +19,7 @@ GEM
19
19
  crack (0.4.3)
20
20
  safe_yaml (~> 1.0.0)
21
21
  diff-lcs (1.3)
22
- docile (1.1.5)
22
+ docile (1.3.0)
23
23
  ethon (0.11.0)
24
24
  ffi (>= 1.3.0)
25
25
  faraday (0.14.0)
@@ -41,9 +41,7 @@ GEM
41
41
  json (2.1.0)
42
42
  launchy (2.4.3)
43
43
  addressable (~> 2.3)
44
- mime-types (3.1)
45
- mime-types-data (~> 3.2015)
46
- mime-types-data (3.2016.0521)
44
+ mime-types (1.25.1)
47
45
  multi_json (1.13.1)
48
46
  multipart-post (2.0.0)
49
47
  net-http-persistent (2.9.4)
@@ -51,9 +49,8 @@ GEM
51
49
  pusher-client (0.6.2)
52
50
  json
53
51
  websocket (~> 1.0)
54
- rake (12.3.0)
55
- rdoc (6.0.1)
56
- redgreen (1.2.2)
52
+ rake (12.3.1)
53
+ rdoc (6.0.3)
57
54
  rest-client (1.6.7)
58
55
  mime-types (>= 1.16)
59
56
  rspec (3.7.0)
@@ -272,8 +269,8 @@ GEM
272
269
  rubysl-yaml (2.1.0)
273
270
  rubysl-zlib (2.0.1)
274
271
  safe_yaml (1.0.4)
275
- simplecov (0.15.1)
276
- docile (~> 1.1.0)
272
+ simplecov (0.16.1)
273
+ docile (~> 1.1)
277
274
  json (>= 1.8, < 3)
278
275
  simplecov-html (~> 0.10.0)
279
276
  simplecov-html (0.10.2)
@@ -304,14 +301,10 @@ PLATFORMS
304
301
  DEPENDENCIES
305
302
  algoliasearch!
306
303
  coveralls
307
- highline (< 1.7.0)
308
- mime-types
309
304
  rake
310
305
  rdoc
311
- redgreen
312
306
  rspec (>= 2.5.0)
313
- rubysl (~> 2.0)
314
- safe_yaml
307
+ rubysl (~> 2.2)
315
308
  simplecov
316
309
  travis
317
310
  webmock
data/README.md CHANGED
@@ -20,9 +20,6 @@ If you are a **Ruby on Rails** user, you are probably looking for the [algoliase
20
20
  You can find the full reference on [Algolia's website](https://www.algolia.com/doc/api-client/ruby/).
21
21
 
22
22
 
23
- ## Table of Contents
24
-
25
-
26
23
 
27
24
  1. **[Install](#install)**
28
25
 
@@ -74,9 +71,9 @@ You can find both on [your Algolia account](https://www.algolia.com/api-keys).
74
71
  require 'rubygems'
75
72
  require 'algoliasearch'
76
73
 
77
- Algolia.init application_id: 'YourApplicationID',
78
- api_key: 'YourAPIKey'
79
- index = Algolia::Index.new("your_index_name")
74
+ Algolia.init(application_id: 'YourApplicationID',
75
+ api_key: 'YourAPIKey')
76
+ index = Algolia::Index.new('your_index_name')
80
77
  ```
81
78
 
82
79
  ## Push data
@@ -210,8 +207,6 @@ search.start();
210
207
 
211
208
 
212
209
 
213
-
214
-
215
210
  ### Search
216
211
 
217
212
  - [Search an index](https://algolia.com/doc/api-reference/api-methods/search/?language=ruby)
@@ -222,18 +217,15 @@ search.start();
222
217
 
223
218
 
224
219
 
225
-
226
220
  ### Indexing
227
221
 
228
222
  - [Add objects](https://algolia.com/doc/api-reference/api-methods/add-objects/?language=ruby)
229
223
  - [Update objects](https://algolia.com/doc/api-reference/api-methods/update-objects/?language=ruby)
230
224
  - [Partial update objects](https://algolia.com/doc/api-reference/api-methods/partial-update-objects/?language=ruby)
231
225
  - [Delete objects](https://algolia.com/doc/api-reference/api-methods/delete-objects/?language=ruby)
232
- - [Delete by query](https://algolia.com/doc/api-reference/api-methods/delete-by-query/?language=ruby)
226
+ - [Delete by](https://algolia.com/doc/api-reference/api-methods/delete-by/?language=ruby)
233
227
  - [Get objects](https://algolia.com/doc/api-reference/api-methods/get-objects/?language=ruby)
234
228
  - [Custom batch](https://algolia.com/doc/api-reference/api-methods/batch/?language=ruby)
235
- - [Wait for operations](https://algolia.com/doc/api-reference/api-methods/wait-task/?language=ruby)
236
-
237
229
 
238
230
 
239
231
 
@@ -246,7 +238,6 @@ search.start();
246
238
 
247
239
 
248
240
 
249
-
250
241
  ### Manage indices
251
242
 
252
243
  - [List indexes](https://algolia.com/doc/api-reference/api-methods/list-indices/?language=ruby)
@@ -258,7 +249,6 @@ search.start();
258
249
 
259
250
 
260
251
 
261
-
262
252
  ### API Keys
263
253
 
264
254
  - [Create secured API Key](https://algolia.com/doc/api-reference/api-methods/generate-secured-api-key/?language=ruby)
@@ -271,7 +261,6 @@ search.start();
271
261
 
272
262
 
273
263
 
274
-
275
264
  ### Synonyms
276
265
 
277
266
  - [Save synonym](https://algolia.com/doc/api-reference/api-methods/save-synonym/?language=ruby)
@@ -285,12 +274,11 @@ search.start();
285
274
 
286
275
 
287
276
 
288
-
289
277
  ### Query rules
290
278
 
291
279
  - [Save a single rule](https://algolia.com/doc/api-reference/api-methods/rules-save/?language=ruby)
292
280
  - [Batch save multiple rules](https://algolia.com/doc/api-reference/api-methods/rules-save-batch/?language=ruby)
293
- - [Read a rule](https://algolia.com/doc/api-reference/api-methods/rules-read/?language=ruby)
281
+ - [Get a rule](https://algolia.com/doc/api-reference/api-methods/rules-get/?language=ruby)
294
282
  - [Delete a single rule](https://algolia.com/doc/api-reference/api-methods/rules-delete/?language=ruby)
295
283
  - [Clear all rules](https://algolia.com/doc/api-reference/api-methods/rules-clear/?language=ruby)
296
284
  - [Search for rules](https://algolia.com/doc/api-reference/api-methods/rules-search/?language=ruby)
@@ -299,13 +287,25 @@ search.start();
299
287
 
300
288
 
301
289
 
290
+ ### MultiClusters
291
+
292
+ - [Assign or Move userID](https://algolia.com/doc/api-reference/api-methods/assign-user-id/?language=ruby)
293
+ - [Get top userID](https://algolia.com/doc/api-reference/api-methods/get-top-user-id/?language=ruby)
294
+ - [Get userID](https://algolia.com/doc/api-reference/api-methods/get-user-id/?language=ruby)
295
+ - [List clusters](https://algolia.com/doc/api-reference/api-methods/list-clusters/?language=ruby)
296
+ - [List userIDs](https://algolia.com/doc/api-reference/api-methods/list-user-id/?language=ruby)
297
+ - [Remove userID](https://algolia.com/doc/api-reference/api-methods/remove-user-id/?language=ruby)
298
+ - [Search userID](https://algolia.com/doc/api-reference/api-methods/search-user-id/?language=ruby)
302
299
 
303
300
 
304
301
 
305
302
 
306
303
  ### Advanced
307
304
 
308
- - [Get latest logs](https://algolia.com/doc/api-reference/api-methods/get-logs/?language=ruby)
305
+ - [Get logs](https://algolia.com/doc/api-reference/api-methods/get-logs/?language=ruby)
306
+ - [Configuring timeouts](https://algolia.com/doc/api-reference/api-methods/configuring-timeouts/?language=ruby)
307
+ - [Set extra header](https://algolia.com/doc/api-reference/api-methods/set-extra-header/?language=ruby)
308
+ - [Wait for operations](https://algolia.com/doc/api-reference/api-methods/wait-task/?language=ruby)
309
309
 
310
310
 
311
311
 
@@ -505,11 +505,12 @@ module Algolia
505
505
  # Always use Algolia.client to retrieve the client object.
506
506
  @@client = nil
507
507
 
508
- # Initialize the singleton instance of Client which is used
509
- # by all API methods.
508
+ #
509
+ # Initialize the singleton instance of Client which is used by all API methods
510
+ #
510
511
  def Algolia.init(options = {})
511
- application_id = ENV["ALGOLIA_API_ID"] || ENV["ALGOLIA_APPLICATION_ID"]
512
- api_key = ENV["ALGOLIA_REST_API_KEY"] || ENV['ALGOLIA_API_KEY']
512
+ application_id = ENV['ALGOLIA_APP_ID'] || ENV['ALGOLIA_API_ID'] || ENV['ALGOLIA_APPLICATION_ID']
513
+ api_key = ENV['ALGOLIA_REST_API_KEY'] || ENV['ALGOLIA_API_KEY']
513
514
 
514
515
  defaulted = { :application_id => application_id, :api_key => api_key }
515
516
  defaulted.merge!(options)
data/lib/algolia/index.rb CHANGED
@@ -531,11 +531,15 @@ module Algolia
531
531
  end
532
532
 
533
533
  # List all existing user keys with their associated ACLs
534
+ #
535
+ # Deprecated: Please us `client.list_api_keys` instead.
534
536
  def list_api_keys(request_options = {})
535
537
  client.get(Protocol.index_keys_uri(name), :read, request_options)
536
538
  end
537
539
 
538
540
  # Get ACL of a user key
541
+ #
542
+ # Deprecated: Please us `client.get_api_key` instead.
539
543
  def get_api_key(key, request_options = {})
540
544
  client.get(Protocol.index_key_uri(name, key), :read, request_options)
541
545
  end
@@ -566,6 +570,7 @@ module Algolia
566
570
  # @param maxHitsPerQuery the maximum number of hits this API key can retrieve in one call (0 means unlimited)
567
571
  # @param request_options contains extra parameters to send with your query
568
572
  #
573
+ # Deprecated: Please us `client.add_api_key` instead.
569
574
  def add_api_key(obj, validity = 0, maxQueriesPerIPPerHour = 0, maxHitsPerQuery = 0, request_options = {})
570
575
  if obj.instance_of? Array
571
576
  params = {
@@ -612,6 +617,7 @@ module Algolia
612
617
  # @param maxHitsPerQuery the maximum number of hits this API key can retrieve in one call (0 means unlimited)
613
618
  # @param request_options contains extra parameters to send with your query
614
619
  #
620
+ # Deprecated: Please us `client.update_api_key` instead.
615
621
  def update_api_key(key, obj, validity = 0, maxQueriesPerIPPerHour = 0, maxHitsPerQuery = 0, request_options = {})
616
622
  if obj.instance_of? Array
617
623
  params = {
@@ -634,6 +640,8 @@ module Algolia
634
640
 
635
641
 
636
642
  # Delete an existing user key
643
+ #
644
+ # Deprecated: Please us `client.delete_api_key` instead.
637
645
  def delete_api_key(key, request_options = {})
638
646
  client.delete(Protocol.index_key_uri(name, key), :write, request_options)
639
647
  end
@@ -948,6 +956,7 @@ module Algolia
948
956
  # @param forward_to_replicas should we forward the delete to replica indices
949
957
  # @param request_options contains extra parameters to send with your query
950
958
  def save_rule(objectID, rule, forward_to_replicas = false, request_options = {})
959
+ raise ArgumentError.new('objectID must not be blank') if objectID.nil? || objectID == ''
951
960
  client.put("#{Protocol.rule_uri(name, objectID)}?forwardToReplicas=#{forward_to_replicas}", rule.to_json, :write, request_options)
952
961
  end
953
962
 
@@ -1,3 +1,3 @@
1
1
  module Algolia
2
- VERSION = "1.19.2"
2
+ VERSION = "1.20.0"
3
3
  end
data/spec/client_spec.rb CHANGED
@@ -1107,6 +1107,17 @@ describe 'Client' do
1107
1107
  @index.search_rules('')['nbHits'].should eq(0)
1108
1108
  end
1109
1109
 
1110
+ it 'should not save a query rule with an empty objectID' do
1111
+ rule = {
1112
+ :objectID => '',
1113
+ :condition => { :pattern => 'test', :anchoring => 'contains' },
1114
+ :consequence => { :params => { :query => 'this is better' } }
1115
+ }
1116
+
1117
+ expect { @index.save_rule!(nil, rule) }.to raise_error(ArgumentError)
1118
+ expect { @index.save_rule!(rule[:objectID], rule) }.to raise_error(ArgumentError)
1119
+ end
1120
+
1110
1121
  it "should use request options" do
1111
1122
  expect{Algolia.list_indexes}.to_not raise_error
1112
1123
 
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.19.2
4
+ version: 1.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Algolia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-03 00:00:00.000000000 Z
11
+ date: 2018-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient