]> git.cworth.org Git - sup/blobdiff - lib/sup.rb
Merge commit 'origin/ncurses-widechar'
[sup] / lib / sup.rb
index afd030fc017698077c7a32ef2dfae72a2f622d59..93369a5f62e01933491cd4aaa352013d673fd7ef 100644 (file)
@@ -46,10 +46,11 @@ class Module
 end
 
 module Redwood
-  VERSION = "0.5"
+  VERSION = "git"
 
   BASE_DIR   = ENV["SUP_BASE"] || File.join(ENV["HOME"], ".sup")
   CONFIG_FN  = File.join(BASE_DIR, "config.yaml")
+  COLOR_FN   = File.join(BASE_DIR, "colors.yaml")
   SOURCE_FN  = File.join(BASE_DIR, "sources.yaml")
   LABEL_FN   = File.join(BASE_DIR, "labels.txt")
   PERSON_FN  = File.join(BASE_DIR, "people.txt")
@@ -63,7 +64,18 @@ module Redwood
   YAML_DOMAIN = "masanjin.net"
   YAML_DATE = "2006-10-01"
 
-## record exceptions thrown in threads nicely
+  ## record exceptions thrown in threads nicely
+  @exceptions = []
+  @exception_mutex = Mutex.new
+
+  attr_reader :exceptions
+  def record_exception e, name
+    @exception_mutex.synchronize do
+      @exceptions ||= []
+      @exceptions << [e, name]
+    end
+  end
+
   def reporting_thread name
     if $opts[:no_threads]
       yield
@@ -72,14 +84,13 @@ module Redwood
         begin
           yield
         rescue Exception => e
-          $exceptions ||= []
-          $exceptions << [e, name]
-          raise
+          record_exception e, name
         end
       end
     end
   end
-  module_function :reporting_thread
+
+  module_function :reporting_thread, :record_exception, :exceptions
 
 ## one-stop shop for yamliciousness
   def save_yaml_obj object, fn, safe=false