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 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
- #s.name = "honkster-acts_as_solr"
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
@@ -1,4 +1,5 @@
1
1
  ---
2
- :patch: 4
2
+ :build:
3
3
  :major: 0
4
4
  :minor: 3
5
+ :patch: 6
@@ -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
- begin
290
- value = self[field_name] || self.instance_variable_get("@#{field_name.to_s}".to_sym) || self.send(field_name.to_sym)
291
- case options[:type]
292
- # format dates properly; return nil for nil dates
293
- when :date
294
- value ? (value.respond_to?(:utc) ? value.utc : value).strftime("%Y-%m-%dT%H:%M:%SZ") : nil
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)
@@ -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
- response = @connection.post(@url.path + "/" + request.handler,
157
- request.to_s,
158
- { "Content-Type" => request.content_type })
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
@@ -15,5 +15,5 @@ class ActsAsSolr::ParserInstance
15
15
  []
16
16
  end
17
17
 
18
- public :parse_results, :reorder, :parse_query, :add_scores, :replace_types, :quote_values_with_spaces
18
+ public :parse_results, :reorder, :parse_query, :add_scores, :replace_types
19
19
  end
@@ -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
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-02 00:00:00 -07:00
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: false
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.2.0
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/db/connections/mysql/connection.rb
210
- - test/db/connections/sqlite/connection.rb
211
- - test/db/migrate/001_create_books.rb
212
- - test/db/migrate/002_create_movies.rb
213
- - test/db/migrate/003_create_categories.rb
214
- - test/db/migrate/004_create_electronics.rb
215
- - test/db/migrate/005_create_authors.rb
216
- - test/db/migrate/006_create_postings.rb
217
- - test/db/migrate/007_create_posts.rb
218
- - test/db/migrate/008_create_gadgets.rb
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/posting.rb
232
- - test/test_helper.rb
233
- - test/unit/acts_methods_shoulda.rb
234
- - test/unit/class_methods_shoulda.rb
235
- - test/unit/common_methods_shoulda.rb
236
- - test/unit/instance_methods_shoulda.rb
237
- - test/unit/lazy_document_shoulda.rb
238
- - test/unit/parser_instance.rb
239
- - test/unit/parser_methods_shoulda.rb
240
- - test/unit/solr_instance.rb
241
- - test/unit/test_helper.rb
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