algoliasearch-rails 1.11.9 → 1.11.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aa581c6313d0319f6f2ab57c1866d0ae29880e58
4
- data.tar.gz: 50a8dff40a3cebbb5edf6ace582feffe2099b80f
3
+ metadata.gz: 28d26c0a0fe53deee76c8f23007456d36e410f2a
4
+ data.tar.gz: e858cb10664d36b50bed01ad419b4a36113ae44e
5
5
  SHA512:
6
- metadata.gz: 4cfad0c8a2097f9b50ad4fd8f64b5fc56139cfb49210f55de10e6ad79948fe16ea2358f16cbc242bbb81341ec7ab78d6129434dbfba770067fd5f5b637ff71bd
7
- data.tar.gz: b4d78b082de194b6666e7bca526c06b8e6cbc20822e4daa227ad50319cdd1033663efb44f6574828c085e4647cffd60def89a12b137ae030e4ab0be22e12de82
6
+ metadata.gz: f751938f584dc7288d54a04a572da2d79c5b39d757c8696e9604d17a246865e10a9a6d98eb928f537dfbb7ea812af9c1afa2e756647da5523c2bed4034ceaca8
7
+ data.tar.gz: 3177dec960887a6c7371551275aa025e9d71d17cff71527ed556df8e963c02530a146652252bb00e11c23ec6d70e3f34b02d28912462bf15c4949083e8ae7a07
data/ChangeLog CHANGED
@@ -1,5 +1,9 @@
1
1
  CHANGELOG
2
2
 
3
+ 2014-11-21 1.11.10
4
+
5
+ * Ability to force the UTF-8 encoding of the underlying attributes before sending them to our API
6
+
3
7
  2014-11-12 1.11.9
4
8
 
5
9
  * Upgraded algoliasearch JavaScript client to 2.7.4 & algoliasearch-client-ruby to 1.2.14
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.9
1
+ 1.11.10
@@ -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.9
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-12 00:00:00.000000000 Z
11
+ date: 2014-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json