]> git.cworth.org Git - sup/commitdiff
moved responsibility for archived? to source
authorwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Wed, 21 Feb 2007 00:13:16 +0000 (00:13 +0000)
committerwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Wed, 21 Feb 2007 00:13:16 +0000 (00:13 +0000)
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@335 5c8cc53c-5e98-4d25-b20a-d8db53a31250

lib/sup/imap.rb
lib/sup/mbox/loader.rb
lib/sup/mbox/ssh-loader.rb
lib/sup/source.rb
lib/sup/util.rb

index b3c4b2c27f8a535c78168e223bc5bd846ae47955..92c0b5c6bebe086d7a1d1aeb10d5a765e67d9b7b 100644 (file)
@@ -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
 
index 2f69dbf690c9a34b2bbbd0e3979cb3881699ce34..1d53a8b0405575619a6068ffcb94f3bc08cc1fdb 100644 (file)
@@ -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
 
index a3a8964479a98e87546e9487e6b9af61b5829085..4ea10d890d58b942319dae12b7a1e9d15b0cc9ef 100644 (file)
@@ -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
 
index d3f96e179126a2a1e6f988bee5492e0b1e0dfe63..02f661a406c19f6ae842f7653270da58f8154e09 100644 (file)
@@ -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
index dfe60acd8c490283d6f9ddf6e77f7962cf871f58..c9ac70c2473fd706158db21704f3fc7bd594cde5 100644 (file)
@@ -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