commit e74bea852447b623f30dadbdbe30f1f032a7e64e
parent 8bb5c8aa76eb6440f4ffb5eee67a12411ea7c691
Author: wmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Date: Wed, 21 Feb 2007 00:13:16 +0000
moved responsibility for archived? to source
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@335 5c8cc53c-5e98-4d25-b20a-d8db53a31250
Diffstat:
5 files changed, 3 insertions(+), 14 deletions(-)
diff --git a/lib/sup/imap.rb b/lib/sup/imap.rb
@@ -35,7 +35,6 @@ class IMAP < Source
## upon these errors we'll try to rereconnect a few times
RECOVERABLE_ERRORS = [ Errno::EPIPE, Errno::ETIMEDOUT ]
- attr_reader_cloned :labels
attr_accessor :username, :password
def initialize uri, username, password, last_idate=nil, usual=true, archived=false, id=nil
@@ -52,7 +51,6 @@ class IMAP < Source
@ids = []
@last_scan = nil
@labels = [:unread]
- @labels << :inbox unless archived?
@labels << mailbox.intern unless mailbox =~ /inbox/i
@mutex = Mutex.new
end
@@ -126,7 +124,7 @@ class IMAP < Source
start.upto(ids.length - 1) do |i|
id = ids[i]
self.cur_offset = id
- yield id, labels
+ yield id, @labels.clone
end
end
diff --git a/lib/sup/mbox/loader.rb b/lib/sup/mbox/loader.rb
@@ -4,14 +4,11 @@ module Redwood
module MBox
class Loader < Source
- attr_reader_cloned :labels
-
def initialize uri_or_fp, start_offset=nil, usual=true, archived=false, id=nil
super
@mutex = Mutex.new
@labels = [:unread]
- @labels << :inbox unless archived?
case uri_or_fp
when String
@@ -115,7 +112,7 @@ class Loader < Source
end
self.cur_offset = next_offset
- [returned_offset, labels]
+ [returned_offset, @labels.clone]
end
end
diff --git a/lib/sup/mbox/ssh-loader.rb b/lib/sup/mbox/ssh-loader.rb
@@ -8,7 +8,6 @@ module MBox
## those, reraise them as SourceErrors, and set ourselves as broken.
class SSHLoader < Source
- attr_reader_cloned :labels
attr_accessor :username, :password
def initialize uri, username=nil, password=nil, start_offset=nil, usual=true, archived=false, id=nil
@@ -32,7 +31,6 @@ class SSHLoader < Source
## heuristic: use the filename as a label, unless the file
## has a path that probably represents an inbox.
@labels = [:unread]
- @labels << :inbox unless archived?
@labels << File.basename(filename).intern unless File.dirname(filename) =~ /\b(var|usr|spool)\b/
end
diff --git a/lib/sup/source.rb b/lib/sup/source.rb
@@ -95,7 +95,7 @@ class Source
until done? || broken? # just like life!
n, labels = self.next
raise "no message" unless n
- yield n, labels
+ yield n, labels + (archived? ? [] : [:inbox])
end
rescue SourceError => e
self.broken_msg = e.message
diff --git a/lib/sup/util.rb b/lib/sup/util.rb
@@ -8,10 +8,6 @@ class Module
bool_writer(*args)
end
- def attr_reader_cloned *args
- args.each { |sym| class_eval %{ def #{sym}; @#{sym}.clone; end } }
- end
-
def defer_all_other_method_calls_to obj
class_eval %{ def method_missing meth, *a, &b; @#{obj}.send meth, *a, &b; end }
end