algoliasearch-rails 1.9.1 → 1.9.2

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: 3cbdcfe7f8699286453342d8bf324eb3368b4575
4
- data.tar.gz: 21526f15062e4c576c6a3cf24cf4e2dcbda8840e
3
+ metadata.gz: e635be8a862c1b400648ec0873a4b6fc0a3130cd
4
+ data.tar.gz: 538164527a1e15d90b0633857a274ac2cdf8af0a
5
5
  SHA512:
6
- metadata.gz: ff280f0b1e519117e6906b65098a385d42f7e98823534fbf3796bcf4d44875cbb04bbcb4cc676681f0f5d4acdccf59972287f429176af31c99f1eacb0bc9c51b
7
- data.tar.gz: fc656606f50370e9e64c5636a7b1ba2253e9dba93f6af652a337d89d2ccfb1166198c1abb314c721aad7209dd1e604ffeeee67c0928af1ea8b8b7d9e389c801e
6
+ metadata.gz: 09612510c5fc94be32f0e24d11878c81b9a748e8c0c137fbc8faa35c9c00921f61eaad8a3235eff78c3d9249d83b86410e0be3c8e84da7cd37520be2e853764a
7
+ data.tar.gz: 7b56015514e9eae09cd479a0dd16168abfdfe8fca3db309afea5904f9a222af2804995928f974e829b55527b6b3288726a28cce967847bcd1f74f185fe7a3fcd
data/ChangeLog CHANGED
@@ -1,10 +1,13 @@
1
1
  CHANGELOG
2
2
 
3
+ 2014-03-17 1.9.2
4
+
5
+ * Raise an exception while attempting to index a non-saved object (blank objectID)
6
+
3
7
  2014-03-06 1.9.1
4
8
 
5
9
  * When using MongoId, the `reindex!` method was calling add_objects too many times. (credits go to sush.io)
6
10
 
7
-
8
11
  2014-02-24 1.9.0
9
12
 
10
13
  * Upgrade to algoliasearch 1.2.5 and algoliasearch-client-js 2.4.2
data/Gemfile CHANGED
@@ -6,7 +6,7 @@ gem 'rubysl', '~> 2.0', platform: :rbx
6
6
 
7
7
  group :test do
8
8
  gem 'rspec', '>= 2.5.0'
9
- gem 'activerecord', '>= 3.0.7'
9
+ gem 'rails', '>= 3.0.7'
10
10
  gem 'sqlite3', platform: [:rbx, :ruby]
11
11
  gem 'jdbc-sqlite3', platform: :jruby
12
12
  gem 'activerecord-jdbc-adapter', platform: :jruby
@@ -18,9 +18,12 @@ group :test do
18
18
  end
19
19
 
20
20
  group :development do
21
- gem 'will_paginate', '>= 2.3.15'
22
- gem 'kaminari'
23
21
  gem 'travis'
24
22
  gem 'rake'
25
23
  gem 'rdoc'
26
24
  end
25
+
26
+ group :test, :development do
27
+ gem 'will_paginate', '>= 2.3.15'
28
+ gem 'kaminari'
29
+ end
@@ -2,6 +2,9 @@ GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
4
  ZenTest (4.9.5)
5
+ actionmailer (4.0.2)
6
+ actionpack (= 4.0.2)
7
+ mail (~> 2.5.4)
5
8
  actionpack (4.0.2)
6
9
  activesupport (= 4.0.2)
7
10
  builder (~> 3.1.0)
@@ -33,8 +36,8 @@ GEM
33
36
  httpclient (~> 2.3)
34
37
  json (>= 1.5.1)
35
38
  arel (4.0.1)
36
- atomic (1.1.14)
37
- atomic (1.1.14-java)
39
+ atomic (1.1.15)
40
+ atomic (1.1.15-java)
38
41
  autotest (4.4.6)
39
42
  ZenTest (>= 4.4.1)
40
43
  autotest-fsevent (0.2.9)
@@ -63,6 +66,7 @@ GEM
63
66
  net-http-persistent (>= 2.7)
64
67
  net-http-pipeline
65
68
  highline (1.6.20)
69
+ hike (1.2.3)
66
70
  httpclient (2.3.4.1)
67
71
  i18n (0.6.9)
68
72
  jdbc-sqlite3 (3.7.2.1)
@@ -76,13 +80,17 @@ GEM
76
80
  launchy (2.4.2-java)
77
81
  addressable (~> 2.3)
78
82
  spoon (~> 0.0.1)
83
+ mail (2.5.4)
84
+ mime-types (~> 1.16)
85
+ treetop (~> 1.4.8)
79
86
  method_source (0.8.2)
80
87
  mime-types (1.25.1)
81
88
  minitest (4.7.5)
82
- multi_json (1.8.4)
89
+ multi_json (1.9.0)
83
90
  multipart-post (1.2.0)
84
91
  net-http-persistent (2.9.1)
85
92
  net-http-pipeline (1.0.1)
93
+ polyglot (0.3.4)
86
94
  pry (0.9.12.6)
87
95
  coderay (~> 1.0)
88
96
  method_source (~> 0.8)
@@ -97,6 +105,19 @@ GEM
97
105
  rack (1.5.2)
98
106
  rack-test (0.6.2)
99
107
  rack (>= 1.0)
108
+ rails (4.0.2)
109
+ actionmailer (= 4.0.2)
110
+ actionpack (= 4.0.2)
111
+ activerecord (= 4.0.2)
112
+ activesupport (= 4.0.2)
113
+ bundler (>= 1.3.0, < 2.0)
114
+ railties (= 4.0.2)
115
+ sprockets-rails (~> 2.0.0)
116
+ railties (4.0.2)
117
+ actionpack (= 4.0.2)
118
+ activesupport (= 4.0.2)
119
+ rake (>= 0.8.7)
120
+ thor (>= 0.18.1, < 2.0)
100
121
  rake (10.1.1)
101
122
  rdoc (4.1.1)
102
123
  json (~> 1.4)
@@ -314,13 +335,24 @@ GEM
314
335
  slop (3.4.7)
315
336
  spoon (0.0.4)
316
337
  ffi
338
+ sprockets (2.10.1)
339
+ hike (~> 1.2)
340
+ multi_json (~> 1.0)
341
+ rack (~> 1.0)
342
+ tilt (~> 1.1, != 1.3.0)
343
+ sprockets-rails (2.0.1)
344
+ actionpack (>= 3.0)
345
+ activesupport (>= 3.0)
346
+ sprockets (~> 2.8)
317
347
  sqlite3 (1.3.8)
318
348
  sys-uname (0.9.2)
319
349
  ffi (>= 1.0.0)
320
- thread_safe (0.1.3)
321
- atomic
322
- thread_safe (0.1.3-java)
323
- atomic
350
+ thor (0.18.1)
351
+ thread_safe (0.2.0)
352
+ atomic (>= 1.1.7, < 2)
353
+ thread_safe (0.2.0-java)
354
+ atomic (>= 1.1.7, < 2)
355
+ tilt (1.4.1)
324
356
  travis (1.6.7)
325
357
  addressable (~> 2.3)
326
358
  backports
@@ -332,9 +364,12 @@ GEM
332
364
  pry (~> 0.9)
333
365
  pusher-client (~> 0.4)
334
366
  typhoeus (~> 0.6)
367
+ treetop (1.4.15)
368
+ polyglot
369
+ polyglot (>= 0.3.1)
335
370
  typhoeus (0.6.7)
336
371
  ethon (~> 0.6.2)
337
- tzinfo (0.3.38)
372
+ tzinfo (0.3.39)
338
373
  websocket (1.0.7)
339
374
  will_paginate (3.0.5)
340
375
 
@@ -343,7 +378,6 @@ PLATFORMS
343
378
  ruby
344
379
 
345
380
  DEPENDENCIES
346
- activerecord (>= 3.0.7)
347
381
  activerecord-jdbc-adapter
348
382
  activerecord-jdbcsqlite3-adapter
349
383
  algoliasearch (~> 1.2)
@@ -353,6 +387,7 @@ DEPENDENCIES
353
387
  jdbc-sqlite3
354
388
  json (>= 1.5.1)
355
389
  kaminari
390
+ rails (>= 3.0.7)
356
391
  rake
357
392
  rdoc
358
393
  redgreen
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.9.1
1
+ 1.9.2
@@ -6,11 +6,11 @@
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "algoliasearch-rails"
9
- s.version = "1.9.1"
9
+ s.version = "1.9.2"
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-03-06"
13
+ s.date = "2014-03-17"
14
14
  s.description = "AlgoliaSearch integration to your favorite ORM"
15
15
  s.email = "contact@algolia.com"
16
16
  s.extra_rdoc_files = [
@@ -187,30 +187,34 @@ module AlgoliaSearch
187
187
 
188
188
  def algolia_index!(object, synchronous = false)
189
189
  return if @algolia_without_auto_index_scope
190
+ object_id = algolia_object_id_of(object)
191
+ raise ArgumentError.new("Cannot index a blank objectID") if object_id.blank?
190
192
  algolia_ensure_init
191
193
  if algolia_indexable?(object)
192
194
  if synchronous
193
- @algolia_index.add_object!(algolia_index_settings.get_attributes(object), algolia_object_id_of(object))
195
+ @algolia_index.add_object!(algolia_index_settings.get_attributes(object), object_id)
194
196
  else
195
- @algolia_index.add_object(algolia_index_settings.get_attributes(object), algolia_object_id_of(object))
197
+ @algolia_index.add_object(algolia_index_settings.get_attributes(object), object_id)
196
198
  end
197
199
  elsif algolia_conditional_index?
198
200
  # remove non-indexable objects
199
201
  if synchronous
200
- @algolia_index.delete_object!(algolia_object_id_of(object))
202
+ @algolia_index.delete_object!(object_id)
201
203
  else
202
- @algolia_index.delete_object(algolia_object_id_of(object))
204
+ @algolia_index.delete_object(object_id)
203
205
  end
204
206
  end
205
207
  end
206
208
 
207
209
  def algolia_remove_from_index!(object, synchronous = false)
208
210
  return if @algolia_without_auto_index_scope
211
+ object_id = algolia_object_id_of(object)
212
+ raise ArgumentError.new("Cannot index a blank objectID") if object_id.blank?
209
213
  algolia_ensure_init
210
214
  if synchronous
211
- @algolia_index.delete_object!(algolia_object_id_of(object))
215
+ @algolia_index.delete_object!(object_id)
212
216
  else
213
- @algolia_index.delete_object(algolia_object_id_of(object))
217
+ @algolia_index.delete_object(object_id)
214
218
  end
215
219
  end
216
220
 
@@ -2,36 +2,29 @@ unless defined? Kaminari
2
2
  raise(AlgoliaSearch::BadConfiguration, "AlgoliaSearch: Please add 'kaminari' to your Gemfile to use kaminari pagination backend")
3
3
  end
4
4
 
5
+ require "kaminari/models/array_extension"
6
+
5
7
  module AlgoliaSearch
6
8
  module Pagination
7
- class Kaminari < Array
8
- include ::Kaminari::ConfigurationMethods::ClassMethods
9
- include ::Kaminari::PageScopeMethods
10
-
11
- attr_reader :limit_value, :offset_value, :total_count
12
-
13
- def initialize(original_array, limit_val, offset_val, total_count)
14
- @limit_value = limit_val || default_per_page
15
- @offset_value, @total_count = offset_val, total_count
16
- super(original_array)
17
- end
9
+ class Kaminari < ::Kaminari::PaginatableArray
18
10
 
19
- def page(num = 1)
20
- self
11
+ def initialize(array, options)
12
+ super(array, options)
21
13
  end
22
14
 
23
15
  def limit(num)
16
+ # noop
24
17
  self
25
18
  end
26
19
 
27
- def current_page
28
- offset_value+1
20
+ def offset(num)
21
+ # noop
22
+ self
29
23
  end
30
24
 
31
25
  class << self
32
26
  def create(results, total_hits, options = {})
33
- instance = new(results, options[:per_page], options[:page]-1, total_hits)
34
- instance
27
+ new results, offset: ((options[:page] - 1) * options[:per_page]), limit: options[:per_page], total_count: total_hits
35
28
  end
36
29
  end
37
30
  end
@@ -8,13 +8,21 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
8
8
 
9
9
  require 'algoliasearch-rails'
10
10
  require 'rspec'
11
+ require 'rails/all'
11
12
 
12
13
  raise "missing ALGOLIA_APPLICATION_ID or ALGOLIA_API_KEY environment variables" if ENV['ALGOLIA_APPLICATION_ID'].nil? || ENV['ALGOLIA_API_KEY'].nil?
13
14
 
14
- AlgoliaSearch.configuration = { application_id: ENV['ALGOLIA_APPLICATION_ID'], api_key: ENV['ALGOLIA_API_KEY'] }
15
+ Thread.current[:algolia_hosts] = nil
15
16
 
16
17
  RSpec.configure do |c|
17
18
  c.mock_with :rspec
18
19
  c.filter_run focus: true
19
20
  c.run_all_when_everything_filtered = true
20
21
  end
22
+
23
+ # avoid concurrent access to the same index
24
+ def safe_index_name(name)
25
+ return name if ENV['TRAVIS'].to_s != "true"
26
+ id = ENV['TRAVIS_JOB_NUMBER'].split('.').last
27
+ "#{name}_travis-#{id}"
28
+ end
@@ -1,5 +1,7 @@
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'] }
4
+
3
5
  describe AlgoliaSearch::Utilities do
4
6
 
5
7
  before(:each) do
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.9.1
4
+ version: 1.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Algolia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-06 00:00:00.000000000 Z
11
+ date: 2014-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json