]> git.cworth.org Git - sup/commitdiff
twiddle expansion changes from Magnus Therning
authorwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Mon, 17 Sep 2007 17:30:44 +0000 (17:30 +0000)
committerwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Mon, 17 Sep 2007 17:30:44 +0000 (17:30 +0000)
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@584 5c8cc53c-5e98-4d25-b20a-d8db53a31250

lib/sup/maildir.rb
lib/sup/mbox/loader.rb
lib/sup/source.rb

index c754ccdf49aca1b1c1504a4b056f565b278b96b2..df1ee8c602c5e00b217f1deb2bc1417f3bb1301a 100644 (file)
@@ -14,9 +14,8 @@ class Maildir < Source
   ## remind me never to use inheritance again.
   yaml_properties :uri, :cur_offset, :usual, :archived, :id, :labels
   def initialize uri, last_date=nil, usual=true, archived=false, id=nil, labels=[]
-    uri = Source.expand_filesystem_uri uri
     super uri, last_date, usual, archived, id
-    uri = URI(uri)
+    uri = URI(Source.expand_filesystem_uri(uri))
 
     raise ArgumentError, "not a maildir URI" unless uri.scheme == "maildir"
     raise ArgumentError, "maildir URI cannot have a host: #{uri.host}" if uri.host
index b2162c078d04da00b449c07a3980e99554a4989c..9bad74e3ee527409d69ba757c2e18b6f2c6a2ce0 100644 (file)
@@ -14,20 +14,21 @@ class Loader < Source
 
     case uri_or_fp
     when String
-      uri_or_fp = Source.expand_filesystem_uri uri_or_fp
-      uri = URI(uri_or_fp)
+      uri = URI(Source.expand_filesystem_uri(uri_or_fp))
       raise ArgumentError, "not an mbox uri" unless uri.scheme == "mbox"
       raise ArgumentError, "mbox uri ('#{uri}') cannot have a host: #{uri.host}" if uri.host
       @f = File.open uri.path
+      @path = uri.path
     else
       @f = uri_or_fp
+      @path = uri_or_fp.path
     end
 
     super uri_or_fp, start_offset, usual, archived, id
   end
 
-  def file_path; URI(uri).path end
-  def is_source_for? uri; super || (URI(Source.expand_filesystem_uri(uri)) == URI(self.uri)); end
+  def file_path; @path end
+  def is_source_for? uri; super || (URI(Source.expand_filesystem_uri(uri)).path == @path); end
 
   def self.suggest_labels_for path
     ## heuristic: use the filename as a label, unless the file
index d21faf70eb5452ca33f9d1177d436df00a1886e4..d56f25a642f4889b212ccad8a2dca7c9861ef602 100644 (file)
@@ -78,7 +78,7 @@ class Source
   def reset!; seek_to! start_offset; end
   def == o; o.uri == uri; end
   def done?; start_offset.nil? || (self.cur_offset ||= start_offset) >= end_offset; end
-  def is_source_for? uri; uri == URI(uri); end
+  def is_source_for? uri; uri == @uri; end
 
   ## check should throw a FatalSourceError or an OutOfSyncSourcError
   ## if it can detect a problem. it is called when the sup starts up