honkster-acts_as_solr 0.3.4 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -2
- data/VERSION.yml +2 -1
- data/lib/acts_as_solr/acts_methods.rb +6 -12
- data/lib/acts_as_solr/parser_methods.rb +1 -6
- data/lib/solr/connection.rb +6 -4
- data/test/unit/parser_instance.rb +1 -1
- data/test/unit/parser_methods_shoulda.rb +0 -12
- metadata +32 -30
data/Rakefile
CHANGED
@@ -57,8 +57,8 @@ end
|
|
57
57
|
begin
|
58
58
|
require 'jeweler'
|
59
59
|
Jeweler::Tasks.new do |s|
|
60
|
-
s.name = "acts_as_solr"
|
61
|
-
|
60
|
+
# s.name = "acts_as_solr"
|
61
|
+
s.name = "honkster-acts_as_solr"
|
62
62
|
s.summary = "This plugin adds full text search capabilities and many other nifty features from Apache�s Solr to any Rails model. I'm currently rearranging the test suite to include a real unit test suite, and adding a few features I need myself."
|
63
63
|
s.email = "meyer@paperplanes.de"
|
64
64
|
s.homepage = "http://github.com/mattmatt/acts_as_solr"
|
data/VERSION.yml
CHANGED
@@ -286,18 +286,12 @@ module ActsAsSolr #:nodoc:
|
|
286
286
|
configuration[:solr_fields][field_name] = options
|
287
287
|
|
288
288
|
define_method("#{field_name}_for_solr".to_sym) do
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
else value
|
296
|
-
end
|
297
|
-
rescue
|
298
|
-
puts $!
|
299
|
-
logger.debug "There was a problem getting the value for the field '#{field_name}': #{$!}"
|
300
|
-
value = ''
|
289
|
+
value = self[field_name] || self.instance_variable_get("@#{field_name.to_s}".to_sym) || self.send(field_name.to_sym)
|
290
|
+
case options[:type]
|
291
|
+
# format dates properly; return nil for nil dates
|
292
|
+
when :date
|
293
|
+
value ? (value.respond_to?(:utc) ? value.utc : value).strftime("%Y-%m-%dT%H:%M:%SZ") : nil
|
294
|
+
else value
|
301
295
|
end
|
302
296
|
end
|
303
297
|
end
|
@@ -72,8 +72,7 @@ module ActsAsSolr #:nodoc:
|
|
72
72
|
query_options[:field_list] = [field_list, 'score']
|
73
73
|
query = "(#{query.gsub(/ *: */,"_t:")}) #{models}"
|
74
74
|
order = options[:order].split(/\s*,\s*/).collect{|e| e.gsub(/\s+/,'_t ').gsub(/\bscore_t\b/, 'score') }.join(',') if options[:order]
|
75
|
-
query_options[:query] = replace_types([query])[0] # TODO adjust replace_types to work with String or Array
|
76
|
-
query_options[:query] = quote_values_with_spaces(query_options[:query])
|
75
|
+
query_options[:query] = replace_types([query])[0] # TODO adjust replace_types to work with String or Array
|
77
76
|
|
78
77
|
if options[:order]
|
79
78
|
# TODO: set the sort parameter instead of the old ;order. style.
|
@@ -167,10 +166,6 @@ module ActsAsSolr #:nodoc:
|
|
167
166
|
end
|
168
167
|
strings
|
169
168
|
end
|
170
|
-
|
171
|
-
def quote_values_with_spaces(string)
|
172
|
-
string.gsub(/:([^\s\)]*)\s([^\s\)]*)\)/, ':"\1 \2")')
|
173
|
-
end
|
174
169
|
|
175
170
|
# Adds the score to each one of the instances found
|
176
171
|
def add_scores(results, solr_data)
|
data/lib/solr/connection.rb
CHANGED
@@ -153,10 +153,12 @@ class Solr::Connection
|
|
153
153
|
# send the http post request to solr; for convenience there are shortcuts
|
154
154
|
# to some requests: add(), query(), commit(), delete() or send()
|
155
155
|
def post(request)
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
156
|
+
|
157
|
+
url = @url.path + "/" + request.handler
|
158
|
+
RAILS_DEFAULT_LOGGER.info "acts_as_solr url: #{url}"
|
159
|
+
RAILS_DEFAULT_LOGGER.info "acts_as_solr post params: #{request.to_s}"
|
160
|
+
response = @connection.post( url, request.to_s, { "Content-Type" => request.content_type })
|
161
|
+
|
160
162
|
case response
|
161
163
|
when Net::HTTPSuccess then response.body
|
162
164
|
else
|
@@ -245,18 +245,6 @@ class ParserMethodsTest < Test::Unit::TestCase
|
|
245
245
|
end
|
246
246
|
end
|
247
247
|
end
|
248
|
-
|
249
|
-
context "When quoting strings" do
|
250
|
-
|
251
|
-
should "quote values that have spaces" do
|
252
|
-
assert_equal '(some_facet:"One Fish") AND (other_t:"Two Fish")', @parser.quote_values_with_spaces("(some_facet:One Fish) AND (other_t:Two Fish)")
|
253
|
-
end
|
254
|
-
|
255
|
-
should "not quote values that do not have spaces" do
|
256
|
-
assert_equal '(age_i:21) OR (some_facet:foo)', @parser.quote_values_with_spaces("(age_i:21) OR (some_facet:foo)")
|
257
|
-
end
|
258
|
-
|
259
|
-
end
|
260
248
|
|
261
249
|
context "When adding scores" do
|
262
250
|
setup do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: honkster-acts_as_solr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mathias Meyer
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-06
|
12
|
+
date: 2009-11-06 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -179,8 +179,10 @@ files:
|
|
179
179
|
- test/unit/parser_methods_shoulda.rb
|
180
180
|
- test/unit/solr_instance.rb
|
181
181
|
- test/unit/test_helper.rb
|
182
|
-
has_rdoc:
|
182
|
+
has_rdoc: true
|
183
183
|
homepage: http://github.com/mattmatt/acts_as_solr
|
184
|
+
licenses: []
|
185
|
+
|
184
186
|
post_install_message:
|
185
187
|
rdoc_options:
|
186
188
|
- --charset=UTF-8
|
@@ -201,41 +203,41 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
201
203
|
requirements: []
|
202
204
|
|
203
205
|
rubyforge_project:
|
204
|
-
rubygems_version: 1.
|
206
|
+
rubygems_version: 1.3.5
|
205
207
|
signing_key:
|
206
208
|
specification_version: 3
|
207
209
|
summary: "This plugin adds full text search capabilities and many other nifty features from Apache\xEF\xBF\xBDs Solr to any Rails model. I'm currently rearranging the test suite to include a real unit test suite, and adding a few features I need myself."
|
208
210
|
test_files:
|
209
|
-
- test/
|
210
|
-
- test/
|
211
|
-
- test/
|
212
|
-
- test/
|
213
|
-
- test/
|
214
|
-
- test/
|
215
|
-
- test/
|
216
|
-
- test/
|
217
|
-
- test/
|
218
|
-
- test/
|
211
|
+
- test/unit/class_methods_shoulda.rb
|
212
|
+
- test/unit/parser_instance.rb
|
213
|
+
- test/unit/acts_methods_shoulda.rb
|
214
|
+
- test/unit/lazy_document_shoulda.rb
|
215
|
+
- test/unit/solr_instance.rb
|
216
|
+
- test/unit/test_helper.rb
|
217
|
+
- test/unit/common_methods_shoulda.rb
|
218
|
+
- test/unit/instance_methods_shoulda.rb
|
219
|
+
- test/unit/parser_methods_shoulda.rb
|
220
|
+
- test/test_helper.rb
|
219
221
|
- test/functional/acts_as_solr_test.rb
|
220
222
|
- test/functional/association_indexing_test.rb
|
221
|
-
- test/functional/faceted_search_test.rb
|
222
223
|
- test/functional/multi_solr_search_test.rb
|
224
|
+
- test/functional/faceted_search_test.rb
|
225
|
+
- test/models/posting.rb
|
226
|
+
- test/models/movie.rb
|
223
227
|
- test/models/author.rb
|
224
|
-
- test/models/book.rb
|
225
|
-
- test/models/category.rb
|
226
228
|
- test/models/electronic.rb
|
227
|
-
- test/models/gadget.rb
|
228
|
-
- test/models/movie.rb
|
229
229
|
- test/models/novel.rb
|
230
|
+
- test/models/gadget.rb
|
230
231
|
- test/models/post.rb
|
231
|
-
- test/models/
|
232
|
-
- test/
|
233
|
-
- test/
|
234
|
-
- test/
|
235
|
-
- test/
|
236
|
-
- test/
|
237
|
-
- test/
|
238
|
-
- test/
|
239
|
-
- test/
|
240
|
-
- test/
|
241
|
-
- test/
|
232
|
+
- test/models/book.rb
|
233
|
+
- test/models/category.rb
|
234
|
+
- test/db/connections/mysql/connection.rb
|
235
|
+
- test/db/connections/sqlite/connection.rb
|
236
|
+
- test/db/migrate/006_create_postings.rb
|
237
|
+
- test/db/migrate/007_create_posts.rb
|
238
|
+
- test/db/migrate/008_create_gadgets.rb
|
239
|
+
- test/db/migrate/004_create_electronics.rb
|
240
|
+
- test/db/migrate/005_create_authors.rb
|
241
|
+
- test/db/migrate/002_create_movies.rb
|
242
|
+
- test/db/migrate/003_create_categories.rb
|
243
|
+
- test/db/migrate/001_create_books.rb
|