algoliasearch-rails 1.26.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.MD +6 -5
- data/Gemfile +4 -34
- data/Gemfile.lock +126 -118
- data/algoliasearch-rails.gemspec +3 -3
- data/lib/algoliasearch/configuration.rb +17 -2
- data/lib/algoliasearch/pagination/kaminari.rb +1 -1
- data/lib/algoliasearch/version.rb +1 -1
- data/lib/algoliasearch-rails.rb +31 -59
- data/spec/spec_helper.rb +4 -3
- data/spec/utilities_spec.rb +1 -1
- metadata +7 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d738368dd1684b9fa58b5507e65d0d7522930a6894e0e9684139fbd5def1a583
|
4
|
+
data.tar.gz: 8fdd59e52471fd184cf51092706fb345d699cd9d135385bd0a7ade084ec8dc2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9f4a61d1eafcda6ffbca4c585026ca54d9aed7fb3b03b36143c19b5ee504196b10e2a8be88b7083004fb0b070dfd12bb0dbfecaa987c1761c8afca31326eeea
|
7
|
+
data.tar.gz: 6a8fb2b05c4798965164fc2f651624b2a69935dfa3a22d7704bb312424b7e0f796e7c3d5e9bbdc6d9058f17fe06cc0ec40bd41ee06233f11ce98435906f2a235
|
data/CHANGELOG.MD
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
-
## [Unreleased](https://github.com/algolia/algoliasearch-rails/compare/
|
3
|
+
## [Unreleased](https://github.com/algolia/algoliasearch-rails/compare/2.0.0...master)
|
4
4
|
|
5
|
-
## [
|
5
|
+
## [2.0.0](https://github.com/algolia/algoliasearch-rails/compare/2.0.0...1.25.0)
|
6
6
|
|
7
|
-
###
|
8
|
-
|
9
|
-
-
|
7
|
+
### Breaking changes
|
8
|
+
- Adds support for `algolia` gem.
|
9
|
+
- Drops support for Ruby < 2.4
|
10
|
+
- Drops support for Rails < 5.1
|
10
11
|
|
11
12
|
## [1.25.0](https://github.com/algolia/algoliasearch-rails/compare/1.24.1...1.25.0) (2020-11-24)
|
12
13
|
|
data/Gemfile
CHANGED
@@ -1,39 +1,16 @@
|
|
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"] || '
|
11
|
+
rails_version = ENV["RAILS_VERSION"] || '6.1'
|
12
12
|
gem 'rails', "~> #{rails_version}"
|
13
13
|
gem 'active_model_serializers'
|
14
|
-
if defined?(RUBY_VERSION) && RUBY_VERSION == "1.8.7"
|
15
|
-
gem 'i18n', '< 0.7'
|
16
|
-
gem 'highline', '< 1.7'
|
17
|
-
gem 'addressable', '<= 2.2.7'
|
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'
|
36
|
-
end
|
37
14
|
if Gem::Version.new(rails_version) >= Gem::Version.new('6.0')
|
38
15
|
gem 'sqlite3', '~> 1.4.0', :platform => [:rbx, :ruby]
|
39
16
|
else
|
@@ -57,13 +34,6 @@ end
|
|
57
34
|
|
58
35
|
group :test, :development do
|
59
36
|
gem 'will_paginate', '>= 2.3.15'
|
60
|
-
|
61
|
-
defined?(RUBY_ENGINE) &&
|
62
|
-
RUBY_ENGINE == 'ruby' &&
|
63
|
-
Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2')
|
64
|
-
gem 'kaminari', '< 1'
|
65
|
-
else
|
66
|
-
gem 'kaminari'
|
67
|
-
end
|
37
|
+
gem 'kaminari', '< 1'
|
68
38
|
end
|
69
39
|
|
data/Gemfile.lock
CHANGED
@@ -1,72 +1,90 @@
|
|
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)
|
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 (~>
|
64
|
+
i18n (>= 1.6, < 2)
|
65
|
+
minitest (>= 5.1)
|
66
|
+
tzinfo (~> 2.0)
|
67
|
+
zeitwerk (~> 2.3)
|
50
68
|
addressable (2.4.0)
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
backports (3.
|
56
|
-
builder (3.2.
|
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)
|
74
|
+
builder (3.2.4)
|
57
75
|
case_transform (0.2)
|
58
76
|
activesupport
|
59
|
-
concurrent-ruby (1.1.
|
60
|
-
crass (1.0.
|
61
|
-
diff-lcs (1.
|
62
|
-
erubi (1.
|
63
|
-
ethon (0.
|
64
|
-
ffi (>= 1.
|
65
|
-
faraday (0.
|
77
|
+
concurrent-ruby (1.1.8)
|
78
|
+
crass (1.0.6)
|
79
|
+
diff-lcs (1.4.4)
|
80
|
+
erubi (1.10.0)
|
81
|
+
ethon (0.13.0)
|
82
|
+
ffi (>= 1.15.0)
|
83
|
+
faraday (0.17.4)
|
66
84
|
multipart-post (>= 1.2, < 3)
|
67
|
-
faraday_middleware (0.
|
85
|
+
faraday_middleware (0.14.0)
|
68
86
|
faraday (>= 0.7.4, < 1.0)
|
69
|
-
ffi (1.
|
87
|
+
ffi (1.15.0)
|
70
88
|
gh (0.15.1)
|
71
89
|
addressable (~> 2.4.0)
|
72
90
|
backports
|
@@ -74,79 +92,69 @@ GEM
|
|
74
92
|
multi_json (~> 1.0)
|
75
93
|
net-http-persistent (~> 2.9)
|
76
94
|
net-http-pipeline
|
77
|
-
globalid (0.4.
|
95
|
+
globalid (0.4.2)
|
78
96
|
activesupport (>= 4.2.0)
|
79
97
|
highline (1.7.10)
|
80
|
-
|
81
|
-
i18n (1.4.0)
|
98
|
+
i18n (1.8.10)
|
82
99
|
concurrent-ruby (~> 1.0)
|
83
|
-
json (
|
84
|
-
jsonapi-renderer (0.2.
|
85
|
-
kaminari (
|
86
|
-
|
87
|
-
|
88
|
-
kaminari-activerecord (= 1.1.1)
|
89
|
-
kaminari-core (= 1.1.1)
|
90
|
-
kaminari-actionview (1.1.1)
|
91
|
-
actionview
|
92
|
-
kaminari-core (= 1.1.1)
|
93
|
-
kaminari-activerecord (1.1.1)
|
94
|
-
activerecord
|
95
|
-
kaminari-core (= 1.1.1)
|
96
|
-
kaminari-core (1.1.1)
|
100
|
+
json (2.5.1)
|
101
|
+
jsonapi-renderer (0.2.2)
|
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
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
minitest (5.11.3)
|
111
|
-
multi_json (1.13.1)
|
112
|
-
multipart-post (2.0.0)
|
112
|
+
marcel (1.0.1)
|
113
|
+
method_source (1.0.0)
|
114
|
+
mini_mime (1.0.3)
|
115
|
+
minitest (5.14.4)
|
116
|
+
multi_json (1.15.0)
|
117
|
+
multipart-post (2.1.1)
|
113
118
|
net-http-persistent (2.9.4)
|
114
119
|
net-http-pipeline (1.0.1)
|
115
|
-
nio4r (2.
|
116
|
-
nokogiri (1.
|
117
|
-
|
120
|
+
nio4r (2.5.7)
|
121
|
+
nokogiri (1.11.3-x86_64-darwin)
|
122
|
+
racc (~> 1.4)
|
118
123
|
pusher-client (0.6.2)
|
119
124
|
json
|
120
125
|
websocket (~> 1.0)
|
121
|
-
|
126
|
+
racc (1.5.2)
|
127
|
+
rack (2.2.3)
|
122
128
|
rack-test (1.1.0)
|
123
129
|
rack (>= 1.0, < 3)
|
124
|
-
rails (
|
125
|
-
actioncable (=
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
130
|
+
rails (6.1.3.1)
|
131
|
+
actioncable (= 6.1.3.1)
|
132
|
+
actionmailbox (= 6.1.3.1)
|
133
|
+
actionmailer (= 6.1.3.1)
|
134
|
+
actionpack (= 6.1.3.1)
|
135
|
+
actiontext (= 6.1.3.1)
|
136
|
+
actionview (= 6.1.3.1)
|
137
|
+
activejob (= 6.1.3.1)
|
138
|
+
activemodel (= 6.1.3.1)
|
139
|
+
activerecord (= 6.1.3.1)
|
140
|
+
activestorage (= 6.1.3.1)
|
141
|
+
activesupport (= 6.1.3.1)
|
142
|
+
bundler (>= 1.15.0)
|
143
|
+
railties (= 6.1.3.1)
|
136
144
|
sprockets-rails (>= 2.0.0)
|
137
145
|
rails-dom-testing (2.0.3)
|
138
146
|
activesupport (>= 4.2.0)
|
139
147
|
nokogiri (>= 1.6)
|
140
|
-
rails-html-sanitizer (1.0
|
141
|
-
loofah (~> 2.
|
142
|
-
railties (
|
143
|
-
actionpack (=
|
144
|
-
activesupport (=
|
148
|
+
rails-html-sanitizer (1.3.0)
|
149
|
+
loofah (~> 2.3)
|
150
|
+
railties (6.1.3.1)
|
151
|
+
actionpack (= 6.1.3.1)
|
152
|
+
activesupport (= 6.1.3.1)
|
145
153
|
method_source
|
146
154
|
rake (>= 0.8.7)
|
147
|
-
thor (
|
155
|
+
thor (~> 1.0)
|
148
156
|
rake (10.1.1)
|
149
|
-
rdoc (6.
|
157
|
+
rdoc (6.3.0)
|
150
158
|
redgreen (1.2.2)
|
151
159
|
rspec (2.99.0)
|
152
160
|
rspec-core (~> 2.99.0)
|
@@ -156,18 +164,17 @@ GEM
|
|
156
164
|
rspec-expectations (2.99.2)
|
157
165
|
diff-lcs (>= 1.1.3, < 2.0)
|
158
166
|
rspec-mocks (2.99.4)
|
159
|
-
sequel (5.
|
160
|
-
sprockets (
|
167
|
+
sequel (5.43.0)
|
168
|
+
sprockets (4.0.2)
|
161
169
|
concurrent-ruby (~> 1.0)
|
162
170
|
rack (> 1, < 3)
|
163
|
-
sprockets-rails (3.2.
|
171
|
+
sprockets-rails (3.2.2)
|
164
172
|
actionpack (>= 4.0)
|
165
173
|
activesupport (>= 4.0)
|
166
174
|
sprockets (>= 3.0.0)
|
167
|
-
sqlite3 (1.
|
168
|
-
thor (
|
169
|
-
|
170
|
-
travis (1.8.9)
|
175
|
+
sqlite3 (1.4.2)
|
176
|
+
thor (1.1.0)
|
177
|
+
travis (1.8.13)
|
171
178
|
backports
|
172
179
|
faraday (~> 0.9)
|
173
180
|
faraday_middleware (~> 0.9, >= 0.9.1)
|
@@ -178,34 +185,35 @@ GEM
|
|
178
185
|
typhoeus (~> 0.6, >= 0.6.8)
|
179
186
|
typhoeus (0.8.0)
|
180
187
|
ethon (>= 0.8.0)
|
181
|
-
tzinfo (
|
182
|
-
|
183
|
-
websocket (1.2.
|
184
|
-
websocket-driver (0.7.
|
188
|
+
tzinfo (2.0.4)
|
189
|
+
concurrent-ruby (~> 1.0)
|
190
|
+
websocket (1.2.9)
|
191
|
+
websocket-driver (0.7.3)
|
185
192
|
websocket-extensions (>= 0.1.0)
|
186
|
-
websocket-extensions (0.1.
|
187
|
-
will_paginate (3.
|
193
|
+
websocket-extensions (0.1.5)
|
194
|
+
will_paginate (3.3.0)
|
195
|
+
zeitwerk (2.4.2)
|
188
196
|
|
189
197
|
PLATFORMS
|
190
|
-
|
198
|
+
x86_64-darwin-19
|
191
199
|
|
192
200
|
DEPENDENCIES
|
193
201
|
active_model_serializers
|
194
202
|
activerecord-jdbc-adapter
|
195
203
|
activerecord-jdbcsqlite3-adapter
|
196
|
-
|
204
|
+
algolia (< 3.0.0)
|
197
205
|
jdbc-sqlite3
|
198
|
-
json (
|
199
|
-
kaminari
|
200
|
-
rails (~>
|
206
|
+
json (>= 1.5.1)
|
207
|
+
kaminari (< 1)
|
208
|
+
rails (~> 6.1)
|
201
209
|
rake (~> 10.1.0)
|
202
210
|
rdoc
|
203
211
|
redgreen
|
204
212
|
rspec (>= 2.5.0, < 3.0)
|
205
213
|
sequel (>= 4.0)
|
206
|
-
sqlite3 (
|
214
|
+
sqlite3 (~> 1.4.0)
|
207
215
|
travis
|
208
216
|
will_paginate (>= 2.3.15)
|
209
217
|
|
210
218
|
BUNDLED WITH
|
211
|
-
|
219
|
+
2.2.15
|
data/algoliasearch-rails.gemspec
CHANGED
@@ -79,7 +79,7 @@ Gem::Specification.new do |s|
|
|
79
79
|
|
80
80
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
81
81
|
s.add_runtime_dependency(%q<json>, [">= 1.5.1"])
|
82
|
-
s.add_runtime_dependency(%q<
|
82
|
+
s.add_runtime_dependency(%q<algolia>, ["< 3.0.0"])
|
83
83
|
s.add_development_dependency(%q<will_paginate>, [">= 2.3.15"])
|
84
84
|
s.add_development_dependency(%q<kaminari>, [">= 0"])
|
85
85
|
s.add_development_dependency "travis"
|
@@ -87,11 +87,11 @@ Gem::Specification.new do |s|
|
|
87
87
|
s.add_development_dependency "rdoc"
|
88
88
|
else
|
89
89
|
s.add_dependency(%q<json>, [">= 1.5.1"])
|
90
|
-
s.add_dependency(%q<
|
90
|
+
s.add_dependency(%q<algolia>, ["< 3.0.0"])
|
91
91
|
end
|
92
92
|
else
|
93
93
|
s.add_dependency(%q<json>, [">= 1.5.1"])
|
94
|
-
s.add_dependency(%q<
|
94
|
+
s.add_dependency(%q<algolia>, ["< 3.0.0"])
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
@@ -1,14 +1,29 @@
|
|
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})"
|
10
14
|
)
|
11
|
-
|
15
|
+
end
|
16
|
+
|
17
|
+
def client
|
18
|
+
if @client.nil?
|
19
|
+
setup_client
|
20
|
+
end
|
21
|
+
|
22
|
+
@client
|
23
|
+
end
|
24
|
+
|
25
|
+
def setup_client
|
26
|
+
@client = Algolia::Search::Client.create_with_config(Algolia::Search::Config.new(@@configuration))
|
12
27
|
end
|
13
28
|
end
|
14
29
|
end
|
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,18 +246,10 @@ module AlgoliaSearch
|
|
248
246
|
v = get_setting(k)
|
249
247
|
settings[k] = v if !v.nil?
|
250
248
|
end
|
251
|
-
if !@options[:
|
252
|
-
settings[:slaves] = additional_indexes.select { |opts, s| opts[:slave] }.map do |opts, s|
|
253
|
-
name = opts[:index_name]
|
254
|
-
name = "#{name}_#{Rails.env.to_s}" if opts[:per_environment]
|
255
|
-
name = "virtual(#{name})" if opts[:virtual]
|
256
|
-
name
|
257
|
-
end
|
258
|
-
settings.delete(:slaves) if settings[:slaves].empty?
|
249
|
+
if !@options[:replica]
|
259
250
|
settings[:replicas] = additional_indexes.select { |opts, s| opts[:replica] }.map do |opts, s|
|
260
251
|
name = opts[:index_name]
|
261
252
|
name = "#{name}_#{Rails.env.to_s}" if opts[:per_environment]
|
262
|
-
name = "virtual(#{name})" if opts[:virtual]
|
263
253
|
name
|
264
254
|
end
|
265
255
|
settings.delete(:replicas) if settings[:replicas].empty?
|
@@ -268,27 +258,20 @@ module AlgoliaSearch
|
|
268
258
|
end
|
269
259
|
|
270
260
|
def add_index(index_name, options = {}, &block)
|
271
|
-
raise ArgumentError.new('Cannot specify additional index on a replica index') if @options[:
|
261
|
+
raise ArgumentError.new('Cannot specify additional index on a replica index') if @options[:replica]
|
272
262
|
raise ArgumentError.new('No block given') if !block_given?
|
273
263
|
raise ArgumentError.new('Options auto_index and auto_remove cannot be set on nested indexes') if options[:auto_index] || options[:auto_remove]
|
274
264
|
@additional_indexes ||= {}
|
275
|
-
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] })
|
276
265
|
options[:index_name] = index_name
|
277
266
|
@additional_indexes[options] = IndexSettings.new(options, &block)
|
278
267
|
end
|
279
268
|
|
280
269
|
def add_replica(index_name, options = {}, &block)
|
281
|
-
raise ArgumentError.new('Cannot specify additional replicas on a replica index') if @options[:
|
270
|
+
raise ArgumentError.new('Cannot specify additional replicas on a replica index') if @options[:replica]
|
282
271
|
raise ArgumentError.new('No block given') if !block_given?
|
283
272
|
add_index(index_name, options.merge({ :replica => true, :primary_settings => self }), &block)
|
284
273
|
end
|
285
274
|
|
286
|
-
def add_slave(index_name, options = {}, &block)
|
287
|
-
raise ArgumentError.new('Cannot specify additional slaves on a slave index') if @options[:slave] || @options[:replica]
|
288
|
-
raise ArgumentError.new('No block given') if !block_given?
|
289
|
-
add_index(index_name, options.merge({ :slave => true, :primary_settings => self }), &block)
|
290
|
-
end
|
291
|
-
|
292
275
|
def additional_indexes
|
293
276
|
@additional_indexes || {}
|
294
277
|
end
|
@@ -306,11 +289,11 @@ module AlgoliaSearch
|
|
306
289
|
# are correctly logged or thrown depending on the `raise_on_failure` option
|
307
290
|
class SafeIndex
|
308
291
|
def initialize(name, raise_on_failure)
|
309
|
-
@index =
|
292
|
+
@index = AlgoliaSearch.client.init_index(name)
|
310
293
|
@raise_on_failure = raise_on_failure.nil? || raise_on_failure
|
311
294
|
end
|
312
295
|
|
313
|
-
::Algolia::Index.instance_methods(false).each do |m|
|
296
|
+
::Algolia::Search::Index.instance_methods(false).each do |m|
|
314
297
|
define_method(m) do |*args, &block|
|
315
298
|
SafeIndex.log_or_throw(m, @raise_on_failure) do
|
316
299
|
@index.send(m, *args, &block)
|
@@ -331,7 +314,7 @@ module AlgoliaSearch
|
|
331
314
|
SafeIndex.log_or_throw(:get_settings, @raise_on_failure) do
|
332
315
|
begin
|
333
316
|
@index.get_settings(*args)
|
334
|
-
rescue Algolia::
|
317
|
+
rescue Algolia::AlgoliaHttpError => e
|
335
318
|
return {} if e.code == 404 # not fatal
|
336
319
|
raise e
|
337
320
|
end
|
@@ -341,7 +324,7 @@ module AlgoliaSearch
|
|
341
324
|
# expose move as well
|
342
325
|
def self.move_index(old_name, new_name)
|
343
326
|
SafeIndex.log_or_throw(:move_index, true) do
|
344
|
-
|
327
|
+
AlgoliaSearch.client.move_index(old_name, new_name)
|
345
328
|
end
|
346
329
|
end
|
347
330
|
|
@@ -513,7 +496,7 @@ module AlgoliaSearch
|
|
513
496
|
algolia_configurations.each do |options, settings|
|
514
497
|
next if algolia_indexing_disabled?(options)
|
515
498
|
index = algolia_ensure_init(options, settings)
|
516
|
-
next if options[:
|
499
|
+
next if options[:replica]
|
517
500
|
last_task = nil
|
518
501
|
|
519
502
|
algolia_find_in_batches(batch_size) do |group|
|
@@ -533,7 +516,7 @@ module AlgoliaSearch
|
|
533
516
|
end
|
534
517
|
last_task = index.save_objects(objects)
|
535
518
|
end
|
536
|
-
index.wait_task(last_task["taskID"]) if last_task and (synchronous || options[:synchronous])
|
519
|
+
index.wait_task(last_task.raw_response["taskID"]) if last_task and (synchronous || options[:synchronous])
|
537
520
|
end
|
538
521
|
nil
|
539
522
|
end
|
@@ -543,7 +526,7 @@ module AlgoliaSearch
|
|
543
526
|
return if algolia_without_auto_index_scope
|
544
527
|
algolia_configurations.each do |options, settings|
|
545
528
|
next if algolia_indexing_disabled?(options)
|
546
|
-
next if options[:
|
529
|
+
next if options[:replica]
|
547
530
|
|
548
531
|
# fetch the master settings
|
549
532
|
master_index = algolia_ensure_init(options, settings)
|
@@ -551,8 +534,6 @@ module AlgoliaSearch
|
|
551
534
|
master_settings.merge!(JSON.parse(settings.to_settings.to_json)) # convert symbols to strings
|
552
535
|
|
553
536
|
# remove the replicas of the temporary index
|
554
|
-
master_settings.delete :slaves
|
555
|
-
master_settings.delete 'slaves'
|
556
537
|
master_settings.delete :replicas
|
557
538
|
master_settings.delete 'replicas'
|
558
539
|
|
@@ -564,7 +545,7 @@ module AlgoliaSearch
|
|
564
545
|
tmp_settings = settings.dup
|
565
546
|
|
566
547
|
if options[:check_settings] == false
|
567
|
-
|
548
|
+
@client.copy_index!(src_index_name, tmp_index_name, %w(settings synonyms rules))
|
568
549
|
tmp_index = SafeIndex.new(tmp_index_name, !!options[:raise_on_failure])
|
569
550
|
else
|
570
551
|
tmp_index = algolia_ensure_init(tmp_options, tmp_settings, master_settings)
|
@@ -580,7 +561,7 @@ module AlgoliaSearch
|
|
580
561
|
end
|
581
562
|
|
582
563
|
move_task = SafeIndex.move_index(tmp_index.name, src_index_name)
|
583
|
-
master_index.wait_task(move_task["taskID"]) if synchronous || options[:synchronous]
|
564
|
+
master_index.wait_task(move_task.raw_response["taskID"]) if synchronous || options[:synchronous]
|
584
565
|
end
|
585
566
|
nil
|
586
567
|
end
|
@@ -589,8 +570,6 @@ module AlgoliaSearch
|
|
589
570
|
algolia_configurations.each do |options, settings|
|
590
571
|
if options[:primary_settings] && options[:inherit]
|
591
572
|
primary = options[:primary_settings].to_settings
|
592
|
-
primary.delete :slaves
|
593
|
-
primary.delete 'slaves'
|
594
573
|
primary.delete :replicas
|
595
574
|
primary.delete 'replicas'
|
596
575
|
final_settings = primary.merge(settings.to_settings)
|
@@ -600,7 +579,7 @@ module AlgoliaSearch
|
|
600
579
|
|
601
580
|
index = SafeIndex.new(algolia_index_name(options), true)
|
602
581
|
task = index.set_settings(final_settings)
|
603
|
-
index.wait_task(task["taskID"]) if synchronous
|
582
|
+
index.wait_task(task.raw_response["taskID"]) if synchronous
|
604
583
|
end
|
605
584
|
end
|
606
585
|
|
@@ -608,9 +587,9 @@ module AlgoliaSearch
|
|
608
587
|
algolia_configurations.each do |options, settings|
|
609
588
|
next if algolia_indexing_disabled?(options)
|
610
589
|
index = algolia_ensure_init(options, settings)
|
611
|
-
next if options[:
|
590
|
+
next if options[:replica]
|
612
591
|
task = index.save_objects(objects.map { |o| settings.get_attributes(o).merge 'objectID' => algolia_object_id_of(o, options) })
|
613
|
-
index.wait_task(task["taskID"]) if synchronous || options[:synchronous]
|
592
|
+
index.wait_task(task.raw_response["taskID"]) if synchronous || options[:synchronous]
|
614
593
|
end
|
615
594
|
end
|
616
595
|
|
@@ -620,13 +599,13 @@ module AlgoliaSearch
|
|
620
599
|
next if algolia_indexing_disabled?(options)
|
621
600
|
object_id = algolia_object_id_of(object, options)
|
622
601
|
index = algolia_ensure_init(options, settings)
|
623
|
-
next if options[:
|
602
|
+
next if options[:replica]
|
624
603
|
if algolia_indexable?(object, options)
|
625
604
|
raise ArgumentError.new("Cannot index a record with a blank objectID") if object_id.blank?
|
626
605
|
if synchronous || options[:synchronous]
|
627
|
-
index.
|
606
|
+
index.save_object!(settings.get_attributes(object).merge 'objectID' => algolia_object_id_of(object, options))
|
628
607
|
else
|
629
|
-
index.
|
608
|
+
index.save_object(settings.get_attributes(object).merge 'objectID' => algolia_object_id_of(object, options))
|
630
609
|
end
|
631
610
|
elsif algolia_conditional_index?(options) && !object_id.blank?
|
632
611
|
# remove non-indexable objects
|
@@ -647,7 +626,7 @@ module AlgoliaSearch
|
|
647
626
|
algolia_configurations.each do |options, settings|
|
648
627
|
next if algolia_indexing_disabled?(options)
|
649
628
|
index = algolia_ensure_init(options, settings)
|
650
|
-
next if options[:
|
629
|
+
next if options[:replica]
|
651
630
|
if synchronous || options[:synchronous]
|
652
631
|
index.delete_object!(object_id)
|
653
632
|
else
|
@@ -661,8 +640,8 @@ module AlgoliaSearch
|
|
661
640
|
algolia_configurations.each do |options, settings|
|
662
641
|
next if algolia_indexing_disabled?(options)
|
663
642
|
index = algolia_ensure_init(options, settings)
|
664
|
-
next if options[:
|
665
|
-
synchronous || options[:synchronous] ? index.
|
643
|
+
next if options[:replica]
|
644
|
+
synchronous || options[:synchronous] ? index.clear_objects! : index.clear_objects
|
666
645
|
@algolia_indexes[settings] = nil
|
667
646
|
end
|
668
647
|
nil
|
@@ -671,8 +650,6 @@ module AlgoliaSearch
|
|
671
650
|
def algolia_raw_search(q, params = {})
|
672
651
|
index_name = params.delete(:index) ||
|
673
652
|
params.delete('index') ||
|
674
|
-
params.delete(:slave) ||
|
675
|
-
params.delete('slave') ||
|
676
653
|
params.delete(:replica) ||
|
677
654
|
params.delete('replica')
|
678
655
|
index = algolia_index(index_name)
|
@@ -737,13 +714,11 @@ module AlgoliaSearch
|
|
737
714
|
def algolia_search_for_facet_values(facet, text, params = {})
|
738
715
|
index_name = params.delete(:index) ||
|
739
716
|
params.delete('index') ||
|
740
|
-
params.delete(:slave) ||
|
741
|
-
params.delete('slave') ||
|
742
717
|
params.delete(:replica) ||
|
743
718
|
params.delete('replicas')
|
744
719
|
index = algolia_index(index_name)
|
745
720
|
query = Hash[params.map { |k, v| [k.to_s, v.to_s] }]
|
746
|
-
index.
|
721
|
+
index.search_for_facet_values(facet, text, query)['facetHits']
|
747
722
|
end
|
748
723
|
|
749
724
|
# deprecated (renaming)
|
@@ -772,7 +747,7 @@ module AlgoliaSearch
|
|
772
747
|
# Loop over each index to see if a attribute used in records has changed
|
773
748
|
algolia_configurations.each do |options, settings|
|
774
749
|
next if algolia_indexing_disabled?(options)
|
775
|
-
next if options[:
|
750
|
+
next if options[:replica]
|
776
751
|
return true if algolia_object_id_changed?(object, options)
|
777
752
|
settings.get_attribute_names(object).each do |k|
|
778
753
|
return true if algolia_attribute_changed?(object, k)
|
@@ -817,13 +792,10 @@ module AlgoliaSearch
|
|
817
792
|
options[:check_settings] = true if options[:check_settings].nil?
|
818
793
|
|
819
794
|
if !algolia_indexing_disabled?(options) && options[:check_settings] && algoliasearch_settings_changed?(current_settings, index_settings)
|
820
|
-
used_slaves = !current_settings.nil? && !current_settings['slaves'].nil?
|
821
795
|
replicas = index_settings.delete(:replicas) ||
|
822
|
-
index_settings.delete('replicas')
|
823
|
-
|
824
|
-
|
825
|
-
index_settings[used_slaves ? :slaves : :replicas] = replicas unless replicas.nil? || options[:inherit]
|
826
|
-
@algolia_indexes[settings].set_settings(index_settings)
|
796
|
+
index_settings.delete('replicas')
|
797
|
+
index_settings[:replicas] = replicas unless replicas.nil? || options[:inherit]
|
798
|
+
@algolia_indexes[settings].set_settings!(index_settings)
|
827
799
|
end
|
828
800
|
|
829
801
|
@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
|
data/spec/utilities_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
2
2
|
|
3
|
-
AlgoliaSearch.configuration = { :application_id => ENV['ALGOLIA_APPLICATION_ID'], :api_key => ENV['ALGOLIA_API_KEY'] }
|
3
|
+
AlgoliaSearch.configuration = { :application_id => ENV['ALGOLIA_APPLICATION_ID'], :api_key => ENV['ALGOLIA_API_KEY'], :symbolize_keys => false }
|
4
4
|
|
5
5
|
describe AlgoliaSearch::Utilities do
|
6
6
|
|
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:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Algolia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-03 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
|
@@ -188,7 +182,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
188
182
|
- !ruby/object:Gem::Version
|
189
183
|
version: '0'
|
190
184
|
requirements: []
|
191
|
-
|
185
|
+
rubyforge_project:
|
186
|
+
rubygems_version: 2.7.6.2
|
192
187
|
signing_key:
|
193
188
|
specification_version: 4
|
194
189
|
summary: AlgoliaSearch integration to your favorite ORM
|