]> git.cworth.org Git - sup/blobdiff - lib/sup.rb
wrapped all imap errors so that they turn into source errors
[sup] / lib / sup.rb
index 819fae1b8feb446fbd690a6be64360857dda1384..c9a1cb4a485d56b302bcfe4fd6ac05be99213c4b 100644 (file)
@@ -3,23 +3,23 @@ require 'yaml'
 require 'zlib'
 require 'thread'
 require 'fileutils'
-Thread.abort_on_exception = true # make debugging possible
 
 class Object
-  ## this is for debugging purposes because i keep calling nil.id and
-  ## i want it to throw an exception
-  def id 
-    raise "wrong id called"
+  ## this is for debugging purposes because i keep calling #id on the
+  ## wrong object and i want it to throw an exception
+  def id
+    raise "wrong id called on #{self.inspect}"
   end
 end
 
 module Redwood
-  VERSION = "0.0.1"
+  VERSION = "0.0.2"
 
   BASE_DIR   = File.join(ENV["HOME"], ".sup")
   CONFIG_FN  = File.join(BASE_DIR, "config.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")
   CONTACT_FN = File.join(BASE_DIR, "contacts.txt")
   DRAFT_DIR  = File.join(BASE_DIR, "drafts")
   SENT_FN    = File.join(BASE_DIR, "sent.mbox")
@@ -28,7 +28,6 @@ module Redwood
   YAML_DATE = "2006-10-01"
 
 ## one-stop shop for yamliciousness
-
   def register_yaml klass, props
     vars = props.map { |p| "@#{p}" }
     path = klass.name.gsub(/::/, "/")
@@ -61,11 +60,27 @@ module Redwood
     end
   end
 
-  module_function :register_yaml, :save_yaml_obj, :load_yaml_obj
+  def start
+    Redwood::PersonManager.new Redwood::PERSON_FN
+    Redwood::SentManager.new Redwood::SENT_FN
+    Redwood::ContactManager.new Redwood::CONTACT_FN
+    Redwood::LabelManager.new Redwood::LABEL_FN
+    Redwood::AccountManager.new $config[:accounts]
+    Redwood::DraftManager.new Redwood::DRAFT_DIR
+    Redwood::UpdateManager.new
+    Redwood::PollManager.new
+  end
+
+  def finish
+    Redwood::LabelManager.save
+    Redwood::ContactManager.save
+    Redwood::PersonManager.save
+  end
+
+  module_function :register_yaml, :save_yaml_obj, :load_yaml_obj, :start, :finish
 end
 
 ## set up default configuration file
-
 if File.exists? Redwood::CONFIG_FN
   $config = Redwood::load_yaml_obj Redwood::CONFIG_FN
 else
@@ -92,7 +107,9 @@ end
 require "sup/util"
 require "sup/update"
 require "sup/message"
+require "sup/source"
 require "sup/mbox"
+require "sup/imap"
 require "sup/person"
 require "sup/account"
 require "sup/thread"