sunspot_rails 1.1.0 → 1.2.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.
- data/History.txt +11 -0
- data/README.rdoc +13 -11
- data/Rakefile +1 -10
- data/TESTING.md +35 -0
- data/dev_tasks/spec.rake +22 -0
- data/lib/generators/sunspot_rails/install/install_generator.rb +13 -0
- data/lib/generators/sunspot_rails/install/templates/config/sunspot.yml +17 -0
- data/lib/generators/sunspot_rails.rb +9 -0
- data/lib/sunspot/rails/adapters.rb +6 -6
- data/lib/sunspot/rails/configuration.rb +53 -6
- data/{rails → lib/sunspot/rails}/init.rb +0 -2
- data/lib/sunspot/rails/railtie.rb +26 -0
- data/lib/sunspot/rails/request_lifecycle.rb +7 -2
- data/lib/sunspot/rails/searchable.rb +11 -13
- data/lib/sunspot/rails/server.rb +1 -1
- data/lib/sunspot/rails/solr_logging.rb +6 -1
- data/lib/sunspot/rails/spec_helper.rb +8 -1
- data/lib/sunspot/rails/tasks.rb +1 -1
- data/lib/sunspot/rails/version.rb +1 -1
- data/lib/sunspot_rails.rb +7 -0
- data/spec/configuration_spec.rb +80 -9
- data/spec/model_spec.rb +19 -21
- data/spec/request_lifecycle_spec.rb +11 -2
- data/spec/server_spec.rb +2 -1
- data/spec/spec_helper.rb +18 -23
- metadata +45 -48
- data/dev_tasks/gemspec.rake +0 -33
- data/spec/mock_app/app/controllers/application.rb +0 -10
- data/spec/mock_app/app/controllers/application_controller.rb +0 -10
- data/spec/mock_app/app/controllers/posts_controller.rb +0 -6
- data/spec/mock_app/app/models/author.rb +0 -8
- data/spec/mock_app/app/models/blog.rb +0 -12
- data/spec/mock_app/app/models/location.rb +0 -2
- data/spec/mock_app/app/models/photo_post.rb +0 -2
- data/spec/mock_app/app/models/post.rb +0 -10
- data/spec/mock_app/app/models/post_with_auto.rb +0 -10
- data/spec/mock_app/config/boot.rb +0 -110
- data/spec/mock_app/config/database.yml +0 -4
- data/spec/mock_app/config/environment.rb +0 -42
- data/spec/mock_app/config/environments/development.rb +0 -27
- data/spec/mock_app/config/environments/test.rb +0 -27
- data/spec/mock_app/config/initializers/new_rails_defaults.rb +0 -19
- data/spec/mock_app/config/initializers/session_store.rb +0 -15
- data/spec/mock_app/config/routes.rb +0 -43
- data/spec/mock_app/config/sunspot.yml +0 -19
- data/spec/mock_app/db/schema.rb +0 -27
- data/spec/mock_app/db/test.db +0 -0
data/spec/model_spec.rb
CHANGED
@@ -15,6 +15,11 @@ describe 'ActiveRecord mixin' do
|
|
15
15
|
Sunspot.commit
|
16
16
|
Post.search.results.should == [@post]
|
17
17
|
end
|
18
|
+
|
19
|
+
it "should not blow up if there's a default scope specifying order" do
|
20
|
+
posts = Array.new(2) { |j| PostWithDefaultScope.create! :title => (10-j).to_s }
|
21
|
+
lambda { PostWithDefaultScope.index(:batch_size => 1) }.should_not raise_error
|
22
|
+
end
|
18
23
|
end
|
19
24
|
|
20
25
|
describe 'single table inheritence' do
|
@@ -70,7 +75,7 @@ describe 'ActiveRecord mixin' do
|
|
70
75
|
|
71
76
|
describe 'remove_all_from_index' do
|
72
77
|
before :each do
|
73
|
-
@posts = Array.new(
|
78
|
+
@posts = Array.new(2) { Post.create! }.each { |post| Sunspot.index(post) }
|
74
79
|
Sunspot.commit
|
75
80
|
Post.remove_all_from_index
|
76
81
|
end
|
@@ -87,7 +92,7 @@ describe 'ActiveRecord mixin' do
|
|
87
92
|
|
88
93
|
describe 'remove_all_from_index!' do
|
89
94
|
before :each do
|
90
|
-
Array.new(
|
95
|
+
Array.new(2) { Post.create! }.each { |post| Sunspot.index(post) }
|
91
96
|
Sunspot.commit
|
92
97
|
Post.remove_all_from_index!
|
93
98
|
end
|
@@ -115,15 +120,8 @@ describe 'ActiveRecord mixin' do
|
|
115
120
|
end.results.should be_empty
|
116
121
|
end
|
117
122
|
|
118
|
-
it 'should find ActiveRecord objects with an integer, not a string' do
|
119
|
-
Post.should_receive(:all).with(hash_including(:conditions => { "id" => [@post.id.to_i] })).and_return([@post])
|
120
|
-
Post.search do
|
121
|
-
with :title, 'Test Post'
|
122
|
-
end.results.should == [@post]
|
123
|
-
end
|
124
|
-
|
125
123
|
it 'should use the include option on the data accessor when specified' do
|
126
|
-
Post.should_receive(:
|
124
|
+
Post.should_receive(:all).with(hash_including(:include => [:blog])).and_return([@post])
|
127
125
|
Post.search do
|
128
126
|
with :title, 'Test Post'
|
129
127
|
data_accessor_for(Post).include = [:blog]
|
@@ -131,14 +129,14 @@ describe 'ActiveRecord mixin' do
|
|
131
129
|
end
|
132
130
|
|
133
131
|
it 'should pass :include option from search call to data accessor' do
|
134
|
-
Post.should_receive(:
|
132
|
+
Post.should_receive(:all).with(hash_including(:include => [:blog])).and_return([@post])
|
135
133
|
Post.search(:include => [:blog]) do
|
136
134
|
with :title, 'Test Post'
|
137
135
|
end.results.should == [@post]
|
138
136
|
end
|
139
137
|
|
140
138
|
it 'should use the select option from search call to data accessor' do
|
141
|
-
Post.should_receive(:
|
139
|
+
Post.should_receive(:all).with(hash_including(:select => 'title, published_at')).and_return([@post])
|
142
140
|
Post.search(:select => 'title, published_at') do
|
143
141
|
with :title, 'Test Post'
|
144
142
|
end.results.should == [@post]
|
@@ -149,7 +147,7 @@ describe 'ActiveRecord mixin' do
|
|
149
147
|
end
|
150
148
|
|
151
149
|
it 'should use the select option on the data accessor when specified' do
|
152
|
-
Post.should_receive(:
|
150
|
+
Post.should_receive(:all).with(hash_including(:select => 'title, published_at')).and_return([@post])
|
153
151
|
Post.search do
|
154
152
|
with :title, 'Test Post'
|
155
153
|
data_accessor_for(Post).select = [:title, :published_at]
|
@@ -157,7 +155,7 @@ describe 'ActiveRecord mixin' do
|
|
157
155
|
end
|
158
156
|
|
159
157
|
it 'should not use the select option on the data accessor when not specified' do
|
160
|
-
Post.should_receive(:
|
158
|
+
Post.should_receive(:all).with(hash_not_including(:select)).and_return([@post])
|
161
159
|
Post.search do
|
162
160
|
with :title, 'Test Post'
|
163
161
|
end.results.should == [@post]
|
@@ -177,7 +175,7 @@ describe 'ActiveRecord mixin' do
|
|
177
175
|
post.location = Location.create!(:lat => 40.0, :lng => -70.0)
|
178
176
|
post.save
|
179
177
|
post.index!
|
180
|
-
Post.search { near(
|
178
|
+
Post.search { with(:location).near(40.0, -70.0) }.results.should == [post]
|
181
179
|
end
|
182
180
|
|
183
181
|
end
|
@@ -285,7 +283,7 @@ describe 'ActiveRecord mixin' do
|
|
285
283
|
describe "reindex()" do
|
286
284
|
|
287
285
|
before(:each) do
|
288
|
-
@posts = Array.new(
|
286
|
+
@posts = Array.new(2) { Post.create }
|
289
287
|
end
|
290
288
|
|
291
289
|
describe "when not using batches" do
|
@@ -309,16 +307,16 @@ describe 'ActiveRecord mixin' do
|
|
309
307
|
params[:limit].should == 500
|
310
308
|
params[:include].should == []
|
311
309
|
params[:conditions].should == ['posts.id > ?', 0]
|
312
|
-
params[:order].should == 'id'
|
310
|
+
params[:order].should == 'posts.id'
|
313
311
|
end.and_return(@posts)
|
314
312
|
Post.reindex
|
315
313
|
end
|
316
314
|
|
317
315
|
it "should set the conditions using the overridden table attributes" do
|
318
|
-
@posts = Array.new(
|
316
|
+
@posts = Array.new(2) { Author.create }
|
319
317
|
Author.should_receive(:all).with do |params|
|
320
318
|
params[:conditions].should == ['writers.writer_id > ?', 0]
|
321
|
-
params[:order].should == 'writer_id'
|
319
|
+
params[:order].should == 'writers.writer_id'
|
322
320
|
end.and_return(@posts)
|
323
321
|
Author.reindex
|
324
322
|
end
|
@@ -345,7 +343,7 @@ describe 'ActiveRecord mixin' do
|
|
345
343
|
end
|
346
344
|
|
347
345
|
it "should set the include option from the searchable options" do
|
348
|
-
@blogs = Array.new(
|
346
|
+
@blogs = Array.new(2) { Blog.create }
|
349
347
|
Blog.should_receive(:all).with do |params|
|
350
348
|
params[:include].should == [{ :posts => :author }, :comments]
|
351
349
|
@blogs
|
@@ -355,7 +353,7 @@ describe 'ActiveRecord mixin' do
|
|
355
353
|
|
356
354
|
it "should commit after indexing each batch" do
|
357
355
|
Sunspot.should_receive(:commit).twice
|
358
|
-
Post.reindex(:batch_size =>
|
356
|
+
Post.reindex(:batch_size => 1)
|
359
357
|
end
|
360
358
|
|
361
359
|
it "should commit after indexing everything" do
|
@@ -1,6 +1,12 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe PostsController, :type => :controller do
|
4
|
+
begin
|
5
|
+
include ::RSpec::Rails::ControllerExampleGroup
|
6
|
+
rescue NameError
|
7
|
+
# Silent -- rspec-rails 1.x catches the :type => :controller
|
8
|
+
end
|
9
|
+
|
4
10
|
before(:each) do
|
5
11
|
Sunspot::Rails.configuration = @configuration = Sunspot::Rails::Configuration.new
|
6
12
|
end
|
@@ -8,7 +14,10 @@ describe 'request lifecycle', :type => :controller do
|
|
8
14
|
after(:each) do
|
9
15
|
Sunspot::Rails.configuration = nil
|
10
16
|
end
|
11
|
-
|
17
|
+
|
18
|
+
unless respond_to?(:describes)
|
19
|
+
controller_name :posts # RSpec 1
|
20
|
+
end
|
12
21
|
|
13
22
|
it 'should automatically commit after each action if specified' do
|
14
23
|
@configuration.user_configuration = { 'auto_commit_after_request' => true }
|
data/spec/server_spec.rb
CHANGED
@@ -3,7 +3,8 @@ require File.join(File.dirname(__FILE__), 'spec_helper')
|
|
3
3
|
describe Sunspot::Rails::Server do
|
4
4
|
before :each do
|
5
5
|
@server = Sunspot::Rails::Server.new
|
6
|
-
@
|
6
|
+
@config = Sunspot::Rails::Configuration.new
|
7
|
+
@solr_home = File.join(@config.solr_home)
|
7
8
|
end
|
8
9
|
|
9
10
|
it "sets the correct Solr home" do
|
data/spec/spec_helper.rb
CHANGED
@@ -1,22 +1,21 @@
|
|
1
1
|
ENV['RAILS_ENV'] = 'test'
|
2
|
-
ENV['RAILS_ROOT'] ||= File.join(File.dirname(__FILE__), '
|
2
|
+
ENV['RAILS_ROOT'] ||= File.join(File.dirname(__FILE__), 'rails3')
|
3
3
|
if rsolr_version = ENV['RSOLR_GEM_VERSION']
|
4
4
|
STDERR.puts("Forcing RSolr version #{rsolr_version}")
|
5
5
|
gem "rsolr", rsolr_version
|
6
6
|
end
|
7
7
|
|
8
|
-
|
9
|
-
STDERR.puts("Using sunspot lib at #{sunspot_lib}")
|
10
|
-
$: << sunspot_lib
|
11
|
-
end
|
12
|
-
|
13
|
-
require File.expand_path(File.join(ENV['RAILS_ROOT'], 'config', 'environment.rb'))
|
8
|
+
require File.expand_path('config/environment', ENV['RAILS_ROOT'])
|
14
9
|
|
15
|
-
|
16
|
-
require '
|
10
|
+
begin
|
11
|
+
require 'rspec'
|
12
|
+
require 'rspec/rails'
|
13
|
+
rescue LoadError => e
|
14
|
+
require 'spec'
|
15
|
+
require 'spec/rails'
|
16
|
+
end
|
17
17
|
require 'rake'
|
18
|
-
require '
|
19
|
-
require File.join(File.dirname(__FILE__), '..', 'lib', 'sunspot', 'rails', 'solr_logging')
|
18
|
+
require File.join('sunspot', 'rails', 'solr_logging')
|
20
19
|
|
21
20
|
def load_schema
|
22
21
|
stdout = $stdout
|
@@ -32,20 +31,16 @@ def silence_stderr(&block)
|
|
32
31
|
$stderr = stderr
|
33
32
|
end
|
34
33
|
|
35
|
-
|
34
|
+
rspec =
|
35
|
+
begin
|
36
|
+
RSpec
|
37
|
+
rescue NameError, ArgumentError
|
38
|
+
Spec::Runner
|
39
|
+
end
|
40
|
+
|
41
|
+
rspec.configure do |config|
|
36
42
|
config.before(:each) do
|
37
43
|
load_schema
|
38
44
|
Sunspot.remove_all!
|
39
45
|
end
|
40
46
|
end
|
41
|
-
|
42
|
-
module Spec
|
43
|
-
module Mocks
|
44
|
-
module Methods
|
45
|
-
def should_respond_to_and_receive(*args, &block)
|
46
|
-
respond_to?(args.first).should ==(true)
|
47
|
-
should_receive(*args, &block)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sunspot_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 31
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 1
|
7
|
-
-
|
8
|
+
- 2
|
8
9
|
- 0
|
9
|
-
version: 1.
|
10
|
+
version: 1.2.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Mat Brown
|
@@ -22,30 +23,34 @@ autorequire:
|
|
22
23
|
bindir: bin
|
23
24
|
cert_chain: []
|
24
25
|
|
25
|
-
date: 2010-
|
26
|
+
date: 2010-12-29 00:00:00 -05:00
|
26
27
|
default_executable:
|
27
28
|
dependencies:
|
28
29
|
- !ruby/object:Gem::Dependency
|
29
30
|
name: sunspot
|
30
31
|
prerelease: false
|
31
32
|
requirement: &id001 !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
32
34
|
requirements:
|
33
35
|
- - "="
|
34
36
|
- !ruby/object:Gem::Version
|
37
|
+
hash: 31
|
35
38
|
segments:
|
36
39
|
- 1
|
37
|
-
-
|
40
|
+
- 2
|
38
41
|
- 0
|
39
|
-
version: 1.
|
42
|
+
version: 1.2.0
|
40
43
|
type: :runtime
|
41
44
|
version_requirements: *id001
|
42
45
|
- !ruby/object:Gem::Dependency
|
43
46
|
name: rspec
|
44
47
|
prerelease: false
|
45
48
|
requirement: &id002 !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
46
50
|
requirements:
|
47
51
|
- - ~>
|
48
52
|
- !ruby/object:Gem::Version
|
53
|
+
hash: 11
|
49
54
|
segments:
|
50
55
|
- 1
|
51
56
|
- 2
|
@@ -56,9 +61,11 @@ dependencies:
|
|
56
61
|
name: rspec-rails
|
57
62
|
prerelease: false
|
58
63
|
requirement: &id003 !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
59
65
|
requirements:
|
60
66
|
- - ~>
|
61
67
|
- !ruby/object:Gem::Version
|
68
|
+
hash: 11
|
62
69
|
segments:
|
63
70
|
- 1
|
64
71
|
- 2
|
@@ -81,61 +88,47 @@ extensions: []
|
|
81
88
|
extra_rdoc_files: []
|
82
89
|
|
83
90
|
files:
|
84
|
-
- MIT-LICENSE
|
85
|
-
- Rakefile
|
86
|
-
- README.rdoc
|
87
|
-
- TODO
|
88
|
-
- History.txt
|
89
91
|
- VERSION.yml
|
92
|
+
- TESTING.md
|
93
|
+
- Rakefile
|
94
|
+
- MIT-LICENSE
|
90
95
|
- LICENSE
|
91
|
-
-
|
92
|
-
-
|
96
|
+
- History.txt
|
97
|
+
- TODO
|
98
|
+
- README.rdoc
|
99
|
+
- lib/sunspot_rails.rb
|
100
|
+
- lib/sunspot/rails/solr_logging.rb
|
101
|
+
- lib/sunspot/rails/railtie.rb
|
93
102
|
- lib/sunspot/rails/version.rb
|
94
|
-
- lib/sunspot/rails/stub_session_proxy.rb
|
95
|
-
- lib/sunspot/rails/adapters.rb
|
96
|
-
- lib/sunspot/rails/configuration.rb
|
97
103
|
- lib/sunspot/rails/server.rb
|
98
|
-
- lib/sunspot/rails/
|
104
|
+
- lib/sunspot/rails/configuration.rb
|
99
105
|
- lib/sunspot/rails/request_lifecycle.rb
|
100
|
-
- lib/sunspot/rails/
|
106
|
+
- lib/sunspot/rails/stub_session_proxy.rb
|
107
|
+
- lib/sunspot/rails/spec_helper.rb
|
108
|
+
- lib/sunspot/rails/tasks.rb
|
109
|
+
- lib/sunspot/rails/searchable.rb
|
110
|
+
- lib/sunspot/rails/adapters.rb
|
111
|
+
- lib/sunspot/rails/init.rb
|
101
112
|
- lib/sunspot/rails.rb
|
102
|
-
-
|
103
|
-
-
|
104
|
-
-
|
113
|
+
- lib/generators/sunspot_rails.rb
|
114
|
+
- lib/generators/sunspot_rails/install/install_generator.rb
|
115
|
+
- lib/generators/sunspot_rails/install/templates/config/sunspot.yml
|
116
|
+
- dev_tasks/spec.rake
|
105
117
|
- dev_tasks/release.rake
|
106
|
-
-
|
118
|
+
- dev_tasks/rdoc.rake
|
119
|
+
- dev_tasks/todo.rake
|
107
120
|
- generators/sunspot/templates/sunspot.yml
|
121
|
+
- generators/sunspot/sunspot_generator.rb
|
108
122
|
- install.rb
|
109
|
-
- rails/init.rb
|
110
|
-
- spec/spec_helper.rb
|
111
123
|
- spec/session_spec.rb
|
112
|
-
- spec/
|
113
|
-
- spec/server_spec.rb
|
124
|
+
- spec/schema.rb
|
114
125
|
- spec/configuration_spec.rb
|
115
126
|
- spec/model_lifecycle_spec.rb
|
116
|
-
- spec/
|
117
|
-
- spec/
|
127
|
+
- spec/spec_helper.rb
|
128
|
+
- spec/stub_session_proxy_spec.rb
|
118
129
|
- spec/request_lifecycle_spec.rb
|
119
|
-
- spec/
|
120
|
-
- spec/
|
121
|
-
- spec/mock_app/app/controllers/application.rb
|
122
|
-
- spec/mock_app/app/models/location.rb
|
123
|
-
- spec/mock_app/app/models/photo_post.rb
|
124
|
-
- spec/mock_app/app/models/blog.rb
|
125
|
-
- spec/mock_app/app/models/post_with_auto.rb
|
126
|
-
- spec/mock_app/app/models/author.rb
|
127
|
-
- spec/mock_app/app/models/post.rb
|
128
|
-
- spec/mock_app/db/schema.rb
|
129
|
-
- spec/mock_app/db/test.db
|
130
|
-
- spec/mock_app/config/database.yml
|
131
|
-
- spec/mock_app/config/environment.rb
|
132
|
-
- spec/mock_app/config/initializers/session_store.rb
|
133
|
-
- spec/mock_app/config/initializers/new_rails_defaults.rb
|
134
|
-
- spec/mock_app/config/sunspot.yml
|
135
|
-
- spec/mock_app/config/environments/development.rb
|
136
|
-
- spec/mock_app/config/environments/test.rb
|
137
|
-
- spec/mock_app/config/routes.rb
|
138
|
-
- spec/mock_app/config/boot.rb
|
130
|
+
- spec/model_spec.rb
|
131
|
+
- spec/server_spec.rb
|
139
132
|
has_rdoc: true
|
140
133
|
homepage: http://github.com/outoftime/sunspot_rails
|
141
134
|
licenses: []
|
@@ -146,23 +139,27 @@ rdoc_options: []
|
|
146
139
|
require_paths:
|
147
140
|
- lib
|
148
141
|
required_ruby_version: !ruby/object:Gem::Requirement
|
142
|
+
none: false
|
149
143
|
requirements:
|
150
144
|
- - ">="
|
151
145
|
- !ruby/object:Gem::Version
|
146
|
+
hash: 3
|
152
147
|
segments:
|
153
148
|
- 0
|
154
149
|
version: "0"
|
155
150
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
|
+
none: false
|
156
152
|
requirements:
|
157
153
|
- - ">="
|
158
154
|
- !ruby/object:Gem::Version
|
155
|
+
hash: 3
|
159
156
|
segments:
|
160
157
|
- 0
|
161
158
|
version: "0"
|
162
159
|
requirements: []
|
163
160
|
|
164
161
|
rubyforge_project: sunspot
|
165
|
-
rubygems_version: 1.3.
|
162
|
+
rubygems_version: 1.3.7
|
166
163
|
signing_key:
|
167
164
|
specification_version: 3
|
168
165
|
summary: Rails integration for the Sunspot Solr search library
|
data/dev_tasks/gemspec.rake
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'tools', 'gem_tasks')
|
2
|
-
|
3
|
-
Sunspot::GemTasks.new do |s|
|
4
|
-
require File.join(File.dirname(__FILE__), '..', 'lib', 'sunspot', 'rails', 'version')
|
5
|
-
|
6
|
-
s.name = 'sunspot_rails'
|
7
|
-
s.version = Sunspot::Rails::VERSION
|
8
|
-
s.summary = 'Rails integration for the Sunspot Solr search library'
|
9
|
-
s.email = 'mat@patch.com'
|
10
|
-
s.homepage = 'http://github.com/outoftime/sunspot_rails'
|
11
|
-
s.description = <<TEXT
|
12
|
-
Sunspot::Rails is an extension to the Sunspot library for Solr search.
|
13
|
-
Sunspot::Rails adds integration between Sunspot and ActiveRecord, including
|
14
|
-
defining search and indexing related methods on ActiveRecord models themselves,
|
15
|
-
running a Sunspot-compatible Solr instance for development and test
|
16
|
-
environments, and automatically commit Solr index changes at the end of each
|
17
|
-
Rails request.
|
18
|
-
TEXT
|
19
|
-
s.authors = ['Mat Brown', 'Peer Allan', 'Michael Moen', 'Benjamin Krause', 'Adam Salter', 'Brandon Keepers', 'Paul Canavese', 'John Eberly', 'Gert Thiel']
|
20
|
-
s.rubyforge_project = 'sunspot'
|
21
|
-
s.files = FileList['[A-Z]*',
|
22
|
-
'{lib,tasks,dev_tasks}/**/*',
|
23
|
-
'generators/**/*',
|
24
|
-
'install.rb',
|
25
|
-
'MIT-LICENSE',
|
26
|
-
'rails/*',
|
27
|
-
'spec/*.rb',
|
28
|
-
'spec/mock_app/{app,lib,db,vendor,config}/**/*',
|
29
|
-
'spec/mock_app/{tmp,log,solr}']
|
30
|
-
s.add_dependency 'sunspot', Sunspot::Rails::VERSION
|
31
|
-
s.add_development_dependency 'rspec', '~> 1.2'
|
32
|
-
s.add_development_dependency 'rspec-rails', '~> 1.2'
|
33
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
# Filters added to this controller apply to all controllers in the application.
|
2
|
-
# Likewise, all the methods added will be available for all controllers.
|
3
|
-
|
4
|
-
class ApplicationController < ActionController::Base
|
5
|
-
helper :all # include all helpers, all the time
|
6
|
-
protect_from_forgery # See ActionController::RequestForgeryProtection for details
|
7
|
-
|
8
|
-
# Scrub sensitive parameters from your log
|
9
|
-
# filter_parameter_logging :password
|
10
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
# Filters added to this controller apply to all controllers in the application.
|
2
|
-
# Likewise, all the methods added will be available for all controllers.
|
3
|
-
|
4
|
-
class ApplicationController < ActionController::Base
|
5
|
-
helper :all # include all helpers, all the time
|
6
|
-
protect_from_forgery # See ActionController::RequestForgeryProtection for details
|
7
|
-
|
8
|
-
# Scrub sensitive parameters from your log
|
9
|
-
# filter_parameter_logging :password
|
10
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
class Blog < ActiveRecord::Base
|
2
|
-
has_many :posts
|
3
|
-
has_many :comments, :through => :posts
|
4
|
-
|
5
|
-
searchable :include => { :posts => :author } do
|
6
|
-
string :subdomain
|
7
|
-
text :name
|
8
|
-
end
|
9
|
-
|
10
|
-
# Make sure that includes are added to with multiple searchable calls
|
11
|
-
searchable(:include => :comments) {}
|
12
|
-
end
|
@@ -1,110 +0,0 @@
|
|
1
|
-
# Don't change this file!
|
2
|
-
# Configure your app in config/environment.rb and config/environments/*.rb
|
3
|
-
|
4
|
-
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
|
5
|
-
|
6
|
-
module Rails
|
7
|
-
class << self
|
8
|
-
def boot!
|
9
|
-
unless booted?
|
10
|
-
preinitialize
|
11
|
-
pick_boot.run
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def booted?
|
16
|
-
defined? Rails::Initializer
|
17
|
-
end
|
18
|
-
|
19
|
-
def pick_boot
|
20
|
-
(vendor_rails? ? VendorBoot : GemBoot).new
|
21
|
-
end
|
22
|
-
|
23
|
-
def vendor_rails?
|
24
|
-
File.exist?("#{RAILS_ROOT}/vendor/rails")
|
25
|
-
end
|
26
|
-
|
27
|
-
def preinitialize
|
28
|
-
load(preinitializer_path) if File.exist?(preinitializer_path)
|
29
|
-
end
|
30
|
-
|
31
|
-
def preinitializer_path
|
32
|
-
"#{RAILS_ROOT}/config/preinitializer.rb"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
class Boot
|
37
|
-
def run
|
38
|
-
load_initializer
|
39
|
-
Rails::Initializer.run(:set_load_path)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
class VendorBoot < Boot
|
44
|
-
def load_initializer
|
45
|
-
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
|
46
|
-
Rails::Initializer.run(:install_gem_spec_stubs)
|
47
|
-
Rails::GemDependency.add_frozen_gem_path
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
class GemBoot < Boot
|
52
|
-
def load_initializer
|
53
|
-
self.class.load_rubygems
|
54
|
-
load_rails_gem
|
55
|
-
require 'initializer'
|
56
|
-
end
|
57
|
-
|
58
|
-
def load_rails_gem
|
59
|
-
if version = self.class.gem_version
|
60
|
-
gem 'rails', version
|
61
|
-
else
|
62
|
-
gem 'rails'
|
63
|
-
end
|
64
|
-
rescue Gem::LoadError => load_error
|
65
|
-
$stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
|
66
|
-
exit 1
|
67
|
-
end
|
68
|
-
|
69
|
-
class << self
|
70
|
-
def rubygems_version
|
71
|
-
Gem::RubyGemsVersion rescue nil
|
72
|
-
end
|
73
|
-
|
74
|
-
def gem_version
|
75
|
-
if defined? RAILS_GEM_VERSION
|
76
|
-
RAILS_GEM_VERSION
|
77
|
-
elsif ENV.include?('RAILS_GEM_VERSION')
|
78
|
-
ENV['RAILS_GEM_VERSION']
|
79
|
-
else
|
80
|
-
parse_gem_version(read_environment_rb)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def load_rubygems
|
85
|
-
require 'rubygems'
|
86
|
-
min_version = '1.3.1'
|
87
|
-
unless rubygems_version >= min_version
|
88
|
-
$stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
|
89
|
-
exit 1
|
90
|
-
end
|
91
|
-
|
92
|
-
rescue LoadError
|
93
|
-
$stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
|
94
|
-
exit 1
|
95
|
-
end
|
96
|
-
|
97
|
-
def parse_gem_version(text)
|
98
|
-
$1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
|
99
|
-
end
|
100
|
-
|
101
|
-
private
|
102
|
-
def read_environment_rb
|
103
|
-
File.read("#{RAILS_ROOT}/config/environment.rb")
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
# All that for this:
|
110
|
-
Rails.boot!
|