algoliasearch-rails 1.25.0 → 2.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.MD +34 -1
- data/Gemfile +9 -36
- data/Gemfile.lock +125 -114
- data/README.md +11 -34
- data/algoliasearch-rails.gemspec +3 -5
- data/lib/algoliasearch/configuration.rb +18 -2
- data/lib/algoliasearch/pagination/kaminari.rb +1 -1
- data/lib/algoliasearch/utilities.rb +1 -1
- data/lib/algoliasearch/version.rb +1 -1
- data/lib/algoliasearch-rails.rb +38 -60
- data/spec/spec_helper.rb +4 -3
- metadata +6 -27
- data/.travis.yml +0 -62
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a93eb9160dcd68998d5f05a33a788a8737888c07d14c3e9fa1d3e36c758b6117
|
4
|
+
data.tar.gz: b397ac486ee7514abd0612bf80f28d37c09299441e1aeb5cf363a9c48d627fd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6b148d577533959db2df41f33169ad9df554287a771057fa5a980e8804ac40282cee2e49f50342de89d08806890766e88f06b94ea7a456496cc637cbdbc4a4a
|
7
|
+
data.tar.gz: 5dcea86a0adfbbef31067f679116873b2e30317950eac88dd9a6e9f9100ccfea1190d630ddd34cbca88d9c05ffa8b01e27550c5e371c0816a12461ccef97fac2
|
data/CHANGELOG.MD
CHANGED
@@ -1,6 +1,39 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
-
## [Unreleased](https://github.com/algolia/algoliasearch-rails/compare/1.
|
3
|
+
## [Unreleased](https://github.com/algolia/algoliasearch-rails/compare/2.1.4...master)
|
4
|
+
|
5
|
+
## [2.1.4](https://github.com/algolia/algoliasearch-rails/compare/2.1.4...2.1.3)
|
6
|
+
### Fixed
|
7
|
+
- File formatting [`#414`](https://github.com/algolia/algoliasearch-rails/pull/414)
|
8
|
+
- Document supported Rails versions [`#407`](https://github.com/algolia/algoliasearch-rails/pull/407)
|
9
|
+
- Fixed error when using `:check_settings => false` [`#413`](https://github.com/algolia/algoliasearch-rails/pull/413)
|
10
|
+
|
11
|
+
### Removed
|
12
|
+
- Old references to TravisCI [`#408`](https://github.com/algolia/algoliasearch-rails/pull/408)
|
13
|
+
|
14
|
+
## [2.1.3](https://github.com/algolia/algoliasearch-rails/compare/2.1.3...2.1.2)
|
15
|
+
### Fixed
|
16
|
+
- Prevent an extra get_settings call even if `check_settings` is false [`#367`](https://github.com/algolia/algoliasearch-rails/pull/367)
|
17
|
+
|
18
|
+
## [2.1.2](https://github.com/algolia/algoliasearch-rails/compare/2.1.2...2.1.1)
|
19
|
+
### Fixed
|
20
|
+
- Error with keys that got symbolized by default [`#403`](https://github.com/algolia/algoliasearch-rails/pull/403)
|
21
|
+
|
22
|
+
## [2.1.1](https://github.com/algolia/algoliasearch-rails/compare/2.1.1...2.1.0)
|
23
|
+
### Fixed
|
24
|
+
- Error with Ruby 3 in regards to default splat behavior [`#400`](https://github.com/algolia/algoliasearch-rails/pull/400)
|
25
|
+
|
26
|
+
## [2.1.0](https://github.com/algolia/algoliasearch-rails/compare/2.1.0...2.0.0)
|
27
|
+
### Added
|
28
|
+
- Add support for [virtual replicas](https://www.algolia.com/doc/guides/managing-results/refine-results/sorting/in-depth/replicas/#what-are-virtual-replicas) ([#386](https://github.com/algolia/algoliasearch-rails/pull/386))
|
29
|
+
|
30
|
+
|
31
|
+
## [2.0.0](https://github.com/algolia/algoliasearch-rails/compare/2.0.0...1.25.0)
|
32
|
+
|
33
|
+
### Breaking changes
|
34
|
+
- Adds support for `algolia` gem.
|
35
|
+
- Drops support for Ruby < 2.4
|
36
|
+
- Drops support for Rails < 5.1
|
4
37
|
|
5
38
|
## [1.25.0](https://github.com/algolia/algoliasearch-rails/compare/1.24.1...1.25.0) (2020-11-24)
|
6
39
|
|
data/Gemfile
CHANGED
@@ -1,41 +1,22 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
|
3
|
-
gem 'json', '
|
4
|
-
gem '
|
3
|
+
gem 'json', '>= 1.5.1'
|
4
|
+
gem 'algolia', '< 3.0.0'
|
5
5
|
|
6
6
|
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
|
7
7
|
gem 'rubysl', '~> 2.0', :platform => :rbx
|
8
8
|
end
|
9
9
|
|
10
10
|
group :test do
|
11
|
-
rails_version = ENV["RAILS_VERSION"]
|
12
|
-
gem 'rails', rails_version
|
11
|
+
rails_version = ENV["RAILS_VERSION"] || '6.1'
|
12
|
+
gem 'rails', "~> #{rails_version}"
|
13
13
|
gem 'active_model_serializers'
|
14
|
-
if
|
15
|
-
gem '
|
16
|
-
|
17
|
-
gem '
|
18
|
-
gem 'rack-cache', '< 1.3'
|
19
|
-
gem 'mime-types', '< 2.6'
|
20
|
-
gem 'net-http-persistent', '< 3.0'
|
21
|
-
gem 'faraday', '< 0.10'
|
22
|
-
elsif defined?(RUBY_VERSION) && RUBY_VERSION == "1.9.3"
|
23
|
-
gem 'rack', '< 2'
|
24
|
-
gem 'rack-cache', '<= 1.7.1'
|
25
|
-
if Gem::Version.new(ENV['RAILS_VERSION'] || '3.2.0') >= Gem::Version.new('4.0')
|
26
|
-
gem 'mime-types', '~> 2.6'
|
27
|
-
else
|
28
|
-
gem 'mime-types', '< 3'
|
29
|
-
end
|
30
|
-
end
|
31
|
-
if defined?(RUBY_VERSION) &&
|
32
|
-
defined?(RUBY_ENGINE) &&
|
33
|
-
RUBY_ENGINE == 'ruby' &&
|
34
|
-
Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.1')
|
35
|
-
gem 'net-http-persistent', '< 3.0'
|
14
|
+
if Gem::Version.new(rails_version) >= Gem::Version.new('6.0')
|
15
|
+
gem 'sqlite3', '~> 1.4.0', :platform => [:rbx, :ruby]
|
16
|
+
else
|
17
|
+
gem 'sqlite3', '< 1.4.0', :platform => [:rbx, :ruby]
|
36
18
|
end
|
37
19
|
gem 'rspec', '>= 2.5.0', '< 3.0'
|
38
|
-
gem 'sqlite3', '< 1.4.0', :platform => [:rbx, :ruby]
|
39
20
|
gem 'jdbc-sqlite3', :platform => :jruby
|
40
21
|
gem 'activerecord-jdbc-adapter', :platform => :jruby
|
41
22
|
gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
|
@@ -46,20 +27,12 @@ group :test do
|
|
46
27
|
end
|
47
28
|
|
48
29
|
group :development do
|
49
|
-
gem 'travis'
|
50
30
|
gem 'rake', '~> 10.1.0'
|
51
31
|
gem 'rdoc'
|
52
32
|
end
|
53
33
|
|
54
34
|
group :test, :development do
|
55
35
|
gem 'will_paginate', '>= 2.3.15'
|
56
|
-
|
57
|
-
defined?(RUBY_ENGINE) &&
|
58
|
-
RUBY_ENGINE == 'ruby' &&
|
59
|
-
Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2')
|
60
|
-
gem 'kaminari', '< 1'
|
61
|
-
else
|
62
|
-
gem 'kaminari'
|
63
|
-
end
|
36
|
+
gem 'kaminari', '< 1'
|
64
37
|
end
|
65
38
|
|
data/Gemfile.lock
CHANGED
@@ -1,153 +1,162 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
actioncable (
|
5
|
-
actionpack (=
|
4
|
+
actioncable (6.1.3.1)
|
5
|
+
actionpack (= 6.1.3.1)
|
6
|
+
activesupport (= 6.1.3.1)
|
6
7
|
nio4r (~> 2.0)
|
7
8
|
websocket-driver (>= 0.6.1)
|
8
|
-
|
9
|
-
actionpack (=
|
10
|
-
|
11
|
-
|
9
|
+
actionmailbox (6.1.3.1)
|
10
|
+
actionpack (= 6.1.3.1)
|
11
|
+
activejob (= 6.1.3.1)
|
12
|
+
activerecord (= 6.1.3.1)
|
13
|
+
activestorage (= 6.1.3.1)
|
14
|
+
activesupport (= 6.1.3.1)
|
15
|
+
mail (>= 2.7.1)
|
16
|
+
actionmailer (6.1.3.1)
|
17
|
+
actionpack (= 6.1.3.1)
|
18
|
+
actionview (= 6.1.3.1)
|
19
|
+
activejob (= 6.1.3.1)
|
20
|
+
activesupport (= 6.1.3.1)
|
12
21
|
mail (~> 2.5, >= 2.5.4)
|
13
22
|
rails-dom-testing (~> 2.0)
|
14
|
-
actionpack (
|
15
|
-
actionview (=
|
16
|
-
activesupport (=
|
17
|
-
rack (~> 2.0, >= 2.0.
|
23
|
+
actionpack (6.1.3.1)
|
24
|
+
actionview (= 6.1.3.1)
|
25
|
+
activesupport (= 6.1.3.1)
|
26
|
+
rack (~> 2.0, >= 2.0.9)
|
18
27
|
rack-test (>= 0.6.3)
|
19
28
|
rails-dom-testing (~> 2.0)
|
20
|
-
rails-html-sanitizer (~> 1.0, >= 1.0
|
21
|
-
|
22
|
-
|
29
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
30
|
+
actiontext (6.1.3.1)
|
31
|
+
actionpack (= 6.1.3.1)
|
32
|
+
activerecord (= 6.1.3.1)
|
33
|
+
activestorage (= 6.1.3.1)
|
34
|
+
activesupport (= 6.1.3.1)
|
35
|
+
nokogiri (>= 1.8.5)
|
36
|
+
actionview (6.1.3.1)
|
37
|
+
activesupport (= 6.1.3.1)
|
23
38
|
builder (~> 3.1)
|
24
39
|
erubi (~> 1.4)
|
25
40
|
rails-dom-testing (~> 2.0)
|
26
|
-
rails-html-sanitizer (~> 1.
|
27
|
-
active_model_serializers (0.10.
|
28
|
-
actionpack (>= 4.1, < 6.
|
29
|
-
activemodel (>= 4.1, < 6.
|
41
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
42
|
+
active_model_serializers (0.10.12)
|
43
|
+
actionpack (>= 4.1, < 6.2)
|
44
|
+
activemodel (>= 4.1, < 6.2)
|
30
45
|
case_transform (>= 0.2)
|
31
46
|
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
|
32
|
-
activejob (
|
33
|
-
activesupport (=
|
47
|
+
activejob (6.1.3.1)
|
48
|
+
activesupport (= 6.1.3.1)
|
34
49
|
globalid (>= 0.3.6)
|
35
|
-
activemodel (
|
36
|
-
activesupport (=
|
37
|
-
activerecord (
|
38
|
-
activemodel (=
|
39
|
-
activesupport (=
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
activerecord (=
|
44
|
-
|
45
|
-
|
50
|
+
activemodel (6.1.3.1)
|
51
|
+
activesupport (= 6.1.3.1)
|
52
|
+
activerecord (6.1.3.1)
|
53
|
+
activemodel (= 6.1.3.1)
|
54
|
+
activesupport (= 6.1.3.1)
|
55
|
+
activestorage (6.1.3.1)
|
56
|
+
actionpack (= 6.1.3.1)
|
57
|
+
activejob (= 6.1.3.1)
|
58
|
+
activerecord (= 6.1.3.1)
|
59
|
+
activesupport (= 6.1.3.1)
|
60
|
+
marcel (~> 1.0.0)
|
61
|
+
mini_mime (~> 1.0.2)
|
62
|
+
activesupport (6.1.3.1)
|
46
63
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
47
|
-
i18n (>=
|
48
|
-
minitest (
|
49
|
-
tzinfo (~>
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
64
|
+
i18n (>= 1.6, < 2)
|
65
|
+
minitest (>= 5.1)
|
66
|
+
tzinfo (~> 2.0)
|
67
|
+
zeitwerk (~> 2.3)
|
68
|
+
addressable (2.4.0)
|
69
|
+
algolia (2.0.4)
|
70
|
+
faraday (>= 0.15, < 2.0)
|
71
|
+
multi_json (~> 1.0)
|
72
|
+
net-http-persistent
|
73
|
+
backports (3.21.0)
|
56
74
|
builder (3.2.4)
|
57
75
|
case_transform (0.2)
|
58
76
|
activesupport
|
59
|
-
concurrent-ruby (1.1.
|
77
|
+
concurrent-ruby (1.1.8)
|
60
78
|
crass (1.0.6)
|
61
79
|
diff-lcs (1.4.4)
|
62
|
-
erubi (1.
|
63
|
-
|
80
|
+
erubi (1.10.0)
|
81
|
+
ethon (0.13.0)
|
82
|
+
ffi (>= 1.15.0)
|
83
|
+
faraday (0.17.4)
|
64
84
|
multipart-post (>= 1.2, < 3)
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
gh (0.
|
69
|
-
|
70
|
-
|
71
|
-
faraday (~>
|
72
|
-
faraday_middleware (~> 1.0)
|
85
|
+
faraday_middleware (0.14.0)
|
86
|
+
faraday (>= 0.7.4, < 1.0)
|
87
|
+
ffi (1.15.0)
|
88
|
+
gh (0.15.1)
|
89
|
+
addressable (~> 2.4.0)
|
90
|
+
backports
|
91
|
+
faraday (~> 0.8)
|
73
92
|
multi_json (~> 1.0)
|
74
93
|
net-http-persistent (~> 2.9)
|
75
94
|
net-http-pipeline
|
76
95
|
globalid (0.4.2)
|
77
96
|
activesupport (>= 4.2.0)
|
78
|
-
highline (
|
79
|
-
|
80
|
-
i18n (1.8.5)
|
97
|
+
highline (1.7.10)
|
98
|
+
i18n (1.8.10)
|
81
99
|
concurrent-ruby (~> 1.0)
|
82
|
-
json (
|
83
|
-
json_pure (2.3.1)
|
100
|
+
json (2.5.1)
|
84
101
|
jsonapi-renderer (0.2.2)
|
85
|
-
kaminari (
|
86
|
-
|
87
|
-
|
88
|
-
kaminari-activerecord (= 1.2.1)
|
89
|
-
kaminari-core (= 1.2.1)
|
90
|
-
kaminari-actionview (1.2.1)
|
91
|
-
actionview
|
92
|
-
kaminari-core (= 1.2.1)
|
93
|
-
kaminari-activerecord (1.2.1)
|
94
|
-
activerecord
|
95
|
-
kaminari-core (= 1.2.1)
|
96
|
-
kaminari-core (1.2.1)
|
102
|
+
kaminari (0.17.0)
|
103
|
+
actionpack (>= 3.0.0)
|
104
|
+
activesupport (>= 3.0.0)
|
97
105
|
launchy (2.4.3)
|
98
106
|
addressable (~> 2.3)
|
99
|
-
loofah (2.
|
107
|
+
loofah (2.9.1)
|
100
108
|
crass (~> 1.0.2)
|
101
109
|
nokogiri (>= 1.5.9)
|
102
110
|
mail (2.7.1)
|
103
111
|
mini_mime (>= 0.1.1)
|
104
|
-
marcel (0.
|
105
|
-
mimemagic (~> 0.3.2)
|
112
|
+
marcel (1.0.1)
|
106
113
|
method_source (1.0.0)
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
minitest (5.14.2)
|
114
|
+
mini_mime (1.0.3)
|
115
|
+
mini_portile2 (2.5.0)
|
116
|
+
minitest (5.14.4)
|
111
117
|
multi_json (1.15.0)
|
112
118
|
multipart-post (2.1.1)
|
113
119
|
net-http-persistent (2.9.4)
|
114
120
|
net-http-pipeline (1.0.1)
|
115
|
-
nio4r (2.5.
|
116
|
-
nokogiri (1.
|
117
|
-
mini_portile2 (~> 2.
|
118
|
-
|
121
|
+
nio4r (2.5.7)
|
122
|
+
nokogiri (1.11.3)
|
123
|
+
mini_portile2 (~> 2.5.0)
|
124
|
+
racc (~> 1.4)
|
119
125
|
pusher-client (0.6.2)
|
120
126
|
json
|
121
127
|
websocket (~> 1.0)
|
128
|
+
racc (1.5.2)
|
122
129
|
rack (2.2.3)
|
123
130
|
rack-test (1.1.0)
|
124
131
|
rack (>= 1.0, < 3)
|
125
|
-
rails (
|
126
|
-
actioncable (=
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
132
|
+
rails (6.1.3.1)
|
133
|
+
actioncable (= 6.1.3.1)
|
134
|
+
actionmailbox (= 6.1.3.1)
|
135
|
+
actionmailer (= 6.1.3.1)
|
136
|
+
actionpack (= 6.1.3.1)
|
137
|
+
actiontext (= 6.1.3.1)
|
138
|
+
actionview (= 6.1.3.1)
|
139
|
+
activejob (= 6.1.3.1)
|
140
|
+
activemodel (= 6.1.3.1)
|
141
|
+
activerecord (= 6.1.3.1)
|
142
|
+
activestorage (= 6.1.3.1)
|
143
|
+
activesupport (= 6.1.3.1)
|
144
|
+
bundler (>= 1.15.0)
|
145
|
+
railties (= 6.1.3.1)
|
137
146
|
sprockets-rails (>= 2.0.0)
|
138
147
|
rails-dom-testing (2.0.3)
|
139
148
|
activesupport (>= 4.2.0)
|
140
149
|
nokogiri (>= 1.6)
|
141
150
|
rails-html-sanitizer (1.3.0)
|
142
151
|
loofah (~> 2.3)
|
143
|
-
railties (
|
144
|
-
actionpack (=
|
145
|
-
activesupport (=
|
152
|
+
railties (6.1.3.1)
|
153
|
+
actionpack (= 6.1.3.1)
|
154
|
+
activesupport (= 6.1.3.1)
|
146
155
|
method_source
|
147
156
|
rake (>= 0.8.7)
|
148
|
-
thor (
|
157
|
+
thor (~> 1.0)
|
149
158
|
rake (10.1.1)
|
150
|
-
rdoc (6.
|
159
|
+
rdoc (6.3.0)
|
151
160
|
redgreen (1.2.2)
|
152
161
|
rspec (2.99.0)
|
153
162
|
rspec-core (~> 2.99.0)
|
@@ -157,8 +166,7 @@ GEM
|
|
157
166
|
rspec-expectations (2.99.2)
|
158
167
|
diff-lcs (>= 1.1.3, < 2.0)
|
159
168
|
rspec-mocks (2.99.4)
|
160
|
-
|
161
|
-
sequel (5.38.0)
|
169
|
+
sequel (5.43.0)
|
162
170
|
sprockets (4.0.2)
|
163
171
|
concurrent-ruby (~> 1.0)
|
164
172
|
rack (> 1, < 3)
|
@@ -166,24 +174,27 @@ GEM
|
|
166
174
|
actionpack (>= 4.0)
|
167
175
|
activesupport (>= 4.0)
|
168
176
|
sprockets (>= 3.0.0)
|
169
|
-
sqlite3 (1.
|
170
|
-
thor (1.0
|
171
|
-
|
172
|
-
|
173
|
-
faraday (~>
|
174
|
-
faraday_middleware (~>
|
177
|
+
sqlite3 (1.4.2)
|
178
|
+
thor (1.1.0)
|
179
|
+
travis (1.8.13)
|
180
|
+
backports
|
181
|
+
faraday (~> 0.9)
|
182
|
+
faraday_middleware (~> 0.9, >= 0.9.1)
|
175
183
|
gh (~> 0.13)
|
176
|
-
highline (~>
|
177
|
-
|
178
|
-
launchy (~> 2.1, < 2.5.0)
|
184
|
+
highline (~> 1.6)
|
185
|
+
launchy (~> 2.1)
|
179
186
|
pusher-client (~> 0.4)
|
180
|
-
|
181
|
-
|
182
|
-
|
187
|
+
typhoeus (~> 0.6, >= 0.6.8)
|
188
|
+
typhoeus (0.8.0)
|
189
|
+
ethon (>= 0.8.0)
|
190
|
+
tzinfo (2.0.4)
|
191
|
+
concurrent-ruby (~> 1.0)
|
192
|
+
websocket (1.2.9)
|
183
193
|
websocket-driver (0.7.3)
|
184
194
|
websocket-extensions (>= 0.1.0)
|
185
195
|
websocket-extensions (0.1.5)
|
186
196
|
will_paginate (3.3.0)
|
197
|
+
zeitwerk (2.4.2)
|
187
198
|
|
188
199
|
PLATFORMS
|
189
200
|
ruby
|
@@ -192,17 +203,17 @@ DEPENDENCIES
|
|
192
203
|
active_model_serializers
|
193
204
|
activerecord-jdbc-adapter
|
194
205
|
activerecord-jdbcsqlite3-adapter
|
195
|
-
|
206
|
+
algolia (< 3.0.0)
|
196
207
|
jdbc-sqlite3
|
197
|
-
json (
|
198
|
-
kaminari
|
199
|
-
rails (
|
208
|
+
json (>= 1.5.1)
|
209
|
+
kaminari (< 1)
|
210
|
+
rails (~> 6.1)
|
200
211
|
rake (~> 10.1.0)
|
201
212
|
rdoc
|
202
213
|
redgreen
|
203
214
|
rspec (>= 2.5.0, < 3.0)
|
204
215
|
sequel (>= 4.0)
|
205
|
-
sqlite3 (
|
216
|
+
sqlite3 (~> 1.4.0)
|
206
217
|
travis
|
207
218
|
will_paginate (>= 2.3.15)
|
208
219
|
|
data/README.md
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
<p align="center">
|
2
2
|
<a href="https://www.algolia.com">
|
3
|
-
<img alt="Algolia for Rails" src="https://raw.githubusercontent.com/algolia/algoliasearch-client-common/master/banners/rails.png"
|
3
|
+
<img alt="Algolia for Rails" src="https://raw.githubusercontent.com/algolia/algoliasearch-client-common/master/banners/rails.png"/>
|
4
4
|
</a>
|
5
|
+
</p>
|
5
6
|
|
6
|
-
|
7
|
+
<h4 align="center">The perfect starting point to integrate <a href="https://algolia.com" target="_blank">Algolia</a> within your Rails project</h4>
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
</p>
|
9
|
+
<p align="center">
|
10
|
+
<a href="https://circleci.com/gh/algolia/algoliasearch-rails"><img src="https://circleci.com/gh/algolia/algoliasearch-rails.svg?style=shield" alt="CircleCI" /></a>
|
11
|
+
<a href="http://badge.fury.io/rb/algoliasearch-rails"><img src="https://badge.fury.io/rb/algoliasearch-rails.svg" alt="Gem Version"/></a>
|
12
|
+
<a href="https://codeclimate.com/github/algolia/algoliasearch-rails"><img src="https://codeclimate.com/github/algolia/algoliasearch-rails.svg" alt="Code Climate"/></a>
|
13
|
+
<img src="https://img.shields.io/badge/ActiveRecord-yes-blue.svg?style=flat-square" alt="ActiveRecord"/>
|
14
|
+
<img src="https://img.shields.io/badge/Mongoid-yes-blue.svg?style=flat-square" alt="Mongoid"/>
|
15
|
+
<img src="https://img.shields.io/badge/Sequel-yes-blue.svg?style=flat-square" alt="Sequel"/>
|
16
16
|
</p>
|
17
17
|
|
18
18
|
<p align="center">
|
@@ -26,7 +26,7 @@
|
|
26
26
|
|
27
27
|
|
28
28
|
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.
|
29
|
-
Rails
|
29
|
+
Rails 5.x and 6.x are supported.
|
30
30
|
|
31
31
|
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/).
|
32
32
|
|
@@ -1160,29 +1160,6 @@ class User < ActiveRecord::Base
|
|
1160
1160
|
end
|
1161
1161
|
```
|
1162
1162
|
|
1163
|
-
Or you may want to mock Algolia's API calls. We provide a [WebMock](https://github.com/bblimke/webmock) sample configuration that you can use including `algolia/webmock`:
|
1164
|
-
|
1165
|
-
```ruby
|
1166
|
-
require 'algolia/webmock'
|
1167
|
-
|
1168
|
-
describe 'With a mocked client' do
|
1169
|
-
|
1170
|
-
before(:each) do
|
1171
|
-
WebMock.enable!
|
1172
|
-
end
|
1173
|
-
|
1174
|
-
it "shouldn't perform any API calls here" do
|
1175
|
-
User.create(name: 'My Indexed User') # mocked, no API call performed
|
1176
|
-
User.search('').should == {} # mocked, no API call performed
|
1177
|
-
end
|
1178
|
-
|
1179
|
-
after(:each) do
|
1180
|
-
WebMock.disable!
|
1181
|
-
end
|
1182
|
-
|
1183
|
-
end
|
1184
|
-
```
|
1185
|
-
|
1186
1163
|
|
1187
1164
|
## ❓ Troubleshooting
|
1188
1165
|
|
data/algoliasearch-rails.gemspec
CHANGED
@@ -21,7 +21,6 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.files = [
|
22
22
|
".document",
|
23
23
|
".rspec",
|
24
|
-
".travis.yml",
|
25
24
|
"CHANGELOG.MD",
|
26
25
|
"Gemfile",
|
27
26
|
"Gemfile.lock",
|
@@ -79,19 +78,18 @@ Gem::Specification.new do |s|
|
|
79
78
|
|
80
79
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
81
80
|
s.add_runtime_dependency(%q<json>, [">= 1.5.1"])
|
82
|
-
s.add_runtime_dependency(%q<
|
81
|
+
s.add_runtime_dependency(%q<algolia>, ["< 3.0.0"])
|
83
82
|
s.add_development_dependency(%q<will_paginate>, [">= 2.3.15"])
|
84
83
|
s.add_development_dependency(%q<kaminari>, [">= 0"])
|
85
|
-
s.add_development_dependency "travis"
|
86
84
|
s.add_development_dependency "rake"
|
87
85
|
s.add_development_dependency "rdoc"
|
88
86
|
else
|
89
87
|
s.add_dependency(%q<json>, [">= 1.5.1"])
|
90
|
-
s.add_dependency(%q<
|
88
|
+
s.add_dependency(%q<algolia>, ["< 3.0.0"])
|
91
89
|
end
|
92
90
|
else
|
93
91
|
s.add_dependency(%q<json>, [">= 1.5.1"])
|
94
|
-
s.add_dependency(%q<
|
92
|
+
s.add_dependency(%q<algolia>, ["< 3.0.0"])
|
95
93
|
end
|
96
94
|
end
|
97
95
|
|
@@ -1,14 +1,30 @@
|
|
1
1
|
module AlgoliaSearch
|
2
2
|
module Configuration
|
3
|
+
def initiliaze
|
4
|
+
@client = nil
|
5
|
+
end
|
6
|
+
|
3
7
|
def configuration
|
4
8
|
@@configuration || raise(NotConfigured, "Please configure AlgoliaSearch. Set AlgoliaSearch.configuration = {application_id: 'YOUR_APPLICATION_ID', api_key: 'YOUR_API_KEY'}")
|
5
9
|
end
|
6
10
|
|
7
11
|
def configuration=(configuration)
|
8
12
|
@@configuration = configuration.merge(
|
9
|
-
|
13
|
+
:user_agent => "Algolia for Rails (#{AlgoliaSearch::VERSION}); Rails (#{Rails::VERSION::STRING})",
|
14
|
+
:symbolize_keys => false
|
10
15
|
)
|
11
|
-
|
16
|
+
end
|
17
|
+
|
18
|
+
def client
|
19
|
+
if @client.nil?
|
20
|
+
setup_client
|
21
|
+
end
|
22
|
+
|
23
|
+
@client
|
24
|
+
end
|
25
|
+
|
26
|
+
def setup_client
|
27
|
+
@client = Algolia::Search::Client.create_with_config(Algolia::Search::Config.new(@@configuration))
|
12
28
|
end
|
13
29
|
end
|
14
30
|
end
|
@@ -2,7 +2,7 @@ module AlgoliaSearch
|
|
2
2
|
module Utilities
|
3
3
|
class << self
|
4
4
|
def get_model_classes
|
5
|
-
if defined?(Rails.autoloaders) && Rails.autoloaders.zeitwerk_enabled?
|
5
|
+
if Rails.application && defined?(Rails.autoloaders) && Rails.autoloaders.zeitwerk_enabled?
|
6
6
|
Zeitwerk::Loader.eager_load_all
|
7
7
|
elsif Rails.application
|
8
8
|
Rails.application.eager_load!
|
data/lib/algoliasearch-rails.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'algolia'
|
2
2
|
|
3
3
|
require 'algoliasearch/version'
|
4
4
|
require 'algoliasearch/utilities'
|
@@ -53,7 +53,6 @@ module AlgoliaSearch
|
|
53
53
|
OPTIONS = [
|
54
54
|
# Attributes
|
55
55
|
:searchableAttributes, :attributesForFaceting, :unretrievableAttributes, :attributesToRetrieve,
|
56
|
-
:attributesToIndex, #Legacy name of searchableAttributes
|
57
56
|
# Ranking
|
58
57
|
:ranking, :customRanking, # Replicas are handled via `add_replica`
|
59
58
|
# Faceting
|
@@ -76,7 +75,6 @@ module AlgoliaSearch
|
|
76
75
|
:disablePrefixOnAttributes, :disableExactOnAttributes, :exactOnSingleWordQuery, :alternativesAsExact,
|
77
76
|
# Performance
|
78
77
|
:numericAttributesForFiltering, :allowCompressionOfIntegerArray,
|
79
|
-
:numericAttributesToIndex, # Legacy name of numericAttributesForFiltering
|
80
78
|
# Advanced
|
81
79
|
:attributeForDistinct, :distinct, :replaceSynonymsInHighlight, :minProximity, :responseFields,
|
82
80
|
:maxFacetHits,
|
@@ -102,7 +100,7 @@ module AlgoliaSearch
|
|
102
100
|
|
103
101
|
def attribute(*names, &block)
|
104
102
|
raise ArgumentError.new('Cannot pass multiple attribute names if block given') if block_given? and names.length > 1
|
105
|
-
raise ArgumentError.new('Cannot specify additional attributes on a replica index') if @options[:
|
103
|
+
raise ArgumentError.new('Cannot specify additional attributes on a replica index') if @options[:replica]
|
106
104
|
@attributes ||= {}
|
107
105
|
names.flatten.each do |name|
|
108
106
|
@attributes[name.to_s] = block_given? ? Proc.new { |o| o.instance_eval(&block) } : Proc.new { |o| o.send(name) }
|
@@ -112,7 +110,7 @@ module AlgoliaSearch
|
|
112
110
|
|
113
111
|
def add_attribute(*names, &block)
|
114
112
|
raise ArgumentError.new('Cannot pass multiple attribute names if block given') if block_given? and names.length > 1
|
115
|
-
raise ArgumentError.new('Cannot specify additional attributes on a replica index') if @options[:
|
113
|
+
raise ArgumentError.new('Cannot specify additional attributes on a replica index') if @options[:replica]
|
116
114
|
@additional_attributes ||= {}
|
117
115
|
names.each do |name|
|
118
116
|
@additional_attributes[name.to_s] = block_given? ? Proc.new { |o| o.instance_eval(&block) } : Proc.new { |o| o.send(name) }
|
@@ -224,14 +222,14 @@ module AlgoliaSearch
|
|
224
222
|
end
|
225
223
|
|
226
224
|
def geoloc(lat_attr = nil, lng_attr = nil, &block)
|
227
|
-
raise ArgumentError.new('Cannot specify additional attributes on a replica index') if @options[:
|
225
|
+
raise ArgumentError.new('Cannot specify additional attributes on a replica index') if @options[:replica]
|
228
226
|
add_attribute :_geoloc do |o|
|
229
227
|
block_given? ? o.instance_eval(&block) : { :lat => o.send(lat_attr).to_f, :lng => o.send(lng_attr).to_f }
|
230
228
|
end
|
231
229
|
end
|
232
230
|
|
233
231
|
def tags(*args, &block)
|
234
|
-
raise ArgumentError.new('Cannot specify additional attributes on a replica index') if @options[:
|
232
|
+
raise ArgumentError.new('Cannot specify additional attributes on a replica index') if @options[:replica]
|
235
233
|
add_attribute :_tags do |o|
|
236
234
|
v = block_given? ? o.instance_eval(&block) : args
|
237
235
|
v.is_a?(Array) ? v : [v]
|
@@ -248,16 +246,12 @@ module AlgoliaSearch
|
|
248
246
|
v = get_setting(k)
|
249
247
|
settings[k] = v if !v.nil?
|
250
248
|
end
|
251
|
-
|
252
|
-
|
253
|
-
name = opts[:index_name]
|
254
|
-
name = "#{name}_#{Rails.env.to_s}" if opts[:per_environment]
|
255
|
-
name
|
256
|
-
end
|
257
|
-
settings.delete(:slaves) if settings[:slaves].empty?
|
249
|
+
|
250
|
+
if !@options[:replica]
|
258
251
|
settings[:replicas] = additional_indexes.select { |opts, s| opts[:replica] }.map do |opts, s|
|
259
252
|
name = opts[:index_name]
|
260
253
|
name = "#{name}_#{Rails.env.to_s}" if opts[:per_environment]
|
254
|
+
name = "virtual(#{name})" if opts[:virtual]
|
261
255
|
name
|
262
256
|
end
|
263
257
|
settings.delete(:replicas) if settings[:replicas].empty?
|
@@ -266,27 +260,20 @@ module AlgoliaSearch
|
|
266
260
|
end
|
267
261
|
|
268
262
|
def add_index(index_name, options = {}, &block)
|
269
|
-
raise ArgumentError.new('Cannot specify additional index on a replica index') if @options[:
|
263
|
+
raise ArgumentError.new('Cannot specify additional index on a replica index') if @options[:replica]
|
270
264
|
raise ArgumentError.new('No block given') if !block_given?
|
271
265
|
raise ArgumentError.new('Options auto_index and auto_remove cannot be set on nested indexes') if options[:auto_index] || options[:auto_remove]
|
272
266
|
@additional_indexes ||= {}
|
273
|
-
raise MixedSlavesAndReplicas.new('Cannot mix slaves and replicas in the same configuration (add_slave is deprecated)') if (options[:slave] && @additional_indexes.any? { |opts, _| opts[:replica] }) || (options[:replica] && @additional_indexes.any? { |opts, _| opts[:slave] })
|
274
267
|
options[:index_name] = index_name
|
275
268
|
@additional_indexes[options] = IndexSettings.new(options, &block)
|
276
269
|
end
|
277
270
|
|
278
271
|
def add_replica(index_name, options = {}, &block)
|
279
|
-
raise ArgumentError.new('Cannot specify additional replicas on a replica index') if @options[:
|
272
|
+
raise ArgumentError.new('Cannot specify additional replicas on a replica index') if @options[:replica]
|
280
273
|
raise ArgumentError.new('No block given') if !block_given?
|
281
274
|
add_index(index_name, options.merge({ :replica => true, :primary_settings => self }), &block)
|
282
275
|
end
|
283
276
|
|
284
|
-
def add_slave(index_name, options = {}, &block)
|
285
|
-
raise ArgumentError.new('Cannot specify additional slaves on a slave index') if @options[:slave] || @options[:replica]
|
286
|
-
raise ArgumentError.new('No block given') if !block_given?
|
287
|
-
add_index(index_name, options.merge({ :slave => true, :primary_settings => self }), &block)
|
288
|
-
end
|
289
|
-
|
290
277
|
def additional_indexes
|
291
278
|
@additional_indexes || {}
|
292
279
|
end
|
@@ -304,11 +291,11 @@ module AlgoliaSearch
|
|
304
291
|
# are correctly logged or thrown depending on the `raise_on_failure` option
|
305
292
|
class SafeIndex
|
306
293
|
def initialize(name, raise_on_failure)
|
307
|
-
@index =
|
294
|
+
@index = AlgoliaSearch.client.init_index(name)
|
308
295
|
@raise_on_failure = raise_on_failure.nil? || raise_on_failure
|
309
296
|
end
|
310
297
|
|
311
|
-
::Algolia::Index.instance_methods(false).each do |m|
|
298
|
+
::Algolia::Search::Index.instance_methods(false).each do |m|
|
312
299
|
define_method(m) do |*args, &block|
|
313
300
|
SafeIndex.log_or_throw(m, @raise_on_failure) do
|
314
301
|
@index.send(m, *args, &block)
|
@@ -329,7 +316,7 @@ module AlgoliaSearch
|
|
329
316
|
SafeIndex.log_or_throw(:get_settings, @raise_on_failure) do
|
330
317
|
begin
|
331
318
|
@index.get_settings(*args)
|
332
|
-
rescue Algolia::
|
319
|
+
rescue Algolia::AlgoliaHttpError => e
|
333
320
|
return {} if e.code == 404 # not fatal
|
334
321
|
raise e
|
335
322
|
end
|
@@ -339,7 +326,7 @@ module AlgoliaSearch
|
|
339
326
|
# expose move as well
|
340
327
|
def self.move_index(old_name, new_name)
|
341
328
|
SafeIndex.log_or_throw(:move_index, true) do
|
342
|
-
|
329
|
+
AlgoliaSearch.client.move_index(old_name, new_name)
|
343
330
|
end
|
344
331
|
end
|
345
332
|
|
@@ -511,7 +498,7 @@ module AlgoliaSearch
|
|
511
498
|
algolia_configurations.each do |options, settings|
|
512
499
|
next if algolia_indexing_disabled?(options)
|
513
500
|
index = algolia_ensure_init(options, settings)
|
514
|
-
next if options[:
|
501
|
+
next if options[:replica]
|
515
502
|
last_task = nil
|
516
503
|
|
517
504
|
algolia_find_in_batches(batch_size) do |group|
|
@@ -531,7 +518,7 @@ module AlgoliaSearch
|
|
531
518
|
end
|
532
519
|
last_task = index.save_objects(objects)
|
533
520
|
end
|
534
|
-
index.wait_task(last_task["taskID"]) if last_task and (synchronous || options[:synchronous])
|
521
|
+
index.wait_task(last_task.raw_response["taskID"]) if last_task and (synchronous || options[:synchronous])
|
535
522
|
end
|
536
523
|
nil
|
537
524
|
end
|
@@ -541,7 +528,7 @@ module AlgoliaSearch
|
|
541
528
|
return if algolia_without_auto_index_scope
|
542
529
|
algolia_configurations.each do |options, settings|
|
543
530
|
next if algolia_indexing_disabled?(options)
|
544
|
-
next if options[:
|
531
|
+
next if options[:replica]
|
545
532
|
|
546
533
|
# fetch the master settings
|
547
534
|
master_index = algolia_ensure_init(options, settings)
|
@@ -549,8 +536,6 @@ module AlgoliaSearch
|
|
549
536
|
master_settings.merge!(JSON.parse(settings.to_settings.to_json)) # convert symbols to strings
|
550
537
|
|
551
538
|
# remove the replicas of the temporary index
|
552
|
-
master_settings.delete :slaves
|
553
|
-
master_settings.delete 'slaves'
|
554
539
|
master_settings.delete :replicas
|
555
540
|
master_settings.delete 'replicas'
|
556
541
|
|
@@ -562,13 +547,13 @@ module AlgoliaSearch
|
|
562
547
|
tmp_settings = settings.dup
|
563
548
|
|
564
549
|
if options[:check_settings] == false
|
565
|
-
|
550
|
+
AlgoliaSearch.client.copy_index!(src_index_name, tmp_index_name, { scope: %w[settings synonyms rules] })
|
566
551
|
tmp_index = SafeIndex.new(tmp_index_name, !!options[:raise_on_failure])
|
567
552
|
else
|
568
553
|
tmp_index = algolia_ensure_init(tmp_options, tmp_settings, master_settings)
|
569
554
|
end
|
570
555
|
|
571
|
-
|
556
|
+
algolia_find_in_batches(batch_size) do |group|
|
572
557
|
if algolia_conditional_index?(options)
|
573
558
|
# select only indexable objects
|
574
559
|
group = group.select { |o| algolia_indexable?(o, tmp_options) }
|
@@ -578,7 +563,7 @@ module AlgoliaSearch
|
|
578
563
|
end
|
579
564
|
|
580
565
|
move_task = SafeIndex.move_index(tmp_index.name, src_index_name)
|
581
|
-
master_index.wait_task(move_task["taskID"]) if synchronous || options[:synchronous]
|
566
|
+
master_index.wait_task(move_task.raw_response["taskID"]) if synchronous || options[:synchronous]
|
582
567
|
end
|
583
568
|
nil
|
584
569
|
end
|
@@ -587,8 +572,6 @@ module AlgoliaSearch
|
|
587
572
|
algolia_configurations.each do |options, settings|
|
588
573
|
if options[:primary_settings] && options[:inherit]
|
589
574
|
primary = options[:primary_settings].to_settings
|
590
|
-
primary.delete :slaves
|
591
|
-
primary.delete 'slaves'
|
592
575
|
primary.delete :replicas
|
593
576
|
primary.delete 'replicas'
|
594
577
|
final_settings = primary.merge(settings.to_settings)
|
@@ -598,7 +581,7 @@ module AlgoliaSearch
|
|
598
581
|
|
599
582
|
index = SafeIndex.new(algolia_index_name(options), true)
|
600
583
|
task = index.set_settings(final_settings)
|
601
|
-
index.wait_task(task["taskID"]) if synchronous
|
584
|
+
index.wait_task(task.raw_response["taskID"]) if synchronous
|
602
585
|
end
|
603
586
|
end
|
604
587
|
|
@@ -606,9 +589,9 @@ module AlgoliaSearch
|
|
606
589
|
algolia_configurations.each do |options, settings|
|
607
590
|
next if algolia_indexing_disabled?(options)
|
608
591
|
index = algolia_ensure_init(options, settings)
|
609
|
-
next if options[:
|
592
|
+
next if options[:replica]
|
610
593
|
task = index.save_objects(objects.map { |o| settings.get_attributes(o).merge 'objectID' => algolia_object_id_of(o, options) })
|
611
|
-
index.wait_task(task["taskID"]) if synchronous || options[:synchronous]
|
594
|
+
index.wait_task(task.raw_response["taskID"]) if synchronous || options[:synchronous]
|
612
595
|
end
|
613
596
|
end
|
614
597
|
|
@@ -618,13 +601,13 @@ module AlgoliaSearch
|
|
618
601
|
next if algolia_indexing_disabled?(options)
|
619
602
|
object_id = algolia_object_id_of(object, options)
|
620
603
|
index = algolia_ensure_init(options, settings)
|
621
|
-
next if options[:
|
604
|
+
next if options[:replica]
|
622
605
|
if algolia_indexable?(object, options)
|
623
606
|
raise ArgumentError.new("Cannot index a record with a blank objectID") if object_id.blank?
|
624
607
|
if synchronous || options[:synchronous]
|
625
|
-
index.
|
608
|
+
index.save_object!(settings.get_attributes(object).merge 'objectID' => algolia_object_id_of(object, options))
|
626
609
|
else
|
627
|
-
index.
|
610
|
+
index.save_object(settings.get_attributes(object).merge 'objectID' => algolia_object_id_of(object, options))
|
628
611
|
end
|
629
612
|
elsif algolia_conditional_index?(options) && !object_id.blank?
|
630
613
|
# remove non-indexable objects
|
@@ -645,7 +628,7 @@ module AlgoliaSearch
|
|
645
628
|
algolia_configurations.each do |options, settings|
|
646
629
|
next if algolia_indexing_disabled?(options)
|
647
630
|
index = algolia_ensure_init(options, settings)
|
648
|
-
next if options[:
|
631
|
+
next if options[:replica]
|
649
632
|
if synchronous || options[:synchronous]
|
650
633
|
index.delete_object!(object_id)
|
651
634
|
else
|
@@ -659,8 +642,8 @@ module AlgoliaSearch
|
|
659
642
|
algolia_configurations.each do |options, settings|
|
660
643
|
next if algolia_indexing_disabled?(options)
|
661
644
|
index = algolia_ensure_init(options, settings)
|
662
|
-
next if options[:
|
663
|
-
synchronous || options[:synchronous] ? index.
|
645
|
+
next if options[:replica]
|
646
|
+
synchronous || options[:synchronous] ? index.clear_objects! : index.clear_objects
|
664
647
|
@algolia_indexes[settings] = nil
|
665
648
|
end
|
666
649
|
nil
|
@@ -669,8 +652,6 @@ module AlgoliaSearch
|
|
669
652
|
def algolia_raw_search(q, params = {})
|
670
653
|
index_name = params.delete(:index) ||
|
671
654
|
params.delete('index') ||
|
672
|
-
params.delete(:slave) ||
|
673
|
-
params.delete('slave') ||
|
674
655
|
params.delete(:replica) ||
|
675
656
|
params.delete('replica')
|
676
657
|
index = algolia_index(index_name)
|
@@ -735,13 +716,11 @@ module AlgoliaSearch
|
|
735
716
|
def algolia_search_for_facet_values(facet, text, params = {})
|
736
717
|
index_name = params.delete(:index) ||
|
737
718
|
params.delete('index') ||
|
738
|
-
params.delete(:slave) ||
|
739
|
-
params.delete('slave') ||
|
740
719
|
params.delete(:replica) ||
|
741
720
|
params.delete('replicas')
|
742
721
|
index = algolia_index(index_name)
|
743
722
|
query = Hash[params.map { |k, v| [k.to_s, v.to_s] }]
|
744
|
-
index.
|
723
|
+
index.search_for_facet_values(facet, text, query)['facetHits']
|
745
724
|
end
|
746
725
|
|
747
726
|
# deprecated (renaming)
|
@@ -770,7 +749,7 @@ module AlgoliaSearch
|
|
770
749
|
# Loop over each index to see if a attribute used in records has changed
|
771
750
|
algolia_configurations.each do |options, settings|
|
772
751
|
next if algolia_indexing_disabled?(options)
|
773
|
-
next if options[:
|
752
|
+
next if options[:replica]
|
774
753
|
return true if algolia_object_id_changed?(object, options)
|
775
754
|
settings.get_attribute_names(object).each do |k|
|
776
755
|
return true if algolia_attribute_changed?(object, k)
|
@@ -807,21 +786,20 @@ module AlgoliaSearch
|
|
807
786
|
|
808
787
|
@algolia_indexes[settings] = SafeIndex.new(algolia_index_name(options), algoliasearch_options[:raise_on_failure])
|
809
788
|
|
810
|
-
current_settings = @algolia_indexes[settings].get_settings(:getVersion => 1) rescue nil # if the index doesn't exist
|
811
|
-
|
812
789
|
index_settings ||= settings.to_settings
|
813
790
|
index_settings = options[:primary_settings].to_settings.merge(index_settings) if options[:inherit]
|
814
791
|
|
815
792
|
options[:check_settings] = true if options[:check_settings].nil?
|
816
793
|
|
794
|
+
current_settings = if options[:check_settings]
|
795
|
+
@algolia_indexes[settings].get_settings(:getVersion => 1) rescue nil # if the index doesn't exist
|
796
|
+
end
|
797
|
+
|
817
798
|
if !algolia_indexing_disabled?(options) && options[:check_settings] && algoliasearch_settings_changed?(current_settings, index_settings)
|
818
|
-
used_slaves = !current_settings.nil? && !current_settings['slaves'].nil?
|
819
799
|
replicas = index_settings.delete(:replicas) ||
|
820
|
-
index_settings.delete('replicas')
|
821
|
-
|
822
|
-
|
823
|
-
index_settings[used_slaves ? :slaves : :replicas] = replicas unless replicas.nil? || options[:inherit]
|
824
|
-
@algolia_indexes[settings].set_settings(index_settings)
|
800
|
+
index_settings.delete('replicas')
|
801
|
+
index_settings[:replicas] = replicas unless replicas.nil? || options[:inherit]
|
802
|
+
@algolia_indexes[settings].set_settings!(index_settings)
|
825
803
|
end
|
826
804
|
|
827
805
|
@algolia_indexes[settings]
|
data/spec/spec_helper.rb
CHANGED
@@ -29,8 +29,9 @@ RSpec.configure do |c|
|
|
29
29
|
|
30
30
|
# Remove all indexes setup in this run in local or CI
|
31
31
|
c.after(:suite) do
|
32
|
-
safe_index_list.each do |
|
33
|
-
|
32
|
+
safe_index_list.each do |i|
|
33
|
+
index = AlgoliaSearch.client.init_index(i['name'])
|
34
|
+
index.delete!
|
34
35
|
end
|
35
36
|
end
|
36
37
|
end
|
@@ -45,7 +46,7 @@ end
|
|
45
46
|
|
46
47
|
# get a list of safe indexes in local or CI
|
47
48
|
def safe_index_list
|
48
|
-
list =
|
49
|
+
list = AlgoliaSearch.client.list_indexes['items']
|
49
50
|
list = list.select { |index| index["name"].include?(SAFE_INDEX_PREFIX) }
|
50
51
|
list.sort_by { |index| index["primary"] || "" }
|
51
52
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: algoliasearch-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 2.1.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: 2021-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -25,25 +25,19 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.5.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: algolia
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 1.26.0
|
34
31
|
- - "<"
|
35
32
|
- !ruby/object:Gem::Version
|
36
|
-
version:
|
33
|
+
version: 3.0.0
|
37
34
|
type: :runtime
|
38
35
|
prerelease: false
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
40
37
|
requirements:
|
41
|
-
- - ">="
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: 1.26.0
|
44
38
|
- - "<"
|
45
39
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
40
|
+
version: 3.0.0
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
42
|
name: will_paginate
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,20 +66,6 @@ dependencies:
|
|
72
66
|
- - ">="
|
73
67
|
- !ruby/object:Gem::Version
|
74
68
|
version: '0'
|
75
|
-
- !ruby/object:Gem::Dependency
|
76
|
-
name: travis
|
77
|
-
requirement: !ruby/object:Gem::Requirement
|
78
|
-
requirements:
|
79
|
-
- - ">="
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: '0'
|
82
|
-
type: :development
|
83
|
-
prerelease: false
|
84
|
-
version_requirements: !ruby/object:Gem::Requirement
|
85
|
-
requirements:
|
86
|
-
- - ">="
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: '0'
|
89
69
|
- !ruby/object:Gem::Dependency
|
90
70
|
name: rake
|
91
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -125,7 +105,6 @@ extra_rdoc_files:
|
|
125
105
|
files:
|
126
106
|
- ".document"
|
127
107
|
- ".rspec"
|
128
|
-
- ".travis.yml"
|
129
108
|
- CHANGELOG.MD
|
130
109
|
- Gemfile
|
131
110
|
- Gemfile.lock
|
@@ -188,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
188
167
|
- !ruby/object:Gem::Version
|
189
168
|
version: '0'
|
190
169
|
requirements: []
|
191
|
-
rubygems_version: 3.0.
|
170
|
+
rubygems_version: 3.0.6
|
192
171
|
signing_key:
|
193
172
|
specification_version: 4
|
194
173
|
summary: AlgoliaSearch integration to your favorite ORM
|
data/.travis.yml
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
|
3
|
-
branches:
|
4
|
-
only:
|
5
|
-
- master
|
6
|
-
|
7
|
-
matrix:
|
8
|
-
include:
|
9
|
-
- rvm: 1.8.7
|
10
|
-
env: RAILS_VERSION=3.2.0 SEQUEL_VERSION=4.0
|
11
|
-
dist: trusty
|
12
|
-
- rvm: 1.9.3
|
13
|
-
env: RAILS_VERSION=3.2.0
|
14
|
-
- rvm: 1.9.3
|
15
|
-
env: RAILS_VERSION=4.2
|
16
|
-
- rvm: 2.2.9
|
17
|
-
env: RAILS_VERSION=3.2.0
|
18
|
-
- rvm: 2.2.9
|
19
|
-
env: RAILS_VERSION=4.2
|
20
|
-
- rvm: 2.2.9
|
21
|
-
env: RAILS_VERSION=5.1
|
22
|
-
- rvm: 2.3.6
|
23
|
-
env: RAILS_VERSION=3.2.0
|
24
|
-
- rvm: 2.3.6
|
25
|
-
env: RAILS_VERSION=4.2
|
26
|
-
- rvm: 2.3.6
|
27
|
-
env: RAILS_VERSION=5.1
|
28
|
-
- rvm: 2.4.3
|
29
|
-
env: RAILS_VERSION=4.2
|
30
|
-
- rvm: 2.4.3
|
31
|
-
env: RAILS_VERSION=5.1 SEQUEL_VERSION=4.0
|
32
|
-
- rvm: 2.4.3
|
33
|
-
env: RAILS_VERSION=5.1 SEQUEL_VERSION=5.0
|
34
|
-
- rvm: 2.5.3
|
35
|
-
env: RAILS_VERSION=5.1 SEQUEL_VERSION=5.0
|
36
|
-
- rvm: 2.5.3
|
37
|
-
env: RAILS_VERSION=6.0 SEQUEL_VERSION=5.0
|
38
|
-
- rvm: 2.6.0
|
39
|
-
env: RAILS_VERSION=5.2 SEQUEL_VERSION=5.0
|
40
|
-
- rvm: 2.6.0
|
41
|
-
env: RAILS_VERSION=6.0 SEQUEL_VERSION=5.0
|
42
|
-
- rvm: 2.7.0
|
43
|
-
env: RAILS_VERSION=5.2 SEQUEL_VERSION=5.0
|
44
|
-
- rvm: 2.7.0
|
45
|
-
env: RAILS_VERSION=6.0 SEQUEL_VERSION=5.0
|
46
|
-
|
47
|
-
before_install:
|
48
|
-
- wget http://api-key-dealer.herokuapp.com/clients/algolia-keys && chmod +x algolia-keys
|
49
|
-
- which bundle || true
|
50
|
-
- find /home/travis/.rvm -wholename "*/bundler-*.gemspec" -print -delete || true
|
51
|
-
- bundle --version || true
|
52
|
-
- gem uninstall bundler || true
|
53
|
-
- bundle --version || true
|
54
|
-
- gem install bundler -v 1.17.3
|
55
|
-
- bundle --version
|
56
|
-
|
57
|
-
install: rm -f Gemfile.lock && bundle install --without development
|
58
|
-
|
59
|
-
cache: bundler
|
60
|
-
|
61
|
-
script:
|
62
|
-
- eval $(./algolia-keys export) && bundle exec rake
|