end
parsed_uri = URI(uri)
end
parsed_uri = URI(uri)
- Trollop::die "no path component to uri: #{parsed_uri}" unless parsed_uri.path
source =
case parsed_uri.scheme
source =
case parsed_uri.scheme
class Maildir < Source
SCAN_INTERVAL = 30 # seconds
class Maildir < Source
SCAN_INTERVAL = 30 # seconds
+ ## 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=[]
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)
super uri, last_date, usual, archived, id
uri = URI(uri)
def file_path; @dir end
def self.suggest_labels_for path; [] end
def file_path; @dir end
def self.suggest_labels_for path; [] end
+ def is_source_for? uri; super || (URI(Source.expand_filesystem_uri(uri)) == URI(self.uri)); end
class Loader < Source
yaml_properties :uri, :cur_offset, :usual, :archived, :id, :labels
class Loader < Source
yaml_properties :uri, :cur_offset, :usual, :archived, :id, :labels
- def initialize uri_or_fp, start_offset=nil, usual=true, archived=false, id=nil, labels=[]
- super uri_or_fp, start_offset, usual, archived, id
+ ## uri_or_fp is horrific. need to refactor.
+ def initialize uri_or_fp, start_offset=nil, usual=true, archived=false, id=nil, labels=[]
@mutex = Mutex.new
@labels = (labels || []).freeze
case uri_or_fp
when String
@mutex = Mutex.new
@labels = (labels || []).freeze
case uri_or_fp
when String
+ uri_or_fp = Source.expand_filesystem_uri uri_or_fp
uri = 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
uri = 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
+
+ super uri_or_fp, start_offset, usual, archived, id
end
def file_path; URI(uri).path end
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 self.suggest_labels_for path
## heuristic: use the filename as a label, unless the file
def self.suggest_labels_for path
## heuristic: use the filename as a label, unless the file
def reset!; seek_to! start_offset; end
def == o; o.uri == uri; end
def done?; (self.cur_offset ||= start_offset) >= end_offset; 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 is_source_for? uri; 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
## check should throw a FatalSourceError or an OutOfSyncSourcError
## if it can detect a problem. it is called when the sup starts up
+ def Source.expand_filesystem_uri uri
+ uri.gsub "~", File.expand_path("~")
+ end
+
def cur_offset= o
@cur_offset = o
@dirty = true
def cur_offset= o
@cur_offset = o
@dirty = true