From 54a3a227a59f1d914fb2fa668b4fd39a5d8dd34d Mon Sep 17 00:00:00 2001 From: Rich Lane Date: Sat, 20 Jun 2009 13:50:13 -0700 Subject: [PATCH] index: choose index implementation with config entry or environment variable --- lib/sup.rb | 2 ++ lib/sup/index.rb | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/sup.rb b/lib/sup.rb index 5689c2b..54de73f 100644 --- a/lib/sup.rb +++ b/lib/sup.rb @@ -54,6 +54,8 @@ module Redwood YAML_DOMAIN = "masanjin.net" YAML_DATE = "2006-10-01" + DEFAULT_INDEX = 'ferret' + ## record exceptions thrown in threads nicely @exceptions = [] @exception_mutex = Mutex.new diff --git a/lib/sup/index.rb b/lib/sup/index.rb index 13b0cc7..9ec0488 100644 --- a/lib/sup/index.rb +++ b/lib/sup/index.rb @@ -212,7 +212,13 @@ EOS end end +index_name = ENV['SUP_INDEX'] || $config[:index] || DEFAULT_INDEX +begin + require "sup/#{index_name}_index" +rescue LoadError + fail "invalid index name #{index_name.inspect}" end +Index = Redwood.const_get "#{index_name.capitalize}Index" +Redwood::log "using index #{Index.name}" -require 'lib/sup/ferret_index' -Redwood::Index = Redwood::FerretIndex +end -- 2.45.2