sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 54a3a227a59f1d914fb2fa668b4fd39a5d8dd34d
parent 9716c862c1e2cd37ffbcb6b63be576ebe6ed9779
Author: Rich Lane <rlane@club.cc.cmu.edu>
Date:   Sat, 20 Jun 2009 13:50:13 -0700

index: choose index implementation with config entry or environment variable

Diffstat:
M lib/sup.rb | 2 ++
M lib/sup/index.rb | 10 ++++++++--
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git 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
@@ -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