]> git.cworth.org Git - sup/blobdiff - lib/sup/hook.rb
rewrite Singleton to not require i_am_the_instance
[sup] / lib / sup / hook.rb
index 74ecfabefc6e69da993b203bbe2e4f717299ce38..a492a07858abbd444916e88b5f39f35867f5e5fd 100644 (file)
@@ -52,6 +52,14 @@ class HookManager
       end
     end
 
+    def get tag
+      HookManager.tags[tag]
+    end
+
+    def set tag, value
+      HookManager.tags[tag] = value
+    end
+
     def __binding 
       binding
     end
@@ -68,12 +76,13 @@ class HookManager
     @hooks = {}
     @descs = {}
     @contexts = {}
-    
-    Dir.mkdir dir unless File.exists? dir
+    @tags = {}
 
-    self.class.i_am_the_instance self
+    Dir.mkdir dir unless File.exists? dir
   end
 
+  attr_reader :tags
+
   def run name, locals={}
     hook = hook_for(name) or return
     context = @contexts[hook] ||= HookContext.new(name)
@@ -120,7 +129,7 @@ private
     unless @hooks.member? name
       @hooks[name] =
         begin
-          returning IO.readlines(fn_for(name)).join do
+          returning IO.read(fn_for(name)) do
             log "read '#{name}' from #{fn_for(name)}"
           end
         rescue SystemCallError => e