lib/sup/source.rb in sup-0.1 vs lib/sup/source.rb in sup-0.2

- old
+ new

@@ -29,11 +29,11 @@ ## - start_offset ## - end_offset (exclusive!) ## - load_header offset ## - load_message offset ## - raw_header offset - ## - raw_full_message offset + ## - raw_message offset ## - check ## - next (or each, if you prefer): should return a message and an ## array of labels. ## ## ... where "offset" really means unique id. (You can tell I @@ -75,12 +75,12 @@ def to_s; @uri.to_s; end def seek_to! o; self.cur_offset = o; end def reset!; seek_to! start_offset; end def == o; o.uri == uri; end - def done?; (self.cur_offset ||= start_offset) >= end_offset; end - def is_source_for? uri; URI(self.uri) == URI(uri); end + def done?; start_offset.nil? || (self.cur_offset ||= start_offset) >= end_offset; 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 ## to proactively notify the user of any source problems. def check; end @@ -94,9 +94,13 @@ end end protected + def Source.expand_filesystem_uri uri + uri.gsub "~", File.expand_path("~") + end + def cur_offset= o @cur_offset = o @dirty = true end end