## 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
@ids = []
@last_scan = nil
@labels = [:unread]
- @labels << :inbox unless archived?
@labels << mailbox.intern unless mailbox =~ /inbox/i
@mutex = Mutex.new
end
start.upto(ids.length - 1) do |i|
id = ids[i]
self.cur_offset = id
- yield id, labels
+ yield id, @labels.clone
end
end
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
end
self.cur_offset = next_offset
- [returned_offset, labels]
+ [returned_offset, @labels.clone]
end
end
## 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
## 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
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
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