sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 9ae66dc7cca5f99473a477eea7af0fc89003e6ef
parent bbf48f75edf47b18da8fd71b3834fcef1d59d941
Author: Whyme Lyu <callme5long@gmail.com>
Date:   Tue, 28 May 2013 23:50:19 +0800

Remove dead & deprecated code

Diffstat:
M lib/sup.rb | 10 +++-------
M lib/sup/draft.rb | 7 +++++--
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/lib/sup.rb b/lib/sup.rb
@@ -23,12 +23,9 @@ class Module
   def yaml_properties *props
     props = props.map { |p| p.to_s }
 
-    def self.to_yaml_tag
-      path = name.gsub(/::/, "/")
-      "!#{Redwood::YAML_DOMAIN},#{Redwood::YAML_DATE}/#{path}"
-    end
+    path = name.gsub(/::/, "/")
+    yaml_tag "!#{Redwood::YAML_DOMAIN},#{Redwood::YAML_DATE}/#{path}"
 
-    define_method(:to_yaml_type) { self.class.to_yaml_tag }
     define_method :init_with do |coder|
       initialize(*coder.map.values_at(*props))
     end
@@ -40,8 +37,7 @@ class Module
       end
     end
 
-    yaml_tag to_yaml_tag
-    path = name.gsub(/::/, "/")
+    # Legacy
     Psych.load_tags["!#{Redwood::LEGACY_YAML_DOMAIN},#{Redwood::YAML_DATE}/#{path}"] = self
   end
 end
diff --git a/lib/sup/draft.rb b/lib/sup/draft.rb
@@ -32,14 +32,17 @@ class DraftLoader < Source
   attr_accessor :dir
   yaml_properties
 
-  def initialize
-    dir = Redwood::DRAFT_DIR
+  def initialize dir=Redwood::DRAFT_DIR
     Dir.mkdir dir unless File.exists? dir
     super DraftManager.source_name, true, false
     @dir = dir
     @cur_offset = 0
   end
 
+  def properly_initialized?
+    !!(@dir && @cur_offset)
+  end
+
   def id; DraftManager.source_id; end
   def to_s; DraftManager.source_name; end
   def uri; DraftManager.source_name; end