lib/sup.rb in sup-0.0.7 vs lib/sup.rb in sup-0.0.8
- old
+ new
@@ -11,11 +11,11 @@
raise "wrong id called on #{self.inspect}"
end
end
module Redwood
- VERSION = "0.0.7"
+ VERSION = "0.0.8"
BASE_DIR = ENV["SUP_BASE"] || 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")
@@ -91,24 +91,67 @@
def finish
Redwood::LabelManager.save
Redwood::ContactManager.save
Redwood::PersonManager.save
+ Redwood::BufferManager.deinstantiate!
end
- module_function :register_yaml, :save_yaml_obj, :load_yaml_obj, :start, :finish
+ ## not really a good place for this, so I'll just dump it here.
+ def report_broken_sources opts={}
+ return unless BufferManager.instantiated?
+
+ broken_sources = Index.usual_sources.select { |s| s.error.is_a? FatalSourceError }
+ unless broken_sources.empty?
+ BufferManager.spawn "Broken source notification", TextMode.new(<<EOM), opts
+Source error notification
+-------------------------
+
+Hi there. It looks like one or more message sources is reporting
+errors. Until this is corrected, messages from these sources cannot
+be viewed, and new messages will not be detected.
+
+#{broken_sources.map { |s| "Source: " + s.to_s + "\n Error: " + s.error.message.wrap(70).join("\n ")}.join('\n\n')}
+EOM
+#' stupid ruby-mode
+ end
+
+ desynced_sources = Index.usual_sources.select { |s| s.error.is_a? OutOfSyncSourceError }
+ unless desynced_sources.empty?
+ BufferManager.spawn "Out-of-sync source notification", TextMode.new(<<EOM), opts
+Out-of-sync source notification
+-------------------------------
+
+Hi there. It looks like one or more sources has fallen out of sync
+with my index. This can happen when you modify these sources with
+other email clients. (Sorry, I don't play well with others.)
+
+Until this is corrected, messages from these sources cannot be viewed,
+and new messages will not be detected. Luckily, this is easy to correct!
+
+#{desynced_sources.map do |s|
+ "Source: " + s.to_s +
+ "\n Error: " + s.error.message.wrap(70).join("\n ") +
+ "\n Fix: sup-sync --changed #{s.to_s}"
+ end}
+EOM
+#' stupid ruby-mode
+ end
+ end
+
+ module_function :register_yaml, :save_yaml_obj, :load_yaml_obj, :start, :finish, :report_broken_sources
end
## set up default configuration file
if File.exists? Redwood::CONFIG_FN
$config = Redwood::load_yaml_obj Redwood::CONFIG_FN
else
$config = {
:accounts => {
:default => {
- :name => "Your Name Here",
- :email => "your.email.here@domain.tld",
+ :name => "Sup Rocks",
+ :email => "sup-rocks@reading-my-emails",
:alternates => [],
:sendmail => "/usr/sbin/sendmail -oem -ti",
:signature => File.join(ENV["HOME"], ".signature")
}
},
@@ -125,9 +168,10 @@
require "sup/util"
require "sup/update"
require "sup/message"
require "sup/source"
require "sup/mbox"
+require "sup/maildir"
require "sup/imap"
require "sup/person"
require "sup/account"
require "sup/thread"
require "sup/index"