commit f6647b188d02b479b7b8806f4647922eb388e7ba
parent e2ddccac5e38efc91899d030853421a56dc76eca
Author: wmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Date: Sat, 24 Nov 2007 18:39:27 +0000
better source error reporting, and better message loading
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@715 5c8cc53c-5e98-4d25-b20a-d8db53a31250
Diffstat:
4 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/lib/sup.rb b/lib/sup.rb
@@ -124,8 +124,10 @@ module Redwood
return unless BufferManager.instantiated?
broken_sources = Index.usual_sources.select { |s| s.error.is_a? FatalSourceError }
+ File.open("goat", "w") { |f| f.puts Kernel.caller }
unless broken_sources.empty?
- BufferManager.spawn "Broken source notification", TextMode.new(<<EOM), opts
+ BufferManager.spawn_unless_exists("Broken source notification for #{broken_sources.join(',')}", opts) do
+ TextMode.new(<<EOM)
Source error notification
-------------------------
@@ -136,11 +138,13 @@ 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
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
+ BufferManager.spawn_unless_exists("Out-of-sync source notification for #{broken_sources.join(',')}", opts) do
+ TextMode.new(<<EOM)
Out-of-sync source notification
-------------------------------
@@ -158,6 +162,7 @@ and new messages will not be detected. Luckily, this is easy to correct!
end}
EOM
#' stupid ruby-mode
+ end
end
end
diff --git a/lib/sup/modes/thread-index-mode.rb b/lib/sup/modes/thread-index-mode.rb
@@ -83,10 +83,11 @@ EOS
## TODO: don't regen text completely
Redwood::reporting_thread do
num = t.size
- BufferManager.say("Loading message bodies...") do |sid|
+ message = "Loading #{num.pluralize 'message body'}..."
+ BufferManager.say(message) do |sid|
t.each_with_index do |(m, *o), i|
next unless m
- BufferManager.say "Loading message bodies... (#{i + 1}/#{num})", sid if t.size > 1
+ BufferManager.say "#{message} (#{i}/#{num})", sid if t.size > 1
m.load_from_source!
end
end
diff --git a/lib/sup/poll.rb b/lib/sup/poll.rb
@@ -87,7 +87,7 @@ EOS
yield "Loading from #{source}... " unless source.done? || source.has_errors?
rescue SourceError => e
Redwood::log "problem getting messages from #{source}: #{e.message}"
- Redwood::report_broken_sources
+ Redwood::report_broken_sources :force_to_top => true
next
end
@@ -163,7 +163,7 @@ EOS
end
rescue SourceError => e
Redwood::log "problem getting messages from #{source}: #{e.message}"
- Redwood::report_broken_sources
+ Redwood::report_broken_sources :force_to_top => true
end
end
end
diff --git a/lib/sup/util.rb b/lib/sup/util.rb
@@ -310,8 +310,18 @@ class Fixnum
end
end
+ ## hacking the english language
def pluralize s
- to_s + " " + (self == 1 ? s : s + "s")
+ to_s + " " +
+ if self == 1
+ s
+ else
+ if s =~ /(.*)y$/
+ $1 + "ies"
+ else
+ s + "s"
+ end
+ end
end
end