]> git.cworth.org Git - sup/commitdiff
index: choose index implementation with config entry or environment variable
authorRich Lane <rlane@club.cc.cmu.edu>
Sat, 20 Jun 2009 20:50:13 +0000 (13:50 -0700)
committerWilliam Morgan <wmorgan-sup@masanjin.net>
Wed, 24 Jun 2009 13:44:48 +0000 (09:44 -0400)
lib/sup.rb
lib/sup/index.rb

index 5689c2b9fa0237385b8e3ef7814767a7dc48ab39..54de73f5597f1e2f752f07a00694d39de547880b 100644 (file)
@@ -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
index 13b0cc71e739fbe4171325b361fa26723a85c28a..9ec0488502faef01312b5580d94495b3ca60d114 100644 (file)
@@ -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