algoliasearch-rails 1.11.11 → 1.11.12

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: b7e0beb5d468bb3e779a277b898e76e95f700da7
4
- data.tar.gz: fc59247435ee0df6e4048ec44f2126d3d20b1e8b
3
+ metadata.gz: e8acb586d687a6f969b2bf65d918df3d90928fa2
4
+ data.tar.gz: 1ecee0a5c9d4397e52e194982ce77e370def3452
5
5
  SHA512:
6
- metadata.gz: 0c3007273908b5b1f2709dc11e2de88f315629dae96de6d34a6979ec3ca56bc9d5f65c1f2f696709621c278b1d8cae287c796c9b00f25667af3d321fa1f3d703
7
- data.tar.gz: 3a1d3bd7077e9d34299bf6f1ae740d0f57dd8d3c1c1addb52172b4bc4781eb953ff2dc2881d10c461d38fd478d2bfb4f9f4aaab98965d67d978356f726cf39b9
6
+ metadata.gz: c6c787e1009b2ad28c6cd2098c32c629bb74602ee18b4646b6f8625c23b51d448227aee631ca27b205e292f9ee26feb7f971a93492bfca6805fff528085da116
7
+ data.tar.gz: 0bb8c9eba4902b3ac0a11ab9aaa0660a2daf45b547ff9fc5d1287f31c9aa3adf5c051dcc0588a63da223cccb695abe792cbf82cc2271be98da5151c8b61acf01
data/ChangeLog CHANGED
@@ -1,5 +1,9 @@
1
1
  CHANGELOG
2
2
 
3
+ 2015-01-29 1.11.12
4
+
5
+ * Fixed potential namespace issue while trying to load the HTML sanitizer
6
+
3
7
  2014-11-27 1.11.11
4
8
 
5
9
  * Upgraded algoliasearch JavaScript client to 2.7.5 to prepare TLD migration
data/README.md CHANGED
@@ -1,13 +1,12 @@
1
1
  Algolia Search for Rails
2
2
  ==================
3
3
 
4
- 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.
4
+ 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. Both Rails 3.x and Rails 4.x are supported.
5
5
 
6
6
  You might be interested in the sample Ruby on Rails application providing a ```typeahead.js```-based auto-completion and ```Google```-like instant search: [algoliasearch-rails-example](https://github.com/algolia/algoliasearch-rails-example/).
7
7
 
8
8
  [![Build Status](https://travis-ci.org/algolia/algoliasearch-rails.png?branch=master)](https://travis-ci.org/algolia/algoliasearch-rails) [![Gem Version](https://badge.fury.io/rb/algoliasearch-rails.png)](http://badge.fury.io/rb/algoliasearch-rails) [![Code Climate](https://codeclimate.com/github/algolia/algoliasearch-rails.png)](https://codeclimate.com/github/algolia/algoliasearch-rails)
9
9
 
10
-
11
10
  Table of Content
12
11
  -------------
13
12
  **Get started**
@@ -35,7 +34,7 @@ Install
35
34
  gem install algoliasearch-rails
36
35
  ```
37
36
 
38
- If you are using Rails 3, add the gem to your <code>Gemfile</code>:
37
+ Add the gem to your <code>Gemfile</code>:
39
38
 
40
39
  ```ruby
41
40
  gem "algoliasearch-rails"
@@ -163,7 +162,7 @@ You can temporary disable auto-indexing using the <code>without_auto_index</code
163
162
  ```ruby
164
163
  Contact.delete_all
165
164
  Contact.without_auto_index do
166
- 1.upto(10000) { Contact.create! attributes } # inside the block, auto indexing task will noop
165
+ 1.upto(10000) { Contact.create! attributes } # inside this block, auto indexing task will not run.
167
166
  end
168
167
  Contact.reindex! # will use batch operations
169
168
  ```
@@ -182,7 +181,7 @@ end
182
181
 
183
182
  #### Custom index name
184
183
 
185
- You can force the index name using the following option:
184
+ By default, the index name will be the class name, e.g. "Contact". You can customize the index name by using the `index_name` option:
186
185
 
187
186
  ```ruby
188
187
  class Contact < ActiveRecord::Base
@@ -249,6 +248,32 @@ class Contact < ActiveRecord::Base
249
248
  end
250
249
  ```
251
250
 
251
+ #### Nested objects/relations
252
+
253
+ You can easily embed nested objects defining an extra attribute returning any JSON-compliant object (an array or a hash or a combination of both).
254
+
255
+ ```ruby
256
+ class Profile < ActiveRecord::Base
257
+ include AlgoliaSearch
258
+
259
+ belongs_to :user
260
+ has_many :specializations
261
+
262
+ algoliasearch do
263
+ attribute :user do
264
+ # restrict the nested "user" object to its `name` + `email`
265
+ { name: user.name, email: user.email }
266
+ end
267
+ attribute :public_specializations do
268
+ # build an array of public specialization (include only `title` and `another_attr`)
269
+ specializations.select { |s| s.public? }.map do |s|
270
+ { title: s.title, another_attr: s.another_attr }
271
+ end
272
+ end
273
+ end
274
+
275
+ end
276
+ ```
252
277
 
253
278
  #### Custom ```objectID```
254
279
 
@@ -332,6 +357,13 @@ end
332
357
 
333
358
  ```
334
359
 
360
+ If you're using Rails 4.2+, you also need to depend on `rails-html-sanitizer`:
361
+
362
+ ```ruby
363
+ gem 'rails-html-sanitizer'
364
+ ```
365
+
366
+
335
367
  #### UTF-8 Encoding
336
368
 
337
369
  You can force the UTF-8 encoding of all your attributes using the ```force_utf8_encoding``` option:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.11.11
1
+ 1.11.12
@@ -103,7 +103,12 @@ module AlgoliaSearch
103
103
  end
104
104
 
105
105
  if @options[:sanitize]
106
- sanitizer = HTML::FullSanitizer.new
106
+ sanitizer = begin
107
+ ::HTML::FullSanitizer.new
108
+ rescue NameError
109
+ # from rails 4.2
110
+ ::Rails::Html::FullSanitizer.new
111
+ end
107
112
  attributes = sanitize_attributes(attributes, sanitizer)
108
113
  end
109
114
 
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.11
4
+ version: 1.11.12
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-27 00:00:00.000000000 Z
11
+ date: 2015-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json