onemorecloud-websolr-rails 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +15 -0
- data/LICENSE +19 -0
- data/README.rdoc +69 -0
- data/Rakefile +112 -0
- data/TESTING_THE_PLUGIN +25 -0
- data/VERSION +1 -0
- data/bin/websolr +8 -0
- data/config/solr.yml +15 -0
- data/config/solr_environment.rb +22 -0
- data/generate_rdoc.sh +13 -0
- data/lib/acts_as_solr.rb +59 -0
- data/lib/acts_methods.rb +279 -0
- data/lib/class_methods.rb +239 -0
- data/lib/common_methods.rb +89 -0
- data/lib/deprecation.rb +61 -0
- data/lib/instance_methods.rb +166 -0
- data/lib/lazy_document.rb +18 -0
- data/lib/parser_methods.rb +201 -0
- data/lib/search_results.rb +68 -0
- data/lib/solr.rb +21 -0
- data/lib/solr/connection.rb +179 -0
- data/lib/solr/document.rb +78 -0
- data/lib/solr/exception.rb +13 -0
- data/lib/solr/field.rb +39 -0
- data/lib/solr/importer.rb +19 -0
- data/lib/solr/importer/array_mapper.rb +26 -0
- data/lib/solr/importer/delimited_file_source.rb +38 -0
- data/lib/solr/importer/hpricot_mapper.rb +27 -0
- data/lib/solr/importer/mapper.rb +51 -0
- data/lib/solr/importer/solr_source.rb +43 -0
- data/lib/solr/importer/xpath_mapper.rb +35 -0
- data/lib/solr/indexer.rb +52 -0
- data/lib/solr/request.rb +26 -0
- data/lib/solr/request/add_document.rb +63 -0
- data/lib/solr/request/base.rb +36 -0
- data/lib/solr/request/commit.rb +31 -0
- data/lib/solr/request/delete.rb +50 -0
- data/lib/solr/request/dismax.rb +46 -0
- data/lib/solr/request/index_info.rb +22 -0
- data/lib/solr/request/modify_document.rb +51 -0
- data/lib/solr/request/optimize.rb +21 -0
- data/lib/solr/request/ping.rb +36 -0
- data/lib/solr/request/select.rb +56 -0
- data/lib/solr/request/spellcheck.rb +30 -0
- data/lib/solr/request/standard.rb +402 -0
- data/lib/solr/request/update.rb +23 -0
- data/lib/solr/response.rb +27 -0
- data/lib/solr/response/add_document.rb +17 -0
- data/lib/solr/response/base.rb +42 -0
- data/lib/solr/response/commit.rb +17 -0
- data/lib/solr/response/delete.rb +13 -0
- data/lib/solr/response/dismax.rb +8 -0
- data/lib/solr/response/index_info.rb +26 -0
- data/lib/solr/response/modify_document.rb +17 -0
- data/lib/solr/response/optimize.rb +14 -0
- data/lib/solr/response/ping.rb +28 -0
- data/lib/solr/response/ruby.rb +42 -0
- data/lib/solr/response/select.rb +17 -0
- data/lib/solr/response/spellcheck.rb +20 -0
- data/lib/solr/response/standard.rb +60 -0
- data/lib/solr/response/xml.rb +42 -0
- data/lib/solr/solrtasks.rb +27 -0
- data/lib/solr/util.rb +32 -0
- data/lib/solr/xml.rb +44 -0
- data/lib/solr_fixtures.rb +13 -0
- data/lib/tasks/database.rake +18 -0
- data/lib/tasks/solr.rake +137 -0
- data/lib/tasks/test.rake +7 -0
- data/lib/websolr-rails.rb +1 -0
- data/lib/websolr.rb +1 -0
- data/lib/websolr_controller.rb +132 -0
- data/lib/websolr_option_parser.rb +58 -0
- data/lib/websolr_rails.rb +1 -0
- data/lib/websolr_rails/tasks.rb +4 -0
- data/solr/CHANGES.txt +1207 -0
- data/solr/LICENSE.txt +712 -0
- data/solr/NOTICE.txt +90 -0
- data/solr/etc/jetty.xml +205 -0
- data/solr/etc/webdefault.xml +379 -0
- data/solr/lib/easymock.jar +0 -0
- data/solr/lib/jetty-6.1.3.jar +0 -0
- data/solr/lib/jetty-util-6.1.3.jar +0 -0
- data/solr/lib/jsp-2.1/ant-1.6.5.jar +0 -0
- data/solr/lib/jsp-2.1/core-3.1.1.jar +0 -0
- data/solr/lib/jsp-2.1/jsp-2.1.jar +0 -0
- data/solr/lib/jsp-2.1/jsp-api-2.1.jar +0 -0
- data/solr/lib/servlet-api-2.4.jar +0 -0
- data/solr/lib/servlet-api-2.5-6.1.3.jar +0 -0
- data/solr/lib/xpp3-1.1.3.4.O.jar +0 -0
- data/solr/logs/.empty-dir-for-git +0 -0
- data/solr/solr/README.txt +52 -0
- data/solr/solr/bin/abc +176 -0
- data/solr/solr/bin/abo +176 -0
- data/solr/solr/bin/backup +108 -0
- data/solr/solr/bin/backupcleaner +142 -0
- data/solr/solr/bin/commit +128 -0
- data/solr/solr/bin/optimize +129 -0
- data/solr/solr/bin/readercycle +129 -0
- data/solr/solr/bin/rsyncd-disable +77 -0
- data/solr/solr/bin/rsyncd-enable +76 -0
- data/solr/solr/bin/rsyncd-start +145 -0
- data/solr/solr/bin/rsyncd-stop +105 -0
- data/solr/solr/bin/scripts-util +83 -0
- data/solr/solr/bin/snapcleaner +148 -0
- data/solr/solr/bin/snapinstaller +168 -0
- data/solr/solr/bin/snappuller +248 -0
- data/solr/solr/bin/snappuller-disable +77 -0
- data/solr/solr/bin/snappuller-enable +77 -0
- data/solr/solr/bin/snapshooter +109 -0
- data/solr/solr/conf/admin-extra.html +31 -0
- data/solr/solr/conf/protwords.txt +21 -0
- data/solr/solr/conf/schema.xml +126 -0
- data/solr/solr/conf/scripts.conf +24 -0
- data/solr/solr/conf/solrconfig.xml +458 -0
- data/solr/solr/conf/stopwords.txt +57 -0
- data/solr/solr/conf/synonyms.txt +31 -0
- data/solr/solr/conf/xslt/example.xsl +132 -0
- data/solr/solr/conf/xslt/example_atom.xsl +63 -0
- data/solr/solr/conf/xslt/example_rss.xsl +62 -0
- data/solr/start.jar +0 -0
- data/solr/tmp/.empty-dir-for-git +0 -0
- data/solr/webapps/solr.war +0 -0
- data/test/config/solr.yml +2 -0
- data/test/db/connections/mysql/connection.rb +10 -0
- data/test/db/connections/sqlite/connection.rb +8 -0
- data/test/db/migrate/001_create_books.rb +15 -0
- data/test/db/migrate/002_create_movies.rb +12 -0
- data/test/db/migrate/003_create_categories.rb +11 -0
- data/test/db/migrate/004_create_electronics.rb +16 -0
- data/test/db/migrate/005_create_authors.rb +12 -0
- data/test/db/migrate/006_create_postings.rb +9 -0
- data/test/db/migrate/007_create_posts.rb +13 -0
- data/test/db/migrate/008_create_gadgets.rb +11 -0
- data/test/fixtures/authors.yml +9 -0
- data/test/fixtures/books.yml +13 -0
- data/test/fixtures/categories.yml +7 -0
- data/test/fixtures/db_definitions/mysql.sql +41 -0
- data/test/fixtures/electronics.yml +49 -0
- data/test/fixtures/movies.yml +9 -0
- data/test/fixtures/postings.yml +10 -0
- data/test/functional/acts_as_solr_test.rb +413 -0
- data/test/functional/association_indexing_test.rb +37 -0
- data/test/functional/faceted_search_test.rb +163 -0
- data/test/functional/multi_solr_search_test.rb +51 -0
- data/test/models/author.rb +10 -0
- data/test/models/book.rb +10 -0
- data/test/models/category.rb +8 -0
- data/test/models/electronic.rb +21 -0
- data/test/models/gadget.rb +9 -0
- data/test/models/movie.rb +17 -0
- data/test/models/novel.rb +2 -0
- data/test/models/post.rb +3 -0
- data/test/models/posting.rb +11 -0
- data/test/test_helper.rb +51 -0
- data/test/unit/acts_methods_shoulda.rb +70 -0
- data/test/unit/class_methods_shoulda.rb +88 -0
- data/test/unit/common_methods_shoulda.rb +112 -0
- data/test/unit/instance_methods_shoulda.rb +326 -0
- data/test/unit/lazy_document_shoulda.rb +35 -0
- data/test/unit/parser_instance.rb +19 -0
- data/test/unit/parser_methods_shoulda.rb +278 -0
- data/test/unit/solr_instance.rb +46 -0
- data/test/unit/test_helper.rb +14 -0
- data/websolr-rails.gemspec +241 -0
- metadata +263 -0
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'lazy_document'
|
3
|
+
|
4
|
+
class UserModel; end
|
5
|
+
|
6
|
+
class LazyDocumentTest < Test::Unit::TestCase
|
7
|
+
context "With a lazy document" do
|
8
|
+
setup do
|
9
|
+
@record = stub(:record)
|
10
|
+
@record.stubs(:is_valid?).returns true
|
11
|
+
UserModel.stubs(:find).returns @record
|
12
|
+
@document = ActsAsSolr::LazyDocument.new(1, UserModel)
|
13
|
+
end
|
14
|
+
|
15
|
+
context "with an uninitialized document" do
|
16
|
+
should "fetch the record from the database" do
|
17
|
+
UserModel.expects(:find).with(1).returns(@record)
|
18
|
+
@document.is_valid?
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "with an initialized document" do
|
23
|
+
should "not fetch the record again" do
|
24
|
+
@document.is_valid?
|
25
|
+
@document.expects(:find).never
|
26
|
+
@document.is_valid?
|
27
|
+
end
|
28
|
+
|
29
|
+
should "reroute the calls to the record" do
|
30
|
+
@record.expects(:is_valid?).once
|
31
|
+
@document.is_valid?
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class ActsAsSolr::ParserInstance
|
2
|
+
include ActsAsSolr::ParserMethods
|
3
|
+
include ActsAsSolr::CommonMethods
|
4
|
+
attr_accessor :configuration, :solr_configuration
|
5
|
+
|
6
|
+
def table_name
|
7
|
+
"documents"
|
8
|
+
end
|
9
|
+
|
10
|
+
def primary_key
|
11
|
+
"id"
|
12
|
+
end
|
13
|
+
|
14
|
+
def find(*args)
|
15
|
+
[]
|
16
|
+
end
|
17
|
+
|
18
|
+
public :parse_results, :reorder, :parse_query, :add_scores, :replace_types
|
19
|
+
end
|
@@ -0,0 +1,278 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
require 'parser_methods'
|
3
|
+
require 'common_methods'
|
4
|
+
require 'search_results'
|
5
|
+
require 'deprecation'
|
6
|
+
module Solr; module Request; end; end
|
7
|
+
require 'solr/request/base'
|
8
|
+
require 'solr/request/select'
|
9
|
+
require 'solr/request/standard'
|
10
|
+
require 'parser_instance'
|
11
|
+
require 'lazy_document'
|
12
|
+
|
13
|
+
class ActsAsSolr::Post; end
|
14
|
+
|
15
|
+
class ParserMethodsTest < Test::Unit::TestCase
|
16
|
+
|
17
|
+
context "With a parser instance" do
|
18
|
+
setup do
|
19
|
+
@parser = ActsAsSolr::ParserInstance.new
|
20
|
+
end
|
21
|
+
|
22
|
+
context "When parsing results" do
|
23
|
+
setup do
|
24
|
+
@results = stub(:results)
|
25
|
+
@results.stubs(:total_hits).returns(2)
|
26
|
+
@results.stubs(:hits).returns([])
|
27
|
+
@results.stubs(:max_score).returns 2.1
|
28
|
+
@results.stubs(:data).returns({"responseHeader" => {"QTime" => "10.2"}})
|
29
|
+
end
|
30
|
+
|
31
|
+
should "return a SearchResults object" do
|
32
|
+
assert_equal ActsAsSolr::SearchResults, @parser.parse_results(@results).class
|
33
|
+
end
|
34
|
+
|
35
|
+
should "set the max score" do
|
36
|
+
assert_equal 2.1, @parser.parse_results(@results).max_score
|
37
|
+
end
|
38
|
+
|
39
|
+
should "include the facets" do
|
40
|
+
@results.stubs(:data).returns({"responseHeader" => {"QTime" => "10.2"}, "facet_counts" => 2})
|
41
|
+
assert_equal 2, @parser.parse_results(@results, :facets => true).facets
|
42
|
+
end
|
43
|
+
|
44
|
+
context "when the format requests objects" do
|
45
|
+
setup do
|
46
|
+
@parser.configuration = {:format => :objects}
|
47
|
+
@parser.solr_configuration = {:primary_key_field => :pk_id}
|
48
|
+
@results.stubs(:hits).returns [{"pk_id" => 1}, {"pk_id" => 2}]
|
49
|
+
@parser.stubs(:reorder)
|
50
|
+
end
|
51
|
+
|
52
|
+
should "query with the record ids" do
|
53
|
+
@parser.expects(:find).with(:all, :conditions => ["documents.id in (?)", [1, 2]]).returns [1, 2]
|
54
|
+
@parser.parse_results(@results)
|
55
|
+
end
|
56
|
+
|
57
|
+
should "reorder the records" do
|
58
|
+
@parser.expects(:reorder).with([], [1, 2])
|
59
|
+
@parser.parse_results(@results)
|
60
|
+
end
|
61
|
+
|
62
|
+
should "add :include if :include was specified" do
|
63
|
+
@parser.expects(:find).with(:all, :conditions => ["documents.id in (?)", [1, 2]], :include => [:author]).returns [1, 2]
|
64
|
+
@parser.parse_results(@results, :include => [:author])
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context "when the format doesn't request objects" do
|
69
|
+
setup do
|
70
|
+
@parser.solr_configuration = {:primary_key_field => "pk_id"}
|
71
|
+
end
|
72
|
+
|
73
|
+
should "not query the database" do
|
74
|
+
@parser.expects(:find).never
|
75
|
+
@parser.parse_results(@results, :format => nil)
|
76
|
+
end
|
77
|
+
|
78
|
+
should "return just the ids" do
|
79
|
+
@results.stubs(:hits).returns([{"pk_id" => 1}, {"pk_id" => 2}])
|
80
|
+
assert_equal [1, 2], @parser.parse_results(@results, :format => nil).docs
|
81
|
+
end
|
82
|
+
|
83
|
+
should "ignore the :lazy option" do
|
84
|
+
@results.stubs(:hits).returns([{"pk_id" => 1}, {"pk_id" => 2}])
|
85
|
+
assert_equal [1, 2], @parser.parse_results(@results, :format => :ids, :lazy => true).docs
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
context "with an empty result set" do
|
90
|
+
setup do
|
91
|
+
@results.stubs(:total_hits).returns(0)
|
92
|
+
@results.stubs(:hits).returns([])
|
93
|
+
end
|
94
|
+
|
95
|
+
should "return an empty search results set" do
|
96
|
+
assert_equal 0, @parser.parse_results(@results).total
|
97
|
+
end
|
98
|
+
|
99
|
+
should "not have any search results" do
|
100
|
+
assert_equal [], @parser.parse_results(@results).docs
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
context "with a nil result set" do
|
105
|
+
should "return an empty search results set" do
|
106
|
+
assert_equal 0, @parser.parse_results(nil).total
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
context "with the scores option" do
|
111
|
+
should "add the scores" do
|
112
|
+
@parser.expects(:add_scores).with([], @results)
|
113
|
+
@parser.parse_results(@results, :scores => true)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
context "with lazy format" do
|
118
|
+
setup do
|
119
|
+
@parser.solr_configuration = {:primary_key_field => :pk_id}
|
120
|
+
@results.stubs(:hits).returns([{"pk_id" => 1}, {"pk_id" => 2}])
|
121
|
+
end
|
122
|
+
|
123
|
+
should "create LazyDocuments for the resulting docs" do
|
124
|
+
result = @parser.parse_results(@results, :lazy => true)
|
125
|
+
assert_equal ActsAsSolr::LazyDocument, result.results.first.class
|
126
|
+
end
|
127
|
+
|
128
|
+
should "set the document id as the record id" do
|
129
|
+
result = @parser.parse_results(@results, :lazy => true)
|
130
|
+
assert_equal 1, result.results.first.id
|
131
|
+
end
|
132
|
+
|
133
|
+
should "set the document class" do
|
134
|
+
result = @parser.parse_results(@results, :lazy => true)
|
135
|
+
assert_equal ActsAsSolr::ParserInstance, result.results.first.clazz.class
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
140
|
+
|
141
|
+
context "when reordering results" do
|
142
|
+
should "raise an error if arguments don't have the same number of elements" do
|
143
|
+
assert_raise(RuntimeError) {@parser.reorder([], [1])}
|
144
|
+
end
|
145
|
+
|
146
|
+
should "reorder the results to match the order of the documents returned by solr" do
|
147
|
+
thing1 = stub(:thing1)
|
148
|
+
thing1.stubs(:id).returns 5
|
149
|
+
thing2 = stub(:thing2)
|
150
|
+
thing2.stubs(:id).returns 1
|
151
|
+
thing3 = stub(:things3)
|
152
|
+
thing3.stubs(:id).returns 3
|
153
|
+
things = [thing1, thing2, thing3]
|
154
|
+
reordered = @parser.reorder(things, [1, 3, 5])
|
155
|
+
assert_equal [1, 3, 5], reordered.collect{|thing| thing.id}
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
context "When parsing a query" do
|
160
|
+
setup do
|
161
|
+
ActsAsSolr::Post.stubs(:execute)
|
162
|
+
@parser.stubs(:solr_type_condition).returns "(type:ParserMethodsTest)"
|
163
|
+
@parser.solr_configuration = {:primary_key_field => "id"}
|
164
|
+
@parser.configuration = {:solr_fields => nil}
|
165
|
+
end
|
166
|
+
|
167
|
+
should "set the limit and offset" do
|
168
|
+
ActsAsSolr::Post.expects(:execute).with {|request|
|
169
|
+
10 == request.to_hash[:rows]
|
170
|
+
20 == request.to_hash[:start]
|
171
|
+
}
|
172
|
+
@parser.parse_query "foo", :limit => 10, :offset => 20
|
173
|
+
end
|
174
|
+
|
175
|
+
should "set the operator" do
|
176
|
+
ActsAsSolr::Post.expects(:execute).with {|request|
|
177
|
+
"OR" == request.to_hash["q.op"]
|
178
|
+
}
|
179
|
+
@parser.parse_query "foo", :operator => :or
|
180
|
+
end
|
181
|
+
|
182
|
+
should "not execute anything if the query is nil" do
|
183
|
+
ActsAsSolr::Post.expects(:execute).never
|
184
|
+
assert_nil @parser.parse_query(nil)
|
185
|
+
end
|
186
|
+
|
187
|
+
should "not execute anything if the query is ''" do
|
188
|
+
ActsAsSolr::Post.expects(:execute).never
|
189
|
+
assert_nil @parser.parse_query('')
|
190
|
+
end
|
191
|
+
|
192
|
+
should "raise an error if invalid options where specified" do
|
193
|
+
assert_raise(RuntimeError) {@parser.parse_query "foo", :invalid => true}
|
194
|
+
end
|
195
|
+
|
196
|
+
should "add the type" do
|
197
|
+
ActsAsSolr::Post.expects(:execute).with {|request|
|
198
|
+
request.to_hash[:q].include?("(type:ParserMethodsTest)")
|
199
|
+
}
|
200
|
+
@parser.parse_query "foo"
|
201
|
+
end
|
202
|
+
|
203
|
+
should "append the field types for the specified fields" do
|
204
|
+
ActsAsSolr::Post.expects(:execute).with {|request|
|
205
|
+
request.to_hash[:q].include?("(username_t:Chunky)")
|
206
|
+
}
|
207
|
+
@parser.parse_query "username:Chunky"
|
208
|
+
end
|
209
|
+
|
210
|
+
should "replace the field types" do
|
211
|
+
@parser.expects(:replace_types).returns(["active_i:1"])
|
212
|
+
ActsAsSolr::Post.expects(:execute).with {|request|
|
213
|
+
request.to_hash[:q].include?("active_i:1")
|
214
|
+
}
|
215
|
+
@parser.parse_query "active:1"
|
216
|
+
end
|
217
|
+
|
218
|
+
should "add score and primary key to field list" do
|
219
|
+
ActsAsSolr::Post.expects(:execute).with {|request|
|
220
|
+
request.to_hash[:fl] == ('id,score')
|
221
|
+
}
|
222
|
+
@parser.parse_query "foo"
|
223
|
+
end
|
224
|
+
|
225
|
+
context "with the order option" do
|
226
|
+
should "add the order criteria to the query" do
|
227
|
+
ActsAsSolr::Post.expects(:execute).with {|request|
|
228
|
+
request.to_hash[:q].include?(";active_t desc")
|
229
|
+
}
|
230
|
+
@parser.parse_query "active:1", :order => "active desc"
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
context "with facets" do
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
context "When setting the field types" do
|
239
|
+
setup do
|
240
|
+
@parser.configuration = {:solr_fields => {:name => {:type => :string},
|
241
|
+
:age => {:type => :integer}}}
|
242
|
+
end
|
243
|
+
|
244
|
+
should "replace the _t suffix with the real type" do
|
245
|
+
assert_equal ["name_s:Chunky AND age_i:21"], @parser.replace_types(["name_t:Chunky AND age_t:21"])
|
246
|
+
end
|
247
|
+
|
248
|
+
context "with a suffix" do
|
249
|
+
should "not include the colon when false" do
|
250
|
+
assert_equal ["name_s"], @parser.replace_types(["name_t"], false)
|
251
|
+
end
|
252
|
+
|
253
|
+
should "include the colon by default" do
|
254
|
+
assert_equal ["name_s:Chunky"], @parser.replace_types(["name_t:Chunky"])
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
context "When adding scores" do
|
260
|
+
setup do
|
261
|
+
@solr_data = stub(:results)
|
262
|
+
@solr_data.stubs(:total_hits).returns(1)
|
263
|
+
@solr_data.stubs(:hits).returns([{"id" => 2, "score" => 2.546}])
|
264
|
+
@solr_data.stubs(:max_score).returns 2.1
|
265
|
+
|
266
|
+
@results = [Array.new]
|
267
|
+
|
268
|
+
@parser.stubs(:record_id).returns(2)
|
269
|
+
|
270
|
+
@parser.solr_configuration = {:primary_key_field => "id"}
|
271
|
+
end
|
272
|
+
|
273
|
+
should "add the score to the result document" do
|
274
|
+
assert_equal 2.546, @parser.add_scores(@results, @solr_data).first.last.solr_score
|
275
|
+
end
|
276
|
+
end
|
277
|
+
end
|
278
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'instance_methods'
|
2
|
+
|
3
|
+
class SolrInstance
|
4
|
+
include ActsAsSolr::InstanceMethods
|
5
|
+
attr_accessor :configuration, :solr_configuration, :name
|
6
|
+
|
7
|
+
def initialize(name = "Chunky bacon!")
|
8
|
+
@name = name
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.primary_key
|
12
|
+
"id"
|
13
|
+
end
|
14
|
+
|
15
|
+
def logger
|
16
|
+
@logger ||= Logger.new(StringIO.new)
|
17
|
+
end
|
18
|
+
|
19
|
+
def record_id(obj)
|
20
|
+
10
|
21
|
+
end
|
22
|
+
|
23
|
+
def boost_rate
|
24
|
+
10.0
|
25
|
+
end
|
26
|
+
|
27
|
+
def irate
|
28
|
+
8.0
|
29
|
+
end
|
30
|
+
|
31
|
+
def name_for_solr
|
32
|
+
name
|
33
|
+
end
|
34
|
+
|
35
|
+
def id_for_solr
|
36
|
+
"bogus"
|
37
|
+
end
|
38
|
+
|
39
|
+
def type_for_solr
|
40
|
+
"humbug"
|
41
|
+
end
|
42
|
+
|
43
|
+
def get_solr_field_type(args)
|
44
|
+
"s"
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
$:.unshift(File.join(File.expand_path(File.dirname(__FILE__)), "..", "..", "lib"))
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'test/unit'
|
5
|
+
|
6
|
+
if RUBY_VERSION =~ /^1\.9/
|
7
|
+
puts "\nRunning the unit test suite doesn't as of yet work with Ruby 1.9, because Mocha hasn't yet been updated to use minitest."
|
8
|
+
puts
|
9
|
+
exit 1
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'mocha'
|
13
|
+
gem 'thoughtbot-shoulda'
|
14
|
+
require 'shoulda'
|
@@ -0,0 +1,241 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{websolr-rails}
|
8
|
+
s.version = "1.1.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Kyle Maxwell"]
|
12
|
+
s.date = %q{2009-08-24}
|
13
|
+
s.default_executable = %q{websolr}
|
14
|
+
s.description = %q{acts_as_solr compatible gem for websolr}
|
15
|
+
s.email = %q{kyle@kylemaxwell.com}
|
16
|
+
s.executables = ["websolr"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE",
|
19
|
+
"README.rdoc"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
".gitignore",
|
24
|
+
"LICENSE",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"TESTING_THE_PLUGIN",
|
28
|
+
"VERSION",
|
29
|
+
"bin/websolr",
|
30
|
+
"config/solr.yml",
|
31
|
+
"config/solr_environment.rb",
|
32
|
+
"generate_rdoc.sh",
|
33
|
+
"lib/acts_as_solr.rb",
|
34
|
+
"lib/acts_methods.rb",
|
35
|
+
"lib/class_methods.rb",
|
36
|
+
"lib/common_methods.rb",
|
37
|
+
"lib/deprecation.rb",
|
38
|
+
"lib/instance_methods.rb",
|
39
|
+
"lib/lazy_document.rb",
|
40
|
+
"lib/parser_methods.rb",
|
41
|
+
"lib/search_results.rb",
|
42
|
+
"lib/solr.rb",
|
43
|
+
"lib/solr/connection.rb",
|
44
|
+
"lib/solr/document.rb",
|
45
|
+
"lib/solr/exception.rb",
|
46
|
+
"lib/solr/field.rb",
|
47
|
+
"lib/solr/importer.rb",
|
48
|
+
"lib/solr/importer/array_mapper.rb",
|
49
|
+
"lib/solr/importer/delimited_file_source.rb",
|
50
|
+
"lib/solr/importer/hpricot_mapper.rb",
|
51
|
+
"lib/solr/importer/mapper.rb",
|
52
|
+
"lib/solr/importer/solr_source.rb",
|
53
|
+
"lib/solr/importer/xpath_mapper.rb",
|
54
|
+
"lib/solr/indexer.rb",
|
55
|
+
"lib/solr/request.rb",
|
56
|
+
"lib/solr/request/add_document.rb",
|
57
|
+
"lib/solr/request/base.rb",
|
58
|
+
"lib/solr/request/commit.rb",
|
59
|
+
"lib/solr/request/delete.rb",
|
60
|
+
"lib/solr/request/dismax.rb",
|
61
|
+
"lib/solr/request/index_info.rb",
|
62
|
+
"lib/solr/request/modify_document.rb",
|
63
|
+
"lib/solr/request/optimize.rb",
|
64
|
+
"lib/solr/request/ping.rb",
|
65
|
+
"lib/solr/request/select.rb",
|
66
|
+
"lib/solr/request/spellcheck.rb",
|
67
|
+
"lib/solr/request/standard.rb",
|
68
|
+
"lib/solr/request/update.rb",
|
69
|
+
"lib/solr/response.rb",
|
70
|
+
"lib/solr/response/add_document.rb",
|
71
|
+
"lib/solr/response/base.rb",
|
72
|
+
"lib/solr/response/commit.rb",
|
73
|
+
"lib/solr/response/delete.rb",
|
74
|
+
"lib/solr/response/dismax.rb",
|
75
|
+
"lib/solr/response/index_info.rb",
|
76
|
+
"lib/solr/response/modify_document.rb",
|
77
|
+
"lib/solr/response/optimize.rb",
|
78
|
+
"lib/solr/response/ping.rb",
|
79
|
+
"lib/solr/response/ruby.rb",
|
80
|
+
"lib/solr/response/select.rb",
|
81
|
+
"lib/solr/response/spellcheck.rb",
|
82
|
+
"lib/solr/response/standard.rb",
|
83
|
+
"lib/solr/response/xml.rb",
|
84
|
+
"lib/solr/solrtasks.rb",
|
85
|
+
"lib/solr/util.rb",
|
86
|
+
"lib/solr/xml.rb",
|
87
|
+
"lib/solr_fixtures.rb",
|
88
|
+
"lib/tasks/database.rake",
|
89
|
+
"lib/tasks/solr.rake",
|
90
|
+
"lib/tasks/test.rake",
|
91
|
+
"lib/websolr-rails.rb",
|
92
|
+
"lib/websolr.rb",
|
93
|
+
"lib/websolr_controller.rb",
|
94
|
+
"lib/websolr_option_parser.rb",
|
95
|
+
"lib/websolr_rails.rb",
|
96
|
+
"lib/websolr_rails/tasks.rb",
|
97
|
+
"solr/CHANGES.txt",
|
98
|
+
"solr/LICENSE.txt",
|
99
|
+
"solr/NOTICE.txt",
|
100
|
+
"solr/etc/jetty.xml",
|
101
|
+
"solr/etc/webdefault.xml",
|
102
|
+
"solr/lib/easymock.jar",
|
103
|
+
"solr/lib/jetty-6.1.3.jar",
|
104
|
+
"solr/lib/jetty-util-6.1.3.jar",
|
105
|
+
"solr/lib/jsp-2.1/ant-1.6.5.jar",
|
106
|
+
"solr/lib/jsp-2.1/core-3.1.1.jar",
|
107
|
+
"solr/lib/jsp-2.1/jsp-2.1.jar",
|
108
|
+
"solr/lib/jsp-2.1/jsp-api-2.1.jar",
|
109
|
+
"solr/lib/servlet-api-2.4.jar",
|
110
|
+
"solr/lib/servlet-api-2.5-6.1.3.jar",
|
111
|
+
"solr/lib/xpp3-1.1.3.4.O.jar",
|
112
|
+
"solr/logs/.empty-dir-for-git",
|
113
|
+
"solr/solr/README.txt",
|
114
|
+
"solr/solr/bin/abc",
|
115
|
+
"solr/solr/bin/abo",
|
116
|
+
"solr/solr/bin/backup",
|
117
|
+
"solr/solr/bin/backupcleaner",
|
118
|
+
"solr/solr/bin/commit",
|
119
|
+
"solr/solr/bin/optimize",
|
120
|
+
"solr/solr/bin/readercycle",
|
121
|
+
"solr/solr/bin/rsyncd-disable",
|
122
|
+
"solr/solr/bin/rsyncd-enable",
|
123
|
+
"solr/solr/bin/rsyncd-start",
|
124
|
+
"solr/solr/bin/rsyncd-stop",
|
125
|
+
"solr/solr/bin/scripts-util",
|
126
|
+
"solr/solr/bin/snapcleaner",
|
127
|
+
"solr/solr/bin/snapinstaller",
|
128
|
+
"solr/solr/bin/snappuller",
|
129
|
+
"solr/solr/bin/snappuller-disable",
|
130
|
+
"solr/solr/bin/snappuller-enable",
|
131
|
+
"solr/solr/bin/snapshooter",
|
132
|
+
"solr/solr/conf/admin-extra.html",
|
133
|
+
"solr/solr/conf/protwords.txt",
|
134
|
+
"solr/solr/conf/schema.xml",
|
135
|
+
"solr/solr/conf/scripts.conf",
|
136
|
+
"solr/solr/conf/solrconfig.xml",
|
137
|
+
"solr/solr/conf/stopwords.txt",
|
138
|
+
"solr/solr/conf/synonyms.txt",
|
139
|
+
"solr/solr/conf/xslt/example.xsl",
|
140
|
+
"solr/solr/conf/xslt/example_atom.xsl",
|
141
|
+
"solr/solr/conf/xslt/example_rss.xsl",
|
142
|
+
"solr/start.jar",
|
143
|
+
"solr/tmp/.empty-dir-for-git",
|
144
|
+
"solr/webapps/solr.war",
|
145
|
+
"test/config/solr.yml",
|
146
|
+
"test/db/connections/mysql/connection.rb",
|
147
|
+
"test/db/connections/sqlite/connection.rb",
|
148
|
+
"test/db/migrate/001_create_books.rb",
|
149
|
+
"test/db/migrate/002_create_movies.rb",
|
150
|
+
"test/db/migrate/003_create_categories.rb",
|
151
|
+
"test/db/migrate/004_create_electronics.rb",
|
152
|
+
"test/db/migrate/005_create_authors.rb",
|
153
|
+
"test/db/migrate/006_create_postings.rb",
|
154
|
+
"test/db/migrate/007_create_posts.rb",
|
155
|
+
"test/db/migrate/008_create_gadgets.rb",
|
156
|
+
"test/fixtures/authors.yml",
|
157
|
+
"test/fixtures/books.yml",
|
158
|
+
"test/fixtures/categories.yml",
|
159
|
+
"test/fixtures/db_definitions/mysql.sql",
|
160
|
+
"test/fixtures/electronics.yml",
|
161
|
+
"test/fixtures/movies.yml",
|
162
|
+
"test/fixtures/postings.yml",
|
163
|
+
"test/functional/acts_as_solr_test.rb",
|
164
|
+
"test/functional/association_indexing_test.rb",
|
165
|
+
"test/functional/faceted_search_test.rb",
|
166
|
+
"test/functional/multi_solr_search_test.rb",
|
167
|
+
"test/models/author.rb",
|
168
|
+
"test/models/book.rb",
|
169
|
+
"test/models/category.rb",
|
170
|
+
"test/models/electronic.rb",
|
171
|
+
"test/models/gadget.rb",
|
172
|
+
"test/models/movie.rb",
|
173
|
+
"test/models/novel.rb",
|
174
|
+
"test/models/post.rb",
|
175
|
+
"test/models/posting.rb",
|
176
|
+
"test/test_helper.rb",
|
177
|
+
"test/unit/acts_methods_shoulda.rb",
|
178
|
+
"test/unit/class_methods_shoulda.rb",
|
179
|
+
"test/unit/common_methods_shoulda.rb",
|
180
|
+
"test/unit/instance_methods_shoulda.rb",
|
181
|
+
"test/unit/lazy_document_shoulda.rb",
|
182
|
+
"test/unit/parser_instance.rb",
|
183
|
+
"test/unit/parser_methods_shoulda.rb",
|
184
|
+
"test/unit/solr_instance.rb",
|
185
|
+
"test/unit/test_helper.rb",
|
186
|
+
"websolr-rails.gemspec"
|
187
|
+
]
|
188
|
+
s.homepage = %q{http://github.com/onemorecloud/websolr-rails}
|
189
|
+
s.rdoc_options = ["--main", "README.rdoc", "README.rdoc", "lib"]
|
190
|
+
s.require_paths = ["lib"]
|
191
|
+
s.rubygems_version = %q{1.3.5}
|
192
|
+
s.summary = %q{acts_as_solr compatible gem for websolr}
|
193
|
+
s.test_files = [
|
194
|
+
"test/db/connections/mysql/connection.rb",
|
195
|
+
"test/db/connections/sqlite/connection.rb",
|
196
|
+
"test/db/migrate/001_create_books.rb",
|
197
|
+
"test/db/migrate/002_create_movies.rb",
|
198
|
+
"test/db/migrate/003_create_categories.rb",
|
199
|
+
"test/db/migrate/004_create_electronics.rb",
|
200
|
+
"test/db/migrate/005_create_authors.rb",
|
201
|
+
"test/db/migrate/006_create_postings.rb",
|
202
|
+
"test/db/migrate/007_create_posts.rb",
|
203
|
+
"test/db/migrate/008_create_gadgets.rb",
|
204
|
+
"test/functional/acts_as_solr_test.rb",
|
205
|
+
"test/functional/association_indexing_test.rb",
|
206
|
+
"test/functional/faceted_search_test.rb",
|
207
|
+
"test/functional/multi_solr_search_test.rb",
|
208
|
+
"test/models/author.rb",
|
209
|
+
"test/models/book.rb",
|
210
|
+
"test/models/category.rb",
|
211
|
+
"test/models/electronic.rb",
|
212
|
+
"test/models/gadget.rb",
|
213
|
+
"test/models/movie.rb",
|
214
|
+
"test/models/novel.rb",
|
215
|
+
"test/models/post.rb",
|
216
|
+
"test/models/posting.rb",
|
217
|
+
"test/test_helper.rb",
|
218
|
+
"test/unit/acts_methods_shoulda.rb",
|
219
|
+
"test/unit/class_methods_shoulda.rb",
|
220
|
+
"test/unit/common_methods_shoulda.rb",
|
221
|
+
"test/unit/instance_methods_shoulda.rb",
|
222
|
+
"test/unit/lazy_document_shoulda.rb",
|
223
|
+
"test/unit/parser_instance.rb",
|
224
|
+
"test/unit/parser_methods_shoulda.rb",
|
225
|
+
"test/unit/solr_instance.rb",
|
226
|
+
"test/unit/test_helper.rb"
|
227
|
+
]
|
228
|
+
|
229
|
+
if s.respond_to? :specification_version then
|
230
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
231
|
+
s.specification_version = 3
|
232
|
+
|
233
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
234
|
+
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
235
|
+
else
|
236
|
+
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
237
|
+
end
|
238
|
+
else
|
239
|
+
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
240
|
+
end
|
241
|
+
end
|