acts_as_ferret 0.4.8.1 → 0.4.8.2

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/README CHANGED
@@ -19,9 +19,13 @@ http://github.com/jkraemer/acts_as_ferret/tree/master .
19
19
 
20
20
  === Set up your Rails > 2.1 project to use the acts_as_ferret gem.
21
21
 
22
- Add this to your project's config/environment.rb:
22
+ Add this to your project's config/environment.rb (inside the Rails::Initializer.run block):
23
23
 
24
- <tt>config.gem 'acts_as_ferret', :version => '~> 0.4.8'</tt>
24
+ <tt>
25
+ config.gem 'acts_as_ferret', :version => '~> 0.4.8'
26
+ config.after_initialize { ActsAsFerret::load_config }
27
+ config.to_prepare { ActsAsFerret::load_config }
28
+ </tt>
25
29
 
26
30
  With the gem installed, change into your RAILS_ROOT and run the supplied aaf_install script.
27
31
  This will copy rake tasks, capistrano recipes and the ferret server config and startup script
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'acts_as_ferret'
4
- s.version = '0.4.8.1'
4
+ s.version = '0.4.8.2'
5
5
  s.authors = ['Jens Kraemer']
6
6
  s.summary = 'acts_as_ferret - Ferret based full text search for any ActiveRecord model'
7
7
  s.description = 'Rails plugin that adds powerful full text search capabilities to ActiveRecord models.'
@@ -23,12 +23,12 @@ Gem::Specification.new do |s|
23
23
  s.specification_version = 3
24
24
 
25
25
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
26
- s.add_runtime_dependency('ferret', [">= 0.11.6"])
26
+ s.add_runtime_dependency('jk-ferret', [">= 0.11.8"])
27
27
  else
28
- s.add_dependency('ferret', [">= 0.11.6"])
28
+ s.add_dependency('jk-ferret', [">= 0.11.8"])
29
29
  end
30
30
  else
31
- s.add_dependency('ferret', [">= 0.11.6"])
31
+ s.add_dependency('jk-ferret', [">= 0.11.8"])
32
32
  end
33
33
 
34
34
 
@@ -456,6 +456,8 @@ module ActsAsFerret
456
456
  # get objects for each model
457
457
  id_arrays.each do |model, id_array|
458
458
  next if id_array.empty?
459
+ # logger.debug "id array from index: #{id_array.inspect}"
460
+
459
461
  model_class = model.constantize
460
462
 
461
463
  # merge conditions
@@ -484,7 +486,9 @@ module ActsAsFerret
484
486
 
485
487
  # order results as they were found by ferret, unless an AR :order
486
488
  # option was given
489
+ # logger.debug "unsorted result: #{result.map{|a| "#{a.id} / #{a.title} / #{a.ferret_rank}"}.inspect}"
487
490
  result.sort! { |a, b| a.ferret_rank <=> b.ferret_rank } unless find_options[:order]
491
+ # logger.debug "sorted result: #{result.map{|a| "#{a.id} / #{a.ferret_rank}"}.inspect}"
488
492
  return result
489
493
  end
490
494
 
@@ -94,6 +94,20 @@ module Ferret
94
94
  flush()
95
95
  end
96
96
  end
97
+
98
+ # search for the first document with +arg+ in the +id+ field and return it's internal document number.
99
+ # The +id+ field is either :id or whatever you set
100
+ # :id_field parameter to when you create the Index object.
101
+ def doc_number(id)
102
+ @dir.synchronize do
103
+ ensure_reader_open()
104
+ term_doc_enum = @reader.term_docs_for(@id_field, id.to_s)
105
+ return term_doc_enum.next? ? term_doc_enum.doc : nil
106
+ end
107
+ end
108
+
109
+ private
110
+
97
111
 
98
112
  # If +docs+ is a Hash or an Array then a batch delete will be performed.
99
113
  # If +docs+ is an Array then it will be considered an array of +id+'s. If
@@ -134,17 +148,7 @@ module Ferret
134
148
  end
135
149
  return self
136
150
  end
137
-
138
- # search for the first document with +arg+ in the +id+ field and return it's internal document number.
139
- # The +id+ field is either :id or whatever you set
140
- # :id_field parameter to when you create the Index object.
141
- def doc_number(id)
142
- @dir.synchronize do
143
- ensure_reader_open()
144
- term_doc_enum = @reader.term_docs_for(@id_field, id.to_s)
145
- return term_doc_enum.next? ? term_doc_enum.doc : nil
146
- end
147
- end
151
+
148
152
  end
149
153
 
150
154
  # add marshalling support to SortFields
@@ -175,7 +179,7 @@ module Ferret
175
179
  # we exclude the last <DOC> sorting as it is appended by new anyway
176
180
  if string =~ /^Sort\[(.*?)(<DOC>(!)?)?\]$/
177
181
  sort_fields = $1.split(',').map do |value|
178
- value.strip!
182
+ value.strip!
179
183
  Ferret::Search::SortField._load value unless value.blank?
180
184
  end
181
185
  new sort_fields.compact
data/lib/local_index.rb CHANGED
@@ -73,9 +73,6 @@ module ActsAsFerret
73
73
  reader.tokenized_fields unless options[:tokenized_fields]
74
74
  return qp.parse query
75
75
  else
76
- # work around ferret bug in #process_query (doesn't ensure the
77
- # reader is open)
78
- ferret_index.send(:ensure_reader_open)
79
76
  return ferret_index.process_query(query)
80
77
  end
81
78
  end
data/lib/rdig_adapter.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  begin
2
2
  require 'rdig'
3
3
  rescue LoadError
4
+ puts "RDig gem not found, searching and indexing static pages won't work."
4
5
  end
5
6
  require 'digest/md5'
6
7
 
@@ -46,13 +46,15 @@ namespace :ferret do
46
46
  desc "Stop the Ferret DRb server"
47
47
  task :stop, :roles => :app do
48
48
  rails_env = fetch(:rails_env, 'production')
49
- run "cd #{current_path}; script/ferret_server -e #{rails_env} stop || true"
49
+ ruby = fetch(:ruby, '/usr/bin/env ruby')
50
+ run "cd #{current_path}; #{ruby} script/ferret_server -e #{rails_env} stop || true"
50
51
  end
51
52
 
52
53
  desc "Start the Ferret DRb server"
53
54
  task :start, :roles => :app do
54
55
  rails_env = fetch(:rails_env, 'production')
55
- run "cd #{current_path}; script/ferret_server -e #{rails_env} start"
56
+ ruby = fetch(:ruby, '/usr/bin/env ruby')
57
+ run "cd #{current_path}; #{ruby} script/ferret_server -e #{rails_env} start"
56
58
  end
57
59
 
58
60
  desc "Restart the Ferret DRb server"
metadata CHANGED
@@ -1,14 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_ferret
3
3
  version: !ruby/object:Gem::Version
4
- hash: 77
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 4
9
- - 8
10
- - 1
11
- version: 0.4.8.1
4
+ version: 0.4.8.2
12
5
  platform: ruby
13
6
  authors:
14
7
  - Jens Kraemer
@@ -16,25 +9,19 @@ autorequire:
16
9
  bindir: bin
17
10
  cert_chain: []
18
11
 
19
- date: 2010-09-14 00:00:00 +02:00
12
+ date: 2010-10-26 00:00:00 +02:00
20
13
  default_executable: aaf_install
21
14
  dependencies:
22
15
  - !ruby/object:Gem::Dependency
23
- name: ferret
24
- prerelease: false
25
- requirement: &id001 !ruby/object:Gem::Requirement
26
- none: false
16
+ name: jk-ferret
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
27
20
  requirements:
28
21
  - - ">="
29
22
  - !ruby/object:Gem::Version
30
- hash: 63
31
- segments:
32
- - 0
33
- - 11
34
- - 6
35
- version: 0.11.6
36
- type: :runtime
37
- version_requirements: *id001
23
+ version: 0.11.8
24
+ version:
38
25
  description: Rails plugin that adds powerful full text search capabilities to ActiveRecord models.
39
26
  email: jk@jkraemer.net
40
27
  executables:
@@ -216,29 +203,21 @@ rdoc_options:
216
203
  require_paths:
217
204
  - lib
218
205
  required_ruby_version: !ruby/object:Gem::Requirement
219
- none: false
220
206
  requirements:
221
207
  - - ">="
222
208
  - !ruby/object:Gem::Version
223
- hash: 59
224
- segments:
225
- - 1
226
- - 8
227
- - 6
228
209
  version: 1.8.6
210
+ version:
229
211
  required_rubygems_version: !ruby/object:Gem::Requirement
230
- none: false
231
212
  requirements:
232
213
  - - ">="
233
214
  - !ruby/object:Gem::Version
234
- hash: 3
235
- segments:
236
- - 0
237
215
  version: "0"
216
+ version:
238
217
  requirements: []
239
218
 
240
219
  rubyforge_project: acts_as_ferret
241
- rubygems_version: 1.3.7
220
+ rubygems_version: 1.3.5
242
221
  signing_key:
243
222
  specification_version: 3
244
223
  summary: acts_as_ferret - Ferret based full text search for any ActiveRecord model