commit 50bd9970e75abbf7a37d5569cc77e30344d8b4c3
parent 5127833d2b9511cc185227b12f27d37b31c87886
Author: Whyme Lyu <callme5long@gmail.com>
Date: Sun, 19 May 2013 22:40:37 +0800
Make sup/index require-able on its own
Diffstat:
5 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/lib/sup.rb b/lib/sup.rb
@@ -309,9 +309,7 @@ require "sup/hook"
require "sup/time"
## everything we need to get logging working
-require "sup/logger"
-Redwood::Logger.init.add_sink $stderr
-include Redwood::LogsStuff
+require "sup/logger/singleton"
## determine encoding and character set
$encoding = Locale.current.charset
diff --git a/lib/sup/hook.rb b/lib/sup/hook.rb
@@ -1,3 +1,5 @@
+require "sup/util"
+
module Redwood
class HookManager
diff --git a/lib/sup/index.rb b/lib/sup/index.rb
@@ -6,6 +6,11 @@ require 'fileutils'
require 'monitor'
require 'chronic'
+require "sup/interactive_lock"
+require "sup/hook"
+require "sup/logger/singleton"
+
+
if ([Xapian.major_version, Xapian.minor_version, Xapian.revision] <=> [1,2,1]) < 0
fail "Xapian version 1.2.1 or higher required"
end
diff --git a/lib/sup/logger.rb b/lib/sup/logger.rb
@@ -1,4 +1,4 @@
-require "sup"
+require "sup/util"
require 'stringio'
require 'thread'
diff --git a/lib/sup/logger/singleton.rb b/lib/sup/logger/singleton.rb
@@ -0,0 +1,10 @@
+# TODO: this is ugly. It's better to have a application singleton passed
+# down to lower level components instead of including logging methods in
+# class `Object'
+#
+# For now this is what we have to do.
+require "sup/logger"
+Redwood::Logger.init.add_sink $stderr
+class Object
+ include Redwood::LogsStuff
+end