diff options
author | Seb Bacon <seb.bacon@gmail.com> | 2012-01-06 09:54:22 +0000 |
---|---|---|
committer | Seb Bacon <seb.bacon@gmail.com> | 2012-01-06 09:54:22 +0000 |
commit | 8d7885217fdf4bf5061233679fbb42970cab1c3c (patch) | |
tree | b5ecab1ba69fe520023883a067507893ecd2cf92 | |
parent | f413c7bfb232db038dcb1265fda1bf5dabb9b4f8 (diff) |
Consistently parse arguments to xapain:rebuild_index
-rw-r--r-- | vendor/plugins/acts_as_xapian/lib/tasks/xapian.rake | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/vendor/plugins/acts_as_xapian/lib/tasks/xapian.rake b/vendor/plugins/acts_as_xapian/lib/tasks/xapian.rake index d18cd07d5..649d0c0d4 100644 --- a/vendor/plugins/acts_as_xapian/lib/tasks/xapian.rake +++ b/vendor/plugins/acts_as_xapian/lib/tasks/xapian.rake @@ -30,12 +30,23 @@ namespace :xapian do desc 'Completely rebuilds Xapian search index (must specify all models)' task :rebuild_index => :environment do + def coerce_arg(arg, default) + if arg == "false" + return false + elsif arg == "true" + return true + elsif arg.nil? + return default + else + return arg + end + end raise "specify ALL your models with models=\"ModelName1 ModelName2\" as parameter" if ENV['models'].nil? ActsAsXapian.rebuild_index(ENV['models'].split(" ").map{|m| m.constantize}, - ENV['verbose'] ? true : false, - ENV['terms'] == "false" ? false : ENV['terms'], - ENV['values'] == "false" ? false : ENV['values'], - ENV['texts'] == "false" ? false : true) + coerce_arg(ENV['verbose'], false), + coerce_arg(ENV['terms'], true), + coerce_arg(ENV['values'], true), + coerce_arg(ENV['textx'], true)) end # Parameters - are models, query, offset, limit, sort_by_prefix, |