algoliasearch-rails 1.11.9 → 1.11.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +4 -0
- data/README.md +17 -0
- data/VERSION +1 -1
- data/lib/algoliasearch-rails.rb +17 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28d26c0a0fe53deee76c8f23007456d36e410f2a
|
4
|
+
data.tar.gz: e858cb10664d36b50bed01ad419b4a36113ae44e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f751938f584dc7288d54a04a572da2d79c5b39d757c8696e9604d17a246865e10a9a6d98eb928f537dfbb7ea812af9c1afa2e756647da5523c2bed4034ceaca8
|
7
|
+
data.tar.gz: 3177dec960887a6c7371551275aa025e9d71d17cff71527ed556df8e963c02530a146652252bb00e11c23ec6d70e3f34b02d28912462bf15c4949083e8ae7a07
|
data/ChangeLog
CHANGED
data/README.md
CHANGED
@@ -332,6 +332,23 @@ end
|
|
332
332
|
|
333
333
|
```
|
334
334
|
|
335
|
+
#### UTF-8 Encoding
|
336
|
+
|
337
|
+
You can force the UTF-8 encoding of all your attributes using the ```force_utf8_encoding``` option:
|
338
|
+
|
339
|
+
```ruby
|
340
|
+
class User < ActiveRecord::Base
|
341
|
+
include AlgoliaSearch
|
342
|
+
|
343
|
+
algoliasearch force_utf8_encoding: true do
|
344
|
+
attributes :name, :email, :company
|
345
|
+
end
|
346
|
+
end
|
347
|
+
|
348
|
+
```
|
349
|
+
|
350
|
+
***Notes:*** This option is not compatible with Ruby 1.8
|
351
|
+
|
335
352
|
|
336
353
|
Configuration example
|
337
354
|
---------------------
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.11.
|
1
|
+
1.11.10
|
data/lib/algoliasearch-rails.rb
CHANGED
@@ -107,6 +107,10 @@ module AlgoliaSearch
|
|
107
107
|
attributes = sanitize_attributes(attributes, sanitizer)
|
108
108
|
end
|
109
109
|
|
110
|
+
if @options[:force_utf8_encoding] && Object.const_defined?(:RUBY_VERSION) && RUBY_VERSION.to_f > 1.8
|
111
|
+
attributes = encode_attributes(attributes)
|
112
|
+
end
|
113
|
+
|
110
114
|
attributes
|
111
115
|
end
|
112
116
|
|
@@ -123,6 +127,19 @@ module AlgoliaSearch
|
|
123
127
|
end
|
124
128
|
end
|
125
129
|
|
130
|
+
def encode_attributes(v)
|
131
|
+
case v
|
132
|
+
when String
|
133
|
+
v.force_encoding('utf-8')
|
134
|
+
when Hash
|
135
|
+
v.each { |key, value| v[key] = encode_attributes(value) }
|
136
|
+
when Array
|
137
|
+
v.map { |x| encode_attributes(x) }
|
138
|
+
else
|
139
|
+
v
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
126
143
|
def geoloc(lat_attr, lng_attr)
|
127
144
|
raise ArgumentError.new('Cannot specify additional attributes on a slave index') if @options[:slave]
|
128
145
|
add_attribute :_geoloc do |o|
|
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.11.
|
4
|
+
version: 1.11.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Algolia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|