algoliasearch-rails 1.10.3 → 1.10.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 675a8f42e7841895e66f88e9f4d550b59222d4e5
4
- data.tar.gz: f832cadef3b8bef0c50b4f49f474423d1c40e3b2
3
+ metadata.gz: 7d6329550086f9eea99ae35aa6111fc515e8804c
4
+ data.tar.gz: e5f7dc994433e9d927252a1b2c1c9b69e8fa18cc
5
5
  SHA512:
6
- metadata.gz: 10324137c57a424b127bdf4440bcc326e5c44f3558411973b76a83083d22f514d78b354c6c47cfbfa876c537d067d91b8896a867ef6ae48874dbd6be258086f6
7
- data.tar.gz: 1a717beffdfe5507c5bf954e2dd6e6f29f2a157a1d1799b20f523993496b2cd134205a0d73cf8d2fe1781236805f0e3f09a9293c3ba6fef09c52227d6f315fa7
6
+ metadata.gz: 582679d281ba1dcddaa2ab478fb17129719d3c02013f8f0d6cc762b5bf488594a6a745ff754fa671b64d55557bfd9b5ffcba0de8762210fa2fe22d150e80f3cc
7
+ data.tar.gz: 7237460c4e85f5e8f8178eeae72388098b77059ce1822c006e7d0c4c48c9b6128678963c4bac0baf5367b96a5639489eee606c0fee6f1d8c44c8554925b7a518
data/ChangeLog CHANGED
@@ -1,8 +1,12 @@
1
1
  CHANGELOG
2
2
 
3
+ 2014-06-28 1.10.4
4
+
5
+ * Ability to disable all indexing tasks (testing purpose)
6
+
3
7
  2014-06-17 1.10.3
4
8
 
5
- * Kaminari: pad the result array to match the options/offset parameters
9
+ * Pagination: fixed a padding issue with recent versions of Kaminari
6
10
 
7
11
  2014-05-09 1.10.2
8
12
 
data/README.md CHANGED
@@ -578,7 +578,25 @@ Note on testing
578
578
 
579
579
  To run the specs, please set the <code>ALGOLIA_APPLICATION_ID</code> and <code>ALGOLIA_API_KEY</code> environment variables. Since the tests are creating and removing indexes, DO NOT use your production account.
580
580
 
581
- You may want to mock Algolia's API calls. We provide a [WebMock](https://github.com/bblimke/webmock) configuration that you can use including `algolia/webmock`:
581
+ You may want to disable all indexing (add, update & delete operations) API calls, you can set the ```disable_indexing``` option:
582
+
583
+ ```ruby
584
+ class User < ActiveRecord::Base
585
+ include AlgoliaSearch
586
+
587
+ algoliasearch :per_environment => true, :disable_indexing => Rails.env.test? do
588
+ end
589
+ end
590
+
591
+ class User < ActiveRecord::Base
592
+ include AlgoliaSearch
593
+
594
+ algoliasearch :per_environment => true, :disable_indexing => Proc.new { Rails.env.test? || more_complex_condition } do
595
+ end
596
+ end
597
+ ```
598
+
599
+ 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`:
582
600
 
583
601
  ```ruby
584
602
  require 'algolia/webmock'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.10.3
1
+ 1.10.4
@@ -6,11 +6,11 @@
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "algoliasearch-rails"
9
- s.version = "1.10.3"
9
+ s.version = "1.10.4"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.authors = ["Algolia"]
13
- s.date = "2014-06-17"
13
+ s.date = "2014-06-28"
14
14
  s.description = "AlgoliaSearch integration to your favorite ORM"
15
15
  s.email = "contact@algolia.com"
16
16
  s.extra_rdoc_files = [
@@ -199,6 +199,7 @@ module AlgoliaSearch
199
199
  def algolia_reindex!(batch_size = 1000, synchronous = false)
200
200
  return if @algolia_without_auto_index_scope
201
201
  algolia_configurations.each do |options, settings|
202
+ next if algolia_indexing_disabled?(options)
202
203
  index = algolia_ensure_init(options, settings)
203
204
  next if options[:slave]
204
205
  last_task = nil
@@ -222,6 +223,7 @@ module AlgoliaSearch
222
223
 
223
224
  def algolia_index_objects(objects, synchronous = false)
224
225
  algolia_configurations.each do |options, settings|
226
+ next if algolia_indexing_disabled?(options)
225
227
  index = algolia_ensure_init(options, settings)
226
228
  next if options[:slave]
227
229
  task = index.save_objects(objects.map { |o| settings.get_attributes(o).merge 'objectID' => algolia_object_id_of(o, options) })
@@ -232,6 +234,7 @@ module AlgoliaSearch
232
234
  def algolia_index!(object, synchronous = false)
233
235
  return if @algolia_without_auto_index_scope
234
236
  algolia_configurations.each do |options, settings|
237
+ next if algolia_indexing_disabled?(options)
235
238
  object_id = algolia_object_id_of(object, options)
236
239
  raise ArgumentError.new("Cannot index a blank objectID") if object_id.blank?
237
240
  index = algolia_ensure_init(options, settings)
@@ -259,6 +262,7 @@ module AlgoliaSearch
259
262
  object_id = algolia_object_id_of(object)
260
263
  raise ArgumentError.new("Cannot index a blank objectID") if object_id.blank?
261
264
  algolia_configurations.each do |options, settings|
265
+ next if algolia_indexing_disabled?(options)
262
266
  index = algolia_ensure_init(options, settings)
263
267
  next if options[:slave]
264
268
  if synchronous
@@ -272,6 +276,7 @@ module AlgoliaSearch
272
276
 
273
277
  def algolia_clear_index!(synchronous = false)
274
278
  algolia_configurations.each do |options, settings|
279
+ next if algolia_indexing_disabled?(options)
275
280
  index = algolia_ensure_init(options, settings)
276
281
  next if options[:slave]
277
282
  synchronous ? index.clear! : index.clear
@@ -374,7 +379,7 @@ module AlgoliaSearch
374
379
  return @algolia_indexes[settings] if @algolia_indexes[settings]
375
380
  @algolia_indexes[settings] = Algolia::Index.new(algolia_index_name(options))
376
381
  current_settings = @algolia_indexes[settings].get_settings rescue nil # if the index doesn't exist
377
- @algolia_indexes[settings].set_settings(settings.to_settings) if algoliasearch_settings_changed?(current_settings, settings.to_settings)
382
+ @algolia_indexes[settings].set_settings(settings.to_settings) if !algolia_indexing_disabled?(options) && algoliasearch_settings_changed?(current_settings, settings.to_settings)
378
383
  @algolia_indexes[settings]
379
384
  end
380
385
 
@@ -461,6 +466,20 @@ module AlgoliaSearch
461
466
  end
462
467
  end
463
468
 
469
+ def algolia_indexing_disabled?(options = nil)
470
+ options ||= algoliasearch_options
471
+ constraint = options[:disable_indexing] || options['disable_indexing']
472
+ if constraint.nil?
473
+ false
474
+ elsif constraint == true || constraint == false
475
+ constraint
476
+ elsif constraint.respond_to?(:call) # Proc
477
+ constraint.call
478
+ else
479
+ raise ArgumentError, "Unknown constraint type: #{constraint} (#{constraint.class})"
480
+ end
481
+ end
482
+
464
483
  def algolia_find_in_batches(batch_size, &block)
465
484
  if (defined?(::ActiveRecord) && ancestors.include?(::ActiveRecord::Base)) || respond_to?(:find_in_batches)
466
485
  find_in_batches(:batch_size => batch_size, &block)
metadata CHANGED
@@ -1,111 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: algoliasearch-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.3
4
+ version: 1.10.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Algolia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-17 00:00:00.000000000 Z
11
+ date: 2014-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.5.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.5.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: algoliasearch
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.2.5
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.2.5
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: will_paginate
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: 2.3.15
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: 2.3.15
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: kaminari
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: travis
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rdoc
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  description: AlgoliaSearch integration to your favorite ORM
@@ -117,9 +117,9 @@ extra_rdoc_files:
117
117
  - LICENSE
118
118
  - README.md
119
119
  files:
120
- - .document
121
- - .rspec
122
- - .travis.yml
120
+ - ".document"
121
+ - ".rspec"
122
+ - ".travis.yml"
123
123
  - ChangeLog
124
124
  - Gemfile
125
125
  - Gemfile.lock
@@ -154,12 +154,12 @@ require_paths:
154
154
  - lib
155
155
  required_ruby_version: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - '>='
157
+ - - ">="
158
158
  - !ruby/object:Gem::Version
159
159
  version: '0'
160
160
  required_rubygems_version: !ruby/object:Gem::Requirement
161
161
  requirements:
162
- - - '>='
162
+ - - ">="
163
163
  - !ruby/object:Gem::Version
164
164
  version: '0'
165
165
  requirements: []