]> git.cworth.org Git - sup/blobdiff - lib/sup/mbox/ssh-loader.rb
labels now fully determined by sources.yaml, and lots of improvements to sup-config
[sup] / lib / sup / mbox / ssh-loader.rb
index 42a2b98cf3c62a24cddf83f12ab7f99769950033..bea585e87e08adf6263fe8e0261311b28076c0e8 100644 (file)
@@ -7,9 +7,9 @@ class SSHLoader < Source
   attr_accessor :username, :password
 
   yaml_properties :uri, :username, :password, :cur_offset, :usual, 
-                  :archived, :id
+                  :archived, :id, :labels
 
-  def initialize uri, username=nil, password=nil, start_offset=nil, usual=true, archived=false, id=nil
+  def initialize uri, username=nil, password=nil, start_offset=nil, usual=true, archived=false, id=nil, labels=[]
     raise ArgumentError, "not an mbox+ssh uri: #{uri.inspect}" unless uri =~ %r!^mbox\+ssh://!
 
     super uri, start_offset, usual, archived, id
@@ -19,6 +19,7 @@ class SSHLoader < Source
     @password = password
     @uri = uri
     @cur_offset = start_offset
+    @labels = (labels || []).freeze
 
     opts = {}
     opts[:username] = @username if @username
@@ -29,10 +30,10 @@ class SSHLoader < Source
     
     ## heuristic: use the filename as a label, unless the file
     ## has a path that probably represents an inbox.
-    @labels = [:unread]
-    @labels << File.basename(filename).intern unless File.dirname(filename) =~ /\b(var|usr|spool)\b/
   end
 
+  def self.suggest_labels_for path; Loader.suggest_labels_for(path) end
+
   def connect; safely { @f.connect }; end
   def host; @parsed_uri.host; end
   def filename; @parsed_uri.path[1..-1] end