sunspot_rails 2.0.0.pre.111215 → 2.0.0.pre.120415
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +2 -0
- data/README.rdoc +2 -2
- data/Rakefile +6 -1
- data/gemfiles/rails-2.3.14 +0 -3
- data/gemfiles/{rails-3.1.3 → rails-3.0.12} +2 -5
- data/gemfiles/{rails-3.0.11 → rails-3.1.4} +2 -5
- data/gemfiles/rails-3.2.3 +12 -0
- data/generators/sunspot/templates/sunspot.yml +3 -1
- data/lib/generators/sunspot_rails/install/templates/config/sunspot.yml +3 -1
- data/lib/sunspot/rails.rb +4 -0
- data/lib/sunspot/rails/configuration.rb +12 -0
- data/lib/sunspot/rails/railtie.rb +1 -1
- data/lib/sunspot/rails/solr_instrumentation.rb +6 -7
- data/lib/sunspot/rails/tasks.rb +11 -2
- data/spec/configuration_spec.rb +14 -0
- data/spec/rails_template/app/models/author.rb +2 -2
- data/spec/rails_template/config/sunspot.yml +2 -0
- metadata +23 -11
data/History.txt
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
* Default batch size can be specified by setting `Sunspot.config.indexing.default_batch_size`
|
4
4
|
(Peer Allan)
|
5
5
|
* Explanation of `progress_bar` is written to stdout instead of stderr (Matt Gornick)
|
6
|
+
* Fixes deprecated behavior of using InstanceMethods module with
|
7
|
+
ActiveSupport::Concern (Everton J. Carpes)
|
6
8
|
|
7
9
|
== 1.3.0 2011-11-26
|
8
10
|
* `Model.index` correctly uses `:first_id` option (Hamza Khan-Cheema)
|
data/README.rdoc
CHANGED
@@ -143,7 +143,7 @@ Do it like this:
|
|
143
143
|
Post.search do
|
144
144
|
with :blog_id, 1
|
145
145
|
with(:updated_at).greater_than(Time.now - 2.weeks)
|
146
|
-
|
146
|
+
order_by :sort_title, :asc
|
147
147
|
paginate :page => 1, :per_page => 15
|
148
148
|
end
|
149
149
|
|
@@ -168,7 +168,7 @@ be added, so just use the interface provided by Sunspot:
|
|
168
168
|
|
169
169
|
Sunspot.search(Post, Comment) do
|
170
170
|
with :blog_id, 1
|
171
|
-
|
171
|
+
order_by :created_at, :asc
|
172
172
|
end
|
173
173
|
|
174
174
|
Be sure to check out the Sunspot documentation for all the details.
|
data/Rakefile
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
require 'rake'
|
2
|
-
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'rdoc/task'
|
5
|
+
rescue LoadError
|
6
|
+
require 'rake/rdoctask'
|
7
|
+
end
|
3
8
|
|
4
9
|
if File.exist?(sunspot_lib = File.expand_path(File.join(File.dirname(__FILE__), '..', 'sunspot', 'lib')))
|
5
10
|
STDERR.puts("Using sunspot lib at #{sunspot_lib}")
|
data/gemfiles/rails-2.3.14
CHANGED
@@ -9,7 +9,4 @@ gem 'sunspot_rails', :path => File.expand_path('../..', __FILE__)
|
|
9
9
|
|
10
10
|
group :test do
|
11
11
|
gem 'rspec-rails', '~> 1.3.4'
|
12
|
-
gem 'ruby-debug19', :require => nil, :platforms => :mri_19
|
13
|
-
gem 'test-unit', '1.2.3', :platforms => :mri_19
|
14
|
-
gem 'ruby-debug', :require => nil, :platforms => :mri_18
|
15
12
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
source :rubygems
|
2
2
|
|
3
|
-
gem 'rails', '3.
|
3
|
+
gem 'rails', '3.0.12'
|
4
4
|
gem 'sqlite3-ruby', '~> 1.3.1'
|
5
5
|
|
6
6
|
gem 'sunspot', :path => File.expand_path('../../../sunspot', __FILE__)
|
@@ -8,8 +8,5 @@ gem 'sunspot_solr', :path => File.expand_path('../../../sunspot_solr', __FILE__)
|
|
8
8
|
gem 'sunspot_rails', :path => File.expand_path('../..', __FILE__)
|
9
9
|
|
10
10
|
group :test do
|
11
|
-
gem 'rspec-rails', '~> 2.
|
12
|
-
gem 'ruby-debug19', :require => nil, :platforms => :mri_19
|
13
|
-
gem 'test-unit', '1.2.3', :platforms => :mri_19
|
14
|
-
gem 'ruby-debug', :require => nil, :platforms => :mri_18
|
11
|
+
gem 'rspec-rails', '~> 2.8.1'
|
15
12
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
source :rubygems
|
2
2
|
|
3
|
-
gem 'rails', '3.
|
3
|
+
gem 'rails', '3.1.4'
|
4
4
|
gem 'sqlite3-ruby', '~> 1.3.1'
|
5
5
|
|
6
6
|
gem 'sunspot', :path => File.expand_path('../../../sunspot', __FILE__)
|
@@ -8,8 +8,5 @@ gem 'sunspot_solr', :path => File.expand_path('../../../sunspot_solr', __FILE__)
|
|
8
8
|
gem 'sunspot_rails', :path => File.expand_path('../..', __FILE__)
|
9
9
|
|
10
10
|
group :test do
|
11
|
-
gem 'rspec-rails', '~> 2.
|
12
|
-
gem 'ruby-debug19', :require => nil, :platforms => :mri_19
|
13
|
-
gem 'test-unit', '1.2.3', :platforms => :mri_19
|
14
|
-
gem 'ruby-debug', :require => nil, :platforms => :mri_18
|
11
|
+
gem 'rspec-rails', '~> 2.8.1'
|
15
12
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
source :rubygems
|
2
|
+
|
3
|
+
gem 'rails', '3.2.3'
|
4
|
+
gem 'sqlite3-ruby', '~> 1.3.1'
|
5
|
+
|
6
|
+
gem 'sunspot', :path => File.expand_path('../../../sunspot', __FILE__)
|
7
|
+
gem 'sunspot_solr', :path => File.expand_path('../../../sunspot_solr', __FILE__)
|
8
|
+
gem 'sunspot_rails', :path => File.expand_path('../..', __FILE__)
|
9
|
+
|
10
|
+
group :test do
|
11
|
+
gem 'rspec-rails', '~> 2.8.1'
|
12
|
+
end
|
data/lib/sunspot/rails.rb
CHANGED
@@ -48,6 +48,8 @@ module Sunspot #:nodoc:
|
|
48
48
|
:port => sunspot_rails_configuration.master_port,
|
49
49
|
:path => sunspot_rails_configuration.master_path
|
50
50
|
).to_s
|
51
|
+
config.solr.read_timeout = sunspot_rails_configuration.read_timeout
|
52
|
+
config.solr.open_timeout = sunspot_rails_configuration.open_timeout
|
51
53
|
config
|
52
54
|
end
|
53
55
|
|
@@ -58,6 +60,8 @@ module Sunspot #:nodoc:
|
|
58
60
|
:port => sunspot_rails_configuration.port,
|
59
61
|
:path => sunspot_rails_configuration.path
|
60
62
|
).to_s
|
63
|
+
config.solr.read_timeout = sunspot_rails_configuration.read_timeout
|
64
|
+
config.solr.open_timeout = sunspot_rails_configuration.open_timeout
|
61
65
|
config
|
62
66
|
end
|
63
67
|
end
|
@@ -21,6 +21,8 @@ module Sunspot #:nodoc:
|
|
21
21
|
# hostname: localhost
|
22
22
|
# port: 8983
|
23
23
|
# log_level: OFF
|
24
|
+
# open_timeout: 0.5
|
25
|
+
# read_timeout: 2
|
24
26
|
# production:
|
25
27
|
# solr:
|
26
28
|
# hostname: localhost
|
@@ -28,6 +30,8 @@ module Sunspot #:nodoc:
|
|
28
30
|
# path: /solr/myindex
|
29
31
|
# log_level: WARNING
|
30
32
|
# solr_home: /some/path
|
33
|
+
# open_timeout: 0.5
|
34
|
+
# read_timeout: 2
|
31
35
|
# master_solr:
|
32
36
|
# hostname: localhost
|
33
37
|
# port: 8982
|
@@ -247,6 +251,14 @@ module Sunspot #:nodoc:
|
|
247
251
|
def bind_address
|
248
252
|
@bind_address ||= user_configuration_from_key('solr', 'bind_address')
|
249
253
|
end
|
254
|
+
|
255
|
+
def read_timeout
|
256
|
+
@read_timeout ||= user_configuration_from_key('solr', 'read_timeout')
|
257
|
+
end
|
258
|
+
|
259
|
+
def open_timeout
|
260
|
+
@open_timeout ||= user_configuration_from_key('solr', 'open_timeout')
|
261
|
+
end
|
250
262
|
|
251
263
|
#
|
252
264
|
# Whether or not to disable Solr.
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Sunspot
|
2
2
|
module Rails
|
3
3
|
class Railtie < ::Rails::Railtie
|
4
|
-
initializer 'sunspot_rails.init' do
|
4
|
+
initializer 'sunspot_rails.init', :before=> :load_config_initializers do
|
5
5
|
Sunspot.session = Sunspot::Rails.build_session
|
6
6
|
ActiveSupport.on_load(:active_record) do
|
7
7
|
Sunspot::Adapters::InstanceAdapter.register(Sunspot::Rails::Adapters::ActiveRecordInstanceAdapter, ActiveRecord::Base)
|
@@ -7,14 +7,13 @@ module Sunspot
|
|
7
7
|
alias_method_chain :execute, :as_instrumentation
|
8
8
|
end
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
end
|
10
|
+
|
11
|
+
def execute_with_as_instrumentation(path, params={}, *extra)
|
12
|
+
ActiveSupport::Notifications.instrument("request.rsolr",
|
13
|
+
{:path => path, :parameters => params}) do
|
14
|
+
execute_without_as_instrumentation(path, params, *extra)
|
16
15
|
end
|
17
16
|
end
|
18
17
|
end
|
19
18
|
end
|
20
|
-
end
|
19
|
+
end
|
data/lib/sunspot/rails/tasks.rb
CHANGED
@@ -15,6 +15,10 @@ namespace :sunspot do
|
|
15
15
|
# # batchs of 1000
|
16
16
|
# $ rake sunspot:reindex[,Post+Author] # reindex Post and Author model
|
17
17
|
task :reindex, [:batch_size, :models] => [:environment] do |t, args|
|
18
|
+
|
19
|
+
# Retry once or gracefully fail for a 5xx error so we don't break reindexing
|
20
|
+
Sunspot.session = Sunspot::SessionProxy::Retry5xxSessionProxy.new(Sunspot.session)
|
21
|
+
|
18
22
|
# Set up general options for reindexing
|
19
23
|
reindex_options = { :batch_commit => false }
|
20
24
|
|
@@ -48,15 +52,20 @@ namespace :sunspot do
|
|
48
52
|
rescue Exception => e
|
49
53
|
$stderr.puts "Error using progress bar: #{e.message}"
|
50
54
|
end
|
51
|
-
|
55
|
+
|
52
56
|
# Finally, invoke the class-level solr_reindex on each model
|
53
57
|
sunspot_models.each do |model|
|
54
58
|
model.solr_reindex(reindex_options)
|
55
59
|
end
|
56
60
|
end
|
57
61
|
|
62
|
+
# Assume that if the sunspot_solr gem is in the load path that this deprication warning is
|
63
|
+
# redundant.
|
64
|
+
def sunspot_solr_in_load_path
|
65
|
+
$:.any? { |path| path =~ %r{sunspot_solr/lib$} }
|
66
|
+
end
|
58
67
|
|
59
|
-
unless
|
68
|
+
unless sunspot_solr_in_load_path
|
60
69
|
namespace :solr do
|
61
70
|
task :moved_to_sunspot_solr do
|
62
71
|
abort %(
|
data/spec/configuration_spec.rb
CHANGED
@@ -36,6 +36,14 @@ describe Sunspot::Rails::Configuration, "default values without a sunspot.yml" d
|
|
36
36
|
@config.port.should == 8983
|
37
37
|
end
|
38
38
|
end
|
39
|
+
|
40
|
+
it "should set the read timeout to nil when not set" do
|
41
|
+
@config.read_timeout == nil
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should set the open timeout to nil when not set" do
|
45
|
+
@config.open_timeout == nil
|
46
|
+
end
|
39
47
|
|
40
48
|
it "should handle the 'log_level' property when not set" do
|
41
49
|
@config.log_level.should == 'INFO'
|
@@ -126,6 +134,12 @@ describe Sunspot::Rails::Configuration, "user provided sunspot.yml" do
|
|
126
134
|
it "should handle the 'bind_address' property when set" do
|
127
135
|
@config.bind_address.should == "127.0.0.1"
|
128
136
|
end
|
137
|
+
it "should handle the 'read_timeout' property when set" do
|
138
|
+
@config.read_timeout.should == 2
|
139
|
+
end
|
140
|
+
it "should handle the 'open_timeout' property when set" do
|
141
|
+
@config.open_timeout.should == 0.5
|
142
|
+
end
|
129
143
|
end
|
130
144
|
|
131
145
|
describe Sunspot::Rails::Configuration, "with disabled: true in sunspot.yml" do
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sunspot_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 2889093829
|
5
|
+
prerelease: 6
|
5
6
|
segments:
|
6
7
|
- 2
|
7
8
|
- 0
|
8
9
|
- 0
|
9
10
|
- pre
|
10
|
-
-
|
11
|
-
version: 2.0.0.pre.
|
11
|
+
- 120415
|
12
|
+
version: 2.0.0.pre.120415
|
12
13
|
platform: ruby
|
13
14
|
authors:
|
14
15
|
- Mat Brown
|
@@ -34,32 +35,35 @@ autorequire:
|
|
34
35
|
bindir: bin
|
35
36
|
cert_chain: []
|
36
37
|
|
37
|
-
date:
|
38
|
-
default_executable:
|
38
|
+
date: 2012-04-15 00:00:00 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: sunspot
|
42
42
|
prerelease: false
|
43
43
|
requirement: &id001 !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
44
45
|
requirements:
|
45
46
|
- - "="
|
46
47
|
- !ruby/object:Gem::Version
|
48
|
+
hash: 2889093829
|
47
49
|
segments:
|
48
50
|
- 2
|
49
51
|
- 0
|
50
52
|
- 0
|
51
53
|
- pre
|
52
|
-
-
|
53
|
-
version: 2.0.0.pre.
|
54
|
+
- 120415
|
55
|
+
version: 2.0.0.pre.120415
|
54
56
|
type: :runtime
|
55
57
|
version_requirements: *id001
|
56
58
|
- !ruby/object:Gem::Dependency
|
57
59
|
name: nokogiri
|
58
60
|
prerelease: false
|
59
61
|
requirement: &id002 !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
60
63
|
requirements:
|
61
64
|
- - ">="
|
62
65
|
- !ruby/object:Gem::Version
|
66
|
+
hash: 3
|
63
67
|
segments:
|
64
68
|
- 0
|
65
69
|
version: "0"
|
@@ -69,9 +73,11 @@ dependencies:
|
|
69
73
|
name: rspec
|
70
74
|
prerelease: false
|
71
75
|
requirement: &id003 !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
72
77
|
requirements:
|
73
78
|
- - ~>
|
74
79
|
- !ruby/object:Gem::Version
|
80
|
+
hash: 11
|
75
81
|
segments:
|
76
82
|
- 1
|
77
83
|
- 2
|
@@ -82,9 +88,11 @@ dependencies:
|
|
82
88
|
name: rspec-rails
|
83
89
|
prerelease: false
|
84
90
|
requirement: &id004 !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
85
92
|
requirements:
|
86
93
|
- - ~>
|
87
94
|
- !ruby/object:Gem::Version
|
95
|
+
hash: 11
|
88
96
|
segments:
|
89
97
|
- 1
|
90
98
|
- 2
|
@@ -114,8 +122,9 @@ files:
|
|
114
122
|
- dev_tasks/spec.rake
|
115
123
|
- dev_tasks/todo.rake
|
116
124
|
- gemfiles/rails-2.3.14
|
117
|
-
- gemfiles/rails-3.0.
|
118
|
-
- gemfiles/rails-3.1.
|
125
|
+
- gemfiles/rails-3.0.12
|
126
|
+
- gemfiles/rails-3.1.4
|
127
|
+
- gemfiles/rails-3.2.3
|
119
128
|
- generators/sunspot/sunspot_generator.rb
|
120
129
|
- generators/sunspot/templates/sunspot.yml
|
121
130
|
- install.rb
|
@@ -166,7 +175,6 @@ files:
|
|
166
175
|
- spec/stub_session_proxy_spec.rb
|
167
176
|
- sunspot_rails.gemspec
|
168
177
|
- tmp/.gitkeep
|
169
|
-
has_rdoc: true
|
170
178
|
homepage: http://github.com/outoftime/sunspot/tree/master/sunspot_rails
|
171
179
|
licenses: []
|
172
180
|
|
@@ -180,16 +188,20 @@ rdoc_options:
|
|
180
188
|
require_paths:
|
181
189
|
- lib
|
182
190
|
required_ruby_version: !ruby/object:Gem::Requirement
|
191
|
+
none: false
|
183
192
|
requirements:
|
184
193
|
- - ">="
|
185
194
|
- !ruby/object:Gem::Version
|
195
|
+
hash: 3
|
186
196
|
segments:
|
187
197
|
- 0
|
188
198
|
version: "0"
|
189
199
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
200
|
+
none: false
|
190
201
|
requirements:
|
191
202
|
- - ">"
|
192
203
|
- !ruby/object:Gem::Version
|
204
|
+
hash: 25
|
193
205
|
segments:
|
194
206
|
- 1
|
195
207
|
- 3
|
@@ -198,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
210
|
requirements: []
|
199
211
|
|
200
212
|
rubyforge_project: sunspot
|
201
|
-
rubygems_version: 1.
|
213
|
+
rubygems_version: 1.8.15
|
202
214
|
signing_key:
|
203
215
|
specification_version: 3
|
204
216
|
summary: Rails integration for the Sunspot Solr search library
|