algoliasearch-rails 1.17.1 → 1.18.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 0bb0ed3c6e61faa93d87f73b3486759e93f6d77b
4
- data.tar.gz: 80bacfec7eb024e61a72196dde014d0cfdecb45d
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NzJhNzkwMzY2NzdkNDAzOTBmY2EyNDU4N2FmYzJiMDlkMTVhYzE4NA==
5
+ data.tar.gz: !binary |-
6
+ ZjBkYjBkOGJiODAwMjM4MzI3YTU4MWEwNGI1NmJlYWM1MzhmNjFiMA==
5
7
  SHA512:
6
- metadata.gz: 803713e7a76f93c14309150aafef6ad66703d1e200ce887234914ea1301841e4225e0ecd001658efe8a3061d9c0857aa208310bfd04ce73267cabf2a35019c88
7
- data.tar.gz: ff9f70b0815494a7847a36a02d1987d18bab009522dc3c86250134412d106f6cee44d7c416a20fed40594fd71b674e009c7001b1d3b7871a82943d045ead4230
8
+ metadata.gz: !binary |-
9
+ YmYwYmU4NTcwMmE1YWZmMWZkOTZjODU5MzhlYWExY2U0ZmFlMmQxNDg5MjFk
10
+ NWY3NmRmMzY5ZTU5MWJjY2Y4ZDgyN2IxM2MxMjc3NzBiZWVkYTFlZTEzYjM4
11
+ YmMxZWU2MmI3ZmQ1NTRhNmQ1YjJiMWVjYmZmOTFhZmIyOTg3MDM=
12
+ data.tar.gz: !binary |-
13
+ YjZhMWQ0YzU0NmQ2YTkwYTYwYzFlNDg1ODdjMjBmMmNiY2RlMmViNTViOGY2
14
+ NGFkOGQ4Y2QyNzhjZGNkNDJjNDZlYjY3MTAyZGZjYTY4YmNhMzI2YTQzODg4
15
+ OWE0NjBlZTdiMmJkYjZlNzVkYmM5MzM2YjU0NTcxNzFjYmJiN2U=
data/.travis.yml CHANGED
@@ -40,6 +40,9 @@ matrix:
40
40
  # env: RAILS_VERSION=5.0
41
41
  allow_failures:
42
42
  - rvm: rbx-2
43
+ before_install:
44
+ - gem install bundler
45
+ - bundle --version
43
46
  install: rm -f Gemfile.lock && bundle install
44
47
  cache: bundler
45
48
  env:
data/ChangeLog CHANGED
@@ -1,5 +1,9 @@
1
1
  CHANGELOG
2
2
 
3
+ 2017-02-16 1.18.0
4
+
5
+ * Add new replica parameter, `inherit` (#198)
6
+
3
7
  2017-01-05 1.17.1
4
8
 
5
9
  * Add missing `disablePrefixOnAttributes` and `disableTypoToleranceOnAttributes` attributes (#193)
data/Gemfile CHANGED
@@ -2,7 +2,10 @@ source "http://rubygems.org"
2
2
 
3
3
  gem 'json', '~> 1.5', '>= 1.5.1'
4
4
  gem 'algoliasearch', '~> 1.12.4'
5
- gem 'rubysl', '~> 2.0', :platform => :rbx
5
+
6
+ if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
7
+ gem 'rubysl', '~> 2.0', :platform => :rbx
8
+ end
6
9
 
7
10
  group :test do
8
11
  rails_version = ENV["RAILS_VERSION"] ? "~> #{ENV["RAILS_VERSION"]}" : '>= 3.2.0'
@@ -47,5 +50,12 @@ end
47
50
 
48
51
  group :test, :development do
49
52
  gem 'will_paginate', '>= 2.3.15'
50
- gem 'kaminari'
53
+ if defined?(RUBY_VERSION) &&
54
+ defined?(RUBY_ENGINE) &&
55
+ RUBY_ENGINE == 'ruby' &&
56
+ Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2')
57
+ gem 'kaminari', '< 1'
58
+ else
59
+ gem 'kaminari'
60
+ end
51
61
  end
data/README.md CHANGED
@@ -2,86 +2,76 @@
2
2
 
3
3
  [Algolia Search](https://www.algolia.com) is a hosted full-text, numerical, and faceted search engine capable of delivering realtime results from the first keystroke.
4
4
 
5
- This gem let you easily integrate the Algolia Search API to your favorite ORM. It's based on the [algoliasearch-client-ruby](https://github.com/algolia/algoliasearch-client-ruby) gem. Rails 3.x, 4.x and 5.x are all supported.
5
+ [![Build Status](https://travis-ci.org/algolia/algoliasearch-rails.svg?branch=master)](https://travis-ci.org/algolia/algoliasearch-rails) [![Gem Version](https://badge.fury.io/rb/algoliasearch-rails.svg)](http://badge.fury.io/rb/algoliasearch-rails) [![Code Climate](https://codeclimate.com/github/algolia/algoliasearch-rails.svg)](https://codeclimate.com/github/algolia/algoliasearch-rails) ![ActiveRecord](https://img.shields.io/badge/ActiveRecord-yes-blue.svg?style=flat-square) ![Mongoid](https://img.shields.io/badge/Mongoid-yes-blue.svg?style=flat-square) ![Sequel](https://img.shields.io/badge/Sequel-yes-blue.svg?style=flat-square)
6
+
7
+
8
+ This gem let you easily integrate the Algolia Search API to your favorite ORM. It's based on the [algoliasearch-client-ruby](https://github.com/algolia/algoliasearch-client-ruby) gem.
9
+ Rails 3.x, 4.x and 5.x are all supported.
6
10
 
7
11
  You might be interested in the sample Ruby on Rails application providing a `autocomplete.js`-based auto-completion and `instantsearch.js`-based instant search results page: [algoliasearch-rails-example](https://github.com/algolia/algoliasearch-rails-example/).
8
12
 
9
- [![Build Status](https://travis-ci.org/algolia/algoliasearch-rails.svg?branch=master)](https://travis-ci.org/algolia/algoliasearch-rails) [![Gem Version](https://badge.fury.io/rb/algoliasearch-rails.svg)](http://badge.fury.io/rb/algoliasearch-rails) [![Code Climate](https://codeclimate.com/github/algolia/algoliasearch-rails.svg)](https://codeclimate.com/github/algolia/algoliasearch-rails) ![ActiveRecord](https://img.shields.io/badge/ActiveRecord-yes-blue.svg?style=flat-square) ![Mongoid](https://img.shields.io/badge/Mongoid-yes-blue.svg?style=flat-square) ![Sequel](https://img.shields.io/badge/Sequel-yes-blue.svg?style=flat-square)
10
13
 
11
14
 
12
- **Note:** An easier-to-read version of this documentation is available on
13
- [Algolia's website](https://www.algolia.com/doc/api-client/rails/).
14
15
 
15
- # Table of Contents
16
+ ## API Documentation
17
+
18
+ You can find the full reference on [Algolia's website](https://www.algolia.com/doc/api-client/rails/).
16
19
 
17
20
 
18
- **Setup**
21
+ ## Table of Contents
19
22
 
20
- 1. [Install](#install)
21
- 1. [Configuration](#configuration)
22
- 1. [Timeouts](#timeouts)
23
- 1. [Notes](#notes)
24
23
 
25
- **Usage**
24
+ 1. **[Setup](#setup)**
26
25
 
27
- 1. [Index Schema](#index-schema)
28
- 1. [Relevancy](#relevancy)
29
- 1. [Indexing](#indexing)
30
- 1. [Frontend Search (realtime experience)](#frontend-search-realtime-experience)
31
- 1. [Backend Search](#backend-search)
32
- 1. [Backend Pagination](#backend-pagination)
33
- 1. [Tags](#tags)
34
- 1. [Faceting](#faceting)
35
- 1. [Faceted search](#faceted-search)
36
- 1. [Group by](#group-by)
37
- 1. [Geo-Search](#geo-search)
26
+ * [Install](#install)
27
+ * [Configuration](#configuration)
28
+ * [Timeouts](#timeouts)
29
+ * [Notes](#notes)
38
30
 
39
- **Options**
31
+ 1. **[Usage](#usage)**
40
32
 
41
- 1. [Auto-indexing & asynchronism](#auto-indexing--asynchronism)
42
- 1. [Custom index name](#custom-index-name)
43
- 1. [Per-environment indices](#per-environment-indices)
44
- 1. [Custom attribute definition](#custom-attribute-definition)
45
- 1. [Nested objects/relations](#nested-objectsrelations)
46
- 1. [Custom `objectID`](#custom-objectid)
47
- 1. [Restrict indexing to a subset of your data](#restrict-indexing-to-a-subset-of-your-data)
48
- 1. [Sanitizer](#sanitizer)
49
- 1. [UTF-8 Encoding](#utf-8-encoding)
50
- 1. [Exceptions](#exceptions)
51
- 1. [Configuration example](#configuration-example)
33
+ * [Index Schema](#index-schema)
34
+ * [Relevancy](#relevancy)
35
+ * [Indexing](#indexing)
36
+ * [Frontend Search (realtime experience)](#frontend-search-realtime-experience)
37
+ * [Backend Search](#backend-search)
38
+ * [Backend Pagination](#backend-pagination)
39
+ * [Tags](#tags)
40
+ * [Faceting](#faceting)
41
+ * [Faceted search](#faceted-search)
42
+ * [Group by](#group-by)
43
+ * [Geo-Search](#geo-search)
52
44
 
53
- **Indices**
45
+ 1. **[Options](#options)**
54
46
 
55
- 1. [Manual indexing](#manual-indexing)
56
- 1. [Manual removal](#manual-removal)
57
- 1. [Reindexing](#reindexing)
58
- 1. [Clearing an index](#clearing-an-index)
59
- 1. [Using the underlying index](#using-the-underlying-index)
60
- 1. [Primary/replica](#primaryreplica)
61
- 1. [Share a single index](#share-a-single-index)
62
- 1. [Target multiple indices](#target-multiple-indices)
47
+ * [Auto-indexing & asynchronism](#auto-indexing--asynchronism)
48
+ * [Custom index name](#custom-index-name)
49
+ * [Per-environment indices](#per-environment-indices)
50
+ * [Custom attribute definition](#custom-attribute-definition)
51
+ * [Nested objects/relations](#nested-objectsrelations)
52
+ * [Custom `objectID`](#custom-objectid)
53
+ * [Restrict indexing to a subset of your data](#restrict-indexing-to-a-subset-of-your-data)
54
+ * [Sanitizer](#sanitizer)
55
+ * [UTF-8 Encoding](#utf-8-encoding)
56
+ * [Exceptions](#exceptions)
57
+ * [Configuration example](#configuration-example)
63
58
 
64
- **Testing**
59
+ 1. **[Indices](#indices)**
65
60
 
66
- 1. [Notes](#notes)
61
+ * [Manual indexing](#manual-indexing)
62
+ * [Manual removal](#manual-removal)
63
+ * [Reindexing](#reindexing)
64
+ * [Clearing an index](#clearing-an-index)
65
+ * [Using the underlying index](#using-the-underlying-index)
66
+ * [Primary/replica](#primaryreplica)
67
+ * [Share a single index](#share-a-single-index)
68
+ * [Target multiple indices](#target-multiple-indices)
67
69
 
70
+ 1. **[Testing](#testing)**
68
71
 
69
- # Guides & Tutorials
72
+ * [Notes](#notes)
70
73
 
71
- Check our [online guides](https://www.algolia.com/doc):
72
74
 
73
- * [Data Formatting](https://www.algolia.com/doc/indexing/formatting-your-data)
74
- * [Import and Synchronize data](https://www.algolia.com/doc/indexing/import-synchronize-data/php)
75
- * [Autocomplete](https://www.algolia.com/doc/search/auto-complete)
76
- * [Instant search page](https://www.algolia.com/doc/search/instant-search)
77
- * [Filtering and Faceting](https://www.algolia.com/doc/search/filtering-faceting)
78
- * [Sorting](https://www.algolia.com/doc/relevance/sorting)
79
- * [Ranking Formula](https://www.algolia.com/doc/relevance/ranking)
80
- * [Typo-Tolerance](https://www.algolia.com/doc/relevance/typo-tolerance)
81
- * [Geo-Search](https://www.algolia.com/doc/geo-search/geo-search-overview)
82
- * [Security](https://www.algolia.com/doc/security/best-security-practices)
83
- * [API-Keys](https://www.algolia.com/doc/security/api-keys)
84
- * [REST API](https://www.algolia.com/doc/rest)
85
75
 
86
76
 
87
77
  # Setup
@@ -922,7 +912,8 @@ index = Contact.index
922
912
 
923
913
  ## Primary/replica
924
914
 
925
- You can define replica indices using the <code>add_replica</code> method:
915
+ You can define replica indices using the <code>add_replica</code> method.
916
+ Use `inherit: true` on the replica block if you want it to inherit from the primary settings.
926
917
 
927
918
  ```ruby
928
919
  class Book < ActiveRecord::Base
@@ -939,7 +930,7 @@ class Book < ActiveRecord::Base
939
930
  end
940
931
 
941
932
  # define a replica index to search by `editor` only
942
- add_replica 'Book_by_editor', per_environment: true do
933
+ add_replica 'Book_by_editor', inherit: true, per_environment: true do
943
934
  searchableAttributes [:editor]
944
935
  end
945
936
  end
@@ -1087,3 +1078,4 @@ end
1087
1078
  ```
1088
1079
 
1089
1080
 
1081
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.17.1
1
+ 1.18.0
@@ -256,13 +256,13 @@ module AlgoliaSearch
256
256
  def add_replica(index_name, options = {}, &block)
257
257
  raise ArgumentError.new('Cannot specify additional replicas on a replica index') if @options[:slave] || @options[:replica]
258
258
  raise ArgumentError.new('No block given') if !block_given?
259
- add_index(index_name, options.merge({ :replica => true }), &block)
259
+ add_index(index_name, options.merge({ :replica => true, :primary_settings => self }), &block)
260
260
  end
261
261
 
262
262
  def add_slave(index_name, options = {}, &block)
263
263
  raise ArgumentError.new('Cannot specify additional slaves on a slave index') if @options[:slave] || @options[:replica]
264
264
  raise ArgumentError.new('No block given') if !block_given?
265
- add_index(index_name, options.merge({ :slave => true }), &block)
265
+ add_index(index_name, options.merge({ :slave => true, :primary_settings => self }), &block)
266
266
  end
267
267
 
268
268
  def additional_indexes
@@ -308,7 +308,7 @@ module AlgoliaSearch
308
308
  begin
309
309
  @index.get_settings(*args)
310
310
  rescue Algolia::AlgoliaError => e
311
- return {} if e.status == 404 # not fatal
311
+ return {} if e.code == 404 # not fatal
312
312
  raise e
313
313
  end
314
314
  end
@@ -725,22 +725,31 @@ module AlgoliaSearch
725
725
 
726
726
  def algolia_ensure_init(options = nil, settings = nil, index_settings = nil)
727
727
  raise ArgumentError.new('No `algoliasearch` block found in your model.') if algoliasearch_settings.nil?
728
+
728
729
  @algolia_indexes ||= {}
730
+
729
731
  options ||= algoliasearch_options
730
732
  settings ||= algoliasearch_settings
733
+
731
734
  return @algolia_indexes[settings] if @algolia_indexes[settings]
735
+
732
736
  @algolia_indexes[settings] = SafeIndex.new(algolia_index_name(options), algoliasearch_options[:raise_on_failure])
737
+
733
738
  current_settings = @algolia_indexes[settings].get_settings rescue nil # if the index doesn't exist
734
- if !algolia_indexing_disabled?(options) && (index_settings || algoliasearch_settings_changed?(current_settings, settings.to_settings))
735
- index_settings ||= settings.to_settings
739
+
740
+ index_settings ||= settings.to_settings
741
+ index_settings = options[:primary_settings].to_settings.merge(index_settings) if options[:inherit]
742
+
743
+ if !algolia_indexing_disabled?(options) && (index_settings || algoliasearch_settings_changed?(current_settings, index_settings))
736
744
  used_slaves = !current_settings.nil? && !current_settings['slaves'].nil?
737
745
  replicas = index_settings.delete(:replicas) ||
738
746
  index_settings.delete('replicas') ||
739
747
  index_settings.delete(:slaves) ||
740
748
  index_settings.delete('slaves')
741
- index_settings[used_slaves ? :slaves : :replicas] = replicas
749
+ index_settings[used_slaves ? :slaves : :replicas] = replicas unless replicas.nil? || options[:inherit]
742
750
  @algolia_indexes[settings].set_settings(index_settings)
743
751
  end
752
+
744
753
  @algolia_indexes[settings]
745
754
  end
746
755
 
metadata CHANGED
@@ -1,111 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: algoliasearch-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.17.1
4
+ version: 1.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Algolia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-01 00:00:00.000000000 Z
11
+ date: 2017-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - ! '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.5.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
26
  version: 1.5.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: algoliasearch
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.12.4
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.12.4
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: will_paginate
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - ! '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: 2.3.15
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: 2.3.15
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: kaminari
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: travis
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
  - !ruby/object:Gem::Dependency
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - ! '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - ! '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rdoc
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - ! '>='
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - ! '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  description: AlgoliaSearch integration to your favorite ORM
@@ -117,9 +117,9 @@ extra_rdoc_files:
117
117
  - LICENSE
118
118
  - README.md
119
119
  files:
120
- - ".document"
121
- - ".rspec"
122
- - ".travis.yml"
120
+ - .document
121
+ - .rspec
122
+ - .travis.yml
123
123
  - ChangeLog
124
124
  - Gemfile
125
125
  - Gemfile.lock
@@ -173,17 +173,17 @@ require_paths:
173
173
  - lib
174
174
  required_ruby_version: !ruby/object:Gem::Requirement
175
175
  requirements:
176
- - - ">="
176
+ - - ! '>='
177
177
  - !ruby/object:Gem::Version
178
178
  version: '0'
179
179
  required_rubygems_version: !ruby/object:Gem::Requirement
180
180
  requirements:
181
- - - ">="
181
+ - - ! '>='
182
182
  - !ruby/object:Gem::Version
183
183
  version: '0'
184
184
  requirements: []
185
185
  rubyforge_project:
186
- rubygems_version: 2.6.8
186
+ rubygems_version: 2.6.10
187
187
  signing_key:
188
188
  specification_version: 4
189
189
  summary: AlgoliaSearch integration to your favorite ORM