sunspot_rails 2.3.0 → 2.6.0
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 +4 -4
- data/Appraisals +15 -11
- data/lib/sunspot/rails/searchable.rb +15 -7
- data/lib/sunspot/rails/stub_session_proxy.rb +9 -2
- data/lib/sunspot/rails/tasks.rb +0 -1
- data/spec/rails_app/app/models/author.rb +0 -2
- data/spec/rails_app/app/models/blog.rb +0 -2
- data/spec/rails_app/app/models/location.rb +0 -1
- data/spec/rails_app/app/models/post.rb +0 -2
- data/spec/rails_app/app/models/post_with_auto.rb +0 -2
- data/spec/rails_app/app/models/post_with_default_scope.rb +0 -2
- data/spec/rails_app/app/models/post_with_only_some_attributes_triggering_reindex.rb +0 -2
- data/spec/rails_app/config/application.rb +3 -0
- data/spec/rails_app/config/environments/test.rb +3 -0
- data/spec/rails_app/config/sunspot.yml +1 -0
- data/spec/rails_app/vendor/engines/test_engine/app/models/test_engine/rake_task_auto_load_test_model.rb +15 -0
- data/spec/rails_app/vendor/engines/test_engine/lib/test_engine/engine.rb +5 -0
- data/spec/rails_app/vendor/engines/test_engine/lib/test_engine.rb +4 -0
- data/spec/rake_task_spec.rb +2 -2
- data/spec/stub_session_proxy_spec.rb +4 -0
- data/sunspot_rails.gemspec +10 -6
- metadata +17 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63d24337902829c8c14a7ea0d9f081c7392b457e0604ff78887ed67037fcedc5
|
4
|
+
data.tar.gz: 77c235ecfc5bc55c4758abece0d0336bc0c541bf6461d5f134b7bec57eec3c88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3a95a7312b3dd3b3402fee02ff137c85b357cf17c1babf7c98f5a37456515882d5e8978729d368b42fa67c4163d02704b7540f9878cd4dd9d09cde22f78f1b8
|
7
|
+
data.tar.gz: 3b031829d6bfac5ee89d7cc33ebc76375614e4ac21f9b1864b55d313a537d08a4ef96cd57d60cc41fabc5eca589a2e42052169172c77756adf382aac7e108dae
|
data/Appraisals
CHANGED
@@ -3,6 +3,7 @@ ruby_version = Gem::Version.new(RUBY_VERSION)
|
|
3
3
|
if ruby_version < Gem::Version.new('2.2.0')
|
4
4
|
['3.0.0', '3.1.0'].each do |rails_version|
|
5
5
|
appraise "rails-#{rails_version}" do
|
6
|
+
gem 'bundler', '>= 1.3.0', '< 2.0'
|
6
7
|
gem 'sunspot', path: File.expand_path('sunspot', ENV['SUNSPOT_LIB_HOME'])
|
7
8
|
gem 'sunspot_solr', path: File.expand_path('sunspot_solr', ENV['SUNSPOT_LIB_HOME'])
|
8
9
|
gem 'rails', "~> #{rails_version}"
|
@@ -15,6 +16,7 @@ end
|
|
15
16
|
|
16
17
|
if ruby_version < Gem::Version.new('2.4.0')
|
17
18
|
appraise 'rails-3.2.0' do
|
19
|
+
gem 'bundler', '>= 1.3.0', '< 2.0'
|
18
20
|
gem 'sunspot', path: File.expand_path('sunspot', ENV['SUNSPOT_LIB_HOME'])
|
19
21
|
gem 'sunspot_solr', path: File.expand_path('sunspot_solr', ENV['SUNSPOT_LIB_HOME'])
|
20
22
|
gem 'rails', '~> 3.2.0'
|
@@ -26,10 +28,10 @@ if ruby_version < Gem::Version.new('2.4.0')
|
|
26
28
|
|
27
29
|
['4.0.0', '4.1.0'].each do |rails_version|
|
28
30
|
appraise "rails-#{rails_version}" do
|
31
|
+
gem 'bundler', '>= 1.3.0', '< 2.0'
|
29
32
|
gem 'sunspot', path: File.expand_path('sunspot', ENV['SUNSPOT_LIB_HOME'])
|
30
33
|
gem 'sunspot_solr', path: File.expand_path('sunspot_solr', ENV['SUNSPOT_LIB_HOME'])
|
31
34
|
gem 'rails', "~> #{rails_version}"
|
32
|
-
gem 'protected_attributes'
|
33
35
|
gem 'progress_bar', '~> 1.0.5', require: false
|
34
36
|
gem 'rspec', '~> 3.4.0'
|
35
37
|
gem 'rspec-rails', '~> 3.4.0'
|
@@ -37,23 +39,25 @@ if ruby_version < Gem::Version.new('2.4.0')
|
|
37
39
|
end
|
38
40
|
end
|
39
41
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
42
|
+
if ruby_version < Gem::Version.new('2.5.0')
|
43
|
+
appraise 'rails-4.2.0' do
|
44
|
+
gem 'bundler', '>= 1.3.0', '< 2.0'
|
45
|
+
gem 'sunspot', path: File.expand_path('sunspot', ENV['SUNSPOT_LIB_HOME'])
|
46
|
+
gem 'sunspot_solr', path: File.expand_path('sunspot_solr', ENV['SUNSPOT_LIB_HOME'])
|
47
|
+
gem 'rails', '~> 4.2.0'
|
48
|
+
gem 'progress_bar', '~> 1.0.5', require: false
|
49
|
+
gem 'rspec', '~> 3.4.0'
|
50
|
+
gem 'rspec-rails', '~> 3.4.0'
|
51
|
+
end
|
48
52
|
end
|
49
53
|
|
50
54
|
if ruby_version >= Gem::Version.new('2.2.0')
|
51
|
-
['5.0.0', '5.1.0'].each do |rails_version|
|
55
|
+
['5.0.0', '5.1.0', '5.2.0'].each do |rails_version|
|
52
56
|
appraise "rails-#{rails_version}" do
|
53
57
|
gem 'sunspot', path: File.expand_path('sunspot', ENV['SUNSPOT_LIB_HOME'])
|
54
58
|
gem 'sunspot_solr', path: File.expand_path('sunspot_solr', ENV['SUNSPOT_LIB_HOME'])
|
55
59
|
gem 'rails', "~> #{rails_version}"
|
56
|
-
gem '
|
60
|
+
gem 'sprockets', '~> 3.0'
|
57
61
|
gem 'progress_bar', '~> 1.0.5', require: false
|
58
62
|
end
|
59
63
|
end
|
@@ -99,9 +99,15 @@ module Sunspot #:nodoc:
|
|
99
99
|
|
100
100
|
unless options[:auto_remove] == false
|
101
101
|
# after_commit { |searchable| searchable.remove_from_index }, :on => :destroy
|
102
|
-
|
103
|
-
|
104
|
-
|
102
|
+
# Only add the on filter if the callback supports it
|
103
|
+
if Sunspot::Rails.configuration.auto_remove_callback =~ /save|destroy|create/
|
104
|
+
__send__ Sunspot::Rails.configuration.auto_remove_callback,
|
105
|
+
proc { |searchable| searchable.remove_from_index }
|
106
|
+
else
|
107
|
+
__send__ Sunspot::Rails.configuration.auto_remove_callback,
|
108
|
+
proc { |searchable| searchable.remove_from_index },
|
109
|
+
:on => :destroy
|
110
|
+
end
|
105
111
|
end
|
106
112
|
options[:include] = Util::Array(options[:include])
|
107
113
|
|
@@ -258,7 +264,7 @@ module Sunspot #:nodoc:
|
|
258
264
|
|
259
265
|
if options[:batch_size].to_i > 0
|
260
266
|
batch_counter = 0
|
261
|
-
self.includes(options[:include]).find_in_batches(options.slice(:batch_size, :start)) do |records|
|
267
|
+
self.includes(options[:include]).find_in_batches(**options.slice(:batch_size, :start)) do |records|
|
262
268
|
|
263
269
|
solr_benchmark(options[:batch_size], batch_counter += 1) do
|
264
270
|
Sunspot.index(records.select(&:indexable?))
|
@@ -281,7 +287,7 @@ module Sunspot #:nodoc:
|
|
281
287
|
#
|
282
288
|
# ==== Updates (passed as a hash)
|
283
289
|
#
|
284
|
-
# updates should be specified as a hash, where key - is the object ID
|
290
|
+
# updates should be specified as a hash, where key - is the object or the object ID
|
285
291
|
# and values is hash with property name/values to be updated.
|
286
292
|
#
|
287
293
|
# ==== Examples
|
@@ -297,6 +303,8 @@ module Sunspot #:nodoc:
|
|
297
303
|
#
|
298
304
|
# # update single property
|
299
305
|
# Post.atomic_update(post1.id => {description: 'New post description'})
|
306
|
+
# Or
|
307
|
+
# Post.atomic_update(post1 => {description: 'New post description'})
|
300
308
|
#
|
301
309
|
# ==== Notice
|
302
310
|
# all non-stored properties in Solr index will be lost after update.
|
@@ -447,7 +455,7 @@ module Sunspot #:nodoc:
|
|
447
455
|
# you only need to pass hash with property changes
|
448
456
|
#
|
449
457
|
def solr_atomic_update(updates = {})
|
450
|
-
Sunspot.atomic_update(self.class, self
|
458
|
+
Sunspot.atomic_update(self.class, self => updates)
|
451
459
|
end
|
452
460
|
|
453
461
|
#
|
@@ -455,7 +463,7 @@ module Sunspot #:nodoc:
|
|
455
463
|
# See #solr_atomic_update
|
456
464
|
#
|
457
465
|
def solr_atomic_update!(updates = {})
|
458
|
-
Sunspot.atomic_update!(self.class, self
|
466
|
+
Sunspot.atomic_update!(self.class, self => updates)
|
459
467
|
end
|
460
468
|
|
461
469
|
#
|
@@ -44,6 +44,10 @@ module Sunspot
|
|
44
44
|
def optimize
|
45
45
|
end
|
46
46
|
|
47
|
+
def config
|
48
|
+
Sunspot::Configuration.build
|
49
|
+
end
|
50
|
+
|
47
51
|
def dirty?
|
48
52
|
false
|
49
53
|
end
|
@@ -104,7 +108,7 @@ module Sunspot
|
|
104
108
|
[]
|
105
109
|
end
|
106
110
|
|
107
|
-
def facet(name)
|
111
|
+
def facet(name, dynamic_name = nil)
|
108
112
|
FacetStub.new
|
109
113
|
end
|
110
114
|
|
@@ -123,6 +127,9 @@ module Sunspot
|
|
123
127
|
def execute
|
124
128
|
self
|
125
129
|
end
|
130
|
+
|
131
|
+
def spellcheck_collation
|
132
|
+
end
|
126
133
|
end
|
127
134
|
|
128
135
|
|
@@ -219,7 +226,7 @@ module Sunspot
|
|
219
226
|
[]
|
220
227
|
end
|
221
228
|
|
222
|
-
def facet(name)
|
229
|
+
def facet(name, dynamic_name = nil)
|
223
230
|
FacetStub.new
|
224
231
|
end
|
225
232
|
|
data/lib/sunspot/rails/tasks.rb
CHANGED
@@ -31,7 +31,6 @@ namespace :sunspot do
|
|
31
31
|
# Load all the application's models. Models which invoke 'searchable' will register themselves
|
32
32
|
# in Sunspot.searchable.
|
33
33
|
Rails.application.eager_load!
|
34
|
-
Rails::Engine.subclasses.each{|engine| engine.instance.eager_load!}
|
35
34
|
|
36
35
|
if args[:models].present?
|
37
36
|
# Choose a specific subset of models, if requested
|
@@ -3,8 +3,6 @@ class PostWithOnlySomeAttributesTriggeringReindex < ActiveRecord::Base
|
|
3
3
|
'posts'
|
4
4
|
end
|
5
5
|
|
6
|
-
attr_accessible :title, :type, :location_id, :body, :blog
|
7
|
-
|
8
6
|
searchable :only_reindex_attribute_changes_of => [ :title, :body ] do
|
9
7
|
string :title
|
10
8
|
text :body, :more_like_this => true
|
@@ -4,6 +4,9 @@ require 'rails/all'
|
|
4
4
|
|
5
5
|
Bundler.require(:default, Rails.env) if defined?(Bundler)
|
6
6
|
|
7
|
+
# Load the test engine
|
8
|
+
require File.expand_path('../../vendor/engines/test_engine/lib/test_engine', __FILE__)
|
9
|
+
|
7
10
|
module RailsApp
|
8
11
|
class Application < Rails::Application
|
9
12
|
config.encoding = 'utf-8'
|
@@ -33,6 +33,9 @@ RailsApp::Application.configure do
|
|
33
33
|
# like if you have constraints or database-specific column types
|
34
34
|
# config.active_record.schema_format = :sql
|
35
35
|
|
36
|
+
# mute Rails 5.2 deprecation warning
|
37
|
+
config.active_record.sqlite3.represent_boolean_as_integer = true if config.active_record.sqlite3
|
38
|
+
|
36
39
|
# Print deprecation notices to the stderr
|
37
40
|
config.active_support.deprecation = :stderr
|
38
41
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# This model should not be used for any test other than the spec test that
|
2
|
+
# checks if all models are loaded. We don't want to pre-load this model in
|
3
|
+
# another test because we're checking to see if it will be auto-loaded by
|
4
|
+
# the reindex task
|
5
|
+
module TestEngine
|
6
|
+
class RakeTaskAutoLoadTestModel < ActiveRecord::Base
|
7
|
+
def self.table_name
|
8
|
+
'posts'
|
9
|
+
end
|
10
|
+
|
11
|
+
searchable do
|
12
|
+
string :name
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/spec/rake_task_spec.rb
CHANGED
@@ -11,8 +11,8 @@ describe 'sunspot namespace rake task' do
|
|
11
11
|
it "should reindex all models if none are specified" do
|
12
12
|
run_rake_task("sunspot:reindex", '', '', true)
|
13
13
|
|
14
|
-
# This
|
15
|
-
expect(Sunspot.searchable.collect(&:name)).to include('RakeTaskAutoLoadTestModel')
|
14
|
+
# This models should not be used by any other test and therefore should only be loaded by this test
|
15
|
+
expect(Sunspot.searchable.collect(&:name)).to include('RakeTaskAutoLoadTestModel', 'TestEngine::RakeTaskAutoLoadTestModel')
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should accept a space delimited list of models to reindex" do
|
@@ -118,6 +118,10 @@ describe 'specs with Sunspot stubbed' do
|
|
118
118
|
Sunspot.more_like_this(@post)
|
119
119
|
end
|
120
120
|
|
121
|
+
it 'should not raise error when reindexing scope' do
|
122
|
+
expect{ Post.solr_index }.to_not raise_error
|
123
|
+
end
|
124
|
+
|
121
125
|
describe 'stub search' do
|
122
126
|
before :each do
|
123
127
|
@search = Post.search
|
data/sunspot_rails.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
'Brian Atkinson', 'Tom Coleman', 'Matt Mitchell', 'Nathan Beyer', 'Kieran Topping', 'Nicolas Braem', 'Jeremy Ashkenas',
|
14
14
|
'Dylan Vaughn', 'Brian Durand', 'Sam Granieri', 'Nick Zadrozny', 'Jason Ronallo']
|
15
15
|
s.email = ["mat@patch.com"]
|
16
|
-
s.homepage = 'http://github.com/
|
16
|
+
s.homepage = 'http://github.com/sunspot/sunspot/tree/master/sunspot_rails'
|
17
17
|
s.summary = 'Rails integration for the Sunspot Solr search library'
|
18
18
|
s.license = 'MIT'
|
19
19
|
s.description = <<-TEXT
|
@@ -25,22 +25,26 @@ Gem::Specification.new do |s|
|
|
25
25
|
Rails request.
|
26
26
|
TEXT
|
27
27
|
|
28
|
-
s.rubyforge_project = "sunspot"
|
29
|
-
|
30
28
|
s.files = `git ls-files`.split("\n")
|
31
29
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
32
30
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
33
31
|
s.require_paths = ["lib"]
|
34
32
|
|
35
|
-
|
36
|
-
|
33
|
+
if RUBY_VERSION < '2.2'
|
34
|
+
s.add_dependency 'rails', '>= 3', '< 5'
|
35
|
+
else
|
36
|
+
s.add_dependency 'rails', '>= 3'
|
37
|
+
end
|
37
38
|
|
39
|
+
s.add_dependency 'sunspot', Sunspot::VERSION
|
40
|
+
|
38
41
|
s.add_development_dependency 'appraisal', '2.2.0'
|
42
|
+
s.add_development_dependency 'bundler', '>= 1.3.0', '< 2.0' if RUBY_VERSION <= '2.0.0'
|
39
43
|
s.add_development_dependency 'nokogiri', '< 1.7' if RUBY_VERSION <= '2.0.0'
|
40
44
|
s.add_development_dependency 'rake', '< 12.3'
|
41
45
|
s.add_development_dependency 'rspec', '~> 3.7'
|
42
46
|
s.add_development_dependency 'rspec-rails', '~> 3.7'
|
43
|
-
s.add_development_dependency 'sqlite3', '~> 1.3'
|
47
|
+
s.add_development_dependency 'sqlite3', '~> 1.3.0'
|
44
48
|
|
45
49
|
s.rdoc_options << '--webcvs=http://github.com/outoftime/sunspot/tree/master/%s' <<
|
46
50
|
'--title' << 'Sunspot-Rails - Rails integration for the Sunspot Solr search library - API Documentation' <<
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sunspot_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mat Brown
|
@@ -23,10 +23,10 @@ authors:
|
|
23
23
|
- Sam Granieri
|
24
24
|
- Nick Zadrozny
|
25
25
|
- Jason Ronallo
|
26
|
-
autorequire:
|
26
|
+
autorequire:
|
27
27
|
bindir: bin
|
28
28
|
cert_chain: []
|
29
|
-
date:
|
29
|
+
date: 2022-05-30 00:00:00.000000000 Z
|
30
30
|
dependencies:
|
31
31
|
- !ruby/object:Gem::Dependency
|
32
32
|
name: rails
|
@@ -48,14 +48,14 @@ dependencies:
|
|
48
48
|
requirements:
|
49
49
|
- - '='
|
50
50
|
- !ruby/object:Gem::Version
|
51
|
-
version: 2.
|
51
|
+
version: 2.6.0
|
52
52
|
type: :runtime
|
53
53
|
prerelease: false
|
54
54
|
version_requirements: !ruby/object:Gem::Requirement
|
55
55
|
requirements:
|
56
56
|
- - '='
|
57
57
|
- !ruby/object:Gem::Version
|
58
|
-
version: 2.
|
58
|
+
version: 2.6.0
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: appraisal
|
61
61
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,14 +118,14 @@ dependencies:
|
|
118
118
|
requirements:
|
119
119
|
- - "~>"
|
120
120
|
- !ruby/object:Gem::Version
|
121
|
-
version:
|
121
|
+
version: 1.3.0
|
122
122
|
type: :development
|
123
123
|
prerelease: false
|
124
124
|
version_requirements: !ruby/object:Gem::Requirement
|
125
125
|
requirements:
|
126
126
|
- - "~>"
|
127
127
|
- !ruby/object:Gem::Version
|
128
|
-
version:
|
128
|
+
version: 1.3.0
|
129
129
|
description: |2
|
130
130
|
Sunspot::Rails is an extension to the Sunspot library for Solr search.
|
131
131
|
Sunspot::Rails adds integration between Sunspot and ActiveRecord, including
|
@@ -201,6 +201,9 @@ files:
|
|
201
201
|
- spec/rails_app/config/routes.rb
|
202
202
|
- spec/rails_app/config/sunspot.yml
|
203
203
|
- spec/rails_app/db/schema.rb
|
204
|
+
- spec/rails_app/vendor/engines/test_engine/app/models/test_engine/rake_task_auto_load_test_model.rb
|
205
|
+
- spec/rails_app/vendor/engines/test_engine/lib/test_engine.rb
|
206
|
+
- spec/rails_app/vendor/engines/test_engine/lib/test_engine/engine.rb
|
204
207
|
- spec/rake_task_spec.rb
|
205
208
|
- spec/request_lifecycle_spec.rb
|
206
209
|
- spec/schema.rb
|
@@ -212,11 +215,11 @@ files:
|
|
212
215
|
- spec/spec_helper.rb
|
213
216
|
- spec/stub_session_proxy_spec.rb
|
214
217
|
- sunspot_rails.gemspec
|
215
|
-
homepage: http://github.com/
|
218
|
+
homepage: http://github.com/sunspot/sunspot/tree/master/sunspot_rails
|
216
219
|
licenses:
|
217
220
|
- MIT
|
218
221
|
metadata: {}
|
219
|
-
post_install_message:
|
222
|
+
post_install_message:
|
220
223
|
rdoc_options:
|
221
224
|
- "--webcvs=http://github.com/outoftime/sunspot/tree/master/%s"
|
222
225
|
- "--title"
|
@@ -236,9 +239,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
236
239
|
- !ruby/object:Gem::Version
|
237
240
|
version: '0'
|
238
241
|
requirements: []
|
239
|
-
|
240
|
-
|
241
|
-
signing_key:
|
242
|
+
rubygems_version: 3.1.4
|
243
|
+
signing_key:
|
242
244
|
specification_version: 4
|
243
245
|
summary: Rails integration for the Sunspot Solr search library
|
244
246
|
test_files:
|
@@ -268,6 +270,9 @@ test_files:
|
|
268
270
|
- spec/rails_app/config/routes.rb
|
269
271
|
- spec/rails_app/config/sunspot.yml
|
270
272
|
- spec/rails_app/db/schema.rb
|
273
|
+
- spec/rails_app/vendor/engines/test_engine/app/models/test_engine/rake_task_auto_load_test_model.rb
|
274
|
+
- spec/rails_app/vendor/engines/test_engine/lib/test_engine.rb
|
275
|
+
- spec/rails_app/vendor/engines/test_engine/lib/test_engine/engine.rb
|
271
276
|
- spec/rake_task_spec.rb
|
272
277
|
- spec/request_lifecycle_spec.rb
|
273
278
|
- spec/schema.rb
|