Changeset 312
- Timestamp:
- 02/02/08 21:36:54 (8 months ago)
- Files:
-
- trunk/plugin/acts_as_ferret/lib/acts_as_ferret.rb (modified) (1 diff)
- trunk/plugin/acts_as_ferret/lib/blank_slate.rb (added)
- trunk/plugin/acts_as_ferret/lib/ferret_result.rb (modified) (1 diff)
- trunk/plugin/acts_as_ferret/lib/search_results.rb (modified) (1 diff)
- trunk/plugin/acts_as_ferret/recipes/aaf_recipes.rb (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/plugin/acts_as_ferret/lib/acts_as_ferret.rb
r307 r312 25 25 require 'ferret' 26 26 27 require 'blank_slate' 27 28 require 'bulk_indexer' 28 29 require 'ferret_extensions' trunk/plugin/acts_as_ferret/lib/ferret_result.rb
r310 r312 10 10 end 11 11 12 class FerretResult < BlankSlate12 class FerretResult < ActsAsFerret::BlankSlate 13 13 include ResultAttributes 14 14 attr_accessor :id trunk/plugin/acts_as_ferret/lib/search_results.rb
r310 r312 3 3 # decorator that adds a total_hits accessor and will_paginate compatible 4 4 # paging support to search result arrays 5 class SearchResults < BlankSlate5 class SearchResults < ActsAsFerret::BlankSlate 6 6 reveal :methods 7 7 attr_reader :current_page, :per_page, :total_hits trunk/plugin/acts_as_ferret/recipes/aaf_recipes.rb
r309 r312 14 14 # into current/ when you deploy. 15 15 # 16 # In order to use the ferret: rebuild task, declare the models you intend to16 # In order to use the ferret:index:rebuild task, declare the models you intend to 17 17 # index in config/deploy.rb: 18 18 # … … 26 26 # 27 27 # The two methods may be combined if you have a shared index, and some models 28 # indexed separately. 28 # indexed separately. 29 # 30 # Like to submit a patch to aaf? Automatically determining the models that use 31 # acts_as_ferret so the declaration of these variables in deploy.rb isn't 32 # necessary anymore would be really cool ;-) 29 33 30 34 namespace :ferret do … … 42 46 desc "Restart the Ferret DRb server" 43 47 task :restart, :roles => :app do 44 run "cd #{current_path}; script/ferret_server -e #{rails_env} stop; sleep 1; script/ferret_server -e #{rails_env} start" 48 top.ferret.stop 49 sleep 1 50 top.ferret.start 45 51 end 46 52 47 desc "Rebuild the Ferret index" 48 task :rebuild, :roles => :app do 49 rake = fetch(:rake, 'rake') 50 single_index_models = fetch(:ferret_single_index_models, nil) 51 if single_index_models 52 run "cd #{current_path}; RAILS_ENV=#{rails_env} MODEL='#{ferret_single_index_models.join(' ')}' #{rake} ferret:rebuild" 53 namespace :index do 54 55 desc "Rebuild the Ferret index. See aaf_recipes.rb for instructions." 56 task :rebuild, :roles => :app do 57 rake = fetch(:rake, 'rake') 58 single_index_models = fetch(:ferret_single_index_models, nil) 59 if single_index_models 60 run "cd #{current_path}; RAILS_ENV=#{rails_env} MODEL='#{ferret_single_index_models.join(' ')}' #{rake} ferret:rebuild" 61 end 62 fetch(:ferret_models, []).each do |m| 63 run "cd #{current_path}; RAILS_ENV=#{rails_env} MODEL='#{m}' #{rake} ferret:rebuild" 64 end 53 65 end 54 fetch(:ferret_models, []).each do |m| 55 run "cd #{current_path}; RAILS_ENV=#{rails_env} MODEL='#{m}' #{rake} ferret:rebuild" 66 67 desc "purges all indexes for the current environment" 68 task :purge, :roles => :app do 69 run "rm -fr #{shared_path}/index/#{rails_env}" 56 70 end 57 end58 71 59 desc "symlinks index folder" 60 task :symlink_index, :roles => :app do 61 run "mkdir -p #{shared_path}/index && rm -f #{current_path}/index && ln -s #{shared_path}/index #{current_path}/index" 72 desc "symlinks index folder" 73 task :symlink, :roles => :app do 74 run "mkdir -p #{shared_path}/index && rm -rf #{release_path}/index && ln -s #{shared_path}/index #{release_path}/index" 75 end 76 62 77 end 63 78 … … 67 82 after "deploy:start", "ferret:start" 68 83 after "deploy:restart", "ferret:restart" 69 after "deploy:symlink", "ferret: symlink_index"84 after "deploy:symlink", "ferret:index:symlink" 70 85
