class Redwood::MBox::SSHLoader
Attributes
password[RW]
username[RW]
Public Class Methods
new(uri, username=nil, password=nil, start_offset=nil, usual=true, archived=false, id=nil, labels=[])
click to toggle source
Calls superclass method
# File lib/sup/mbox/ssh-loader.rb, line 12 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 @parsed_uri = URI(uri) @username = username @password = password @uri = uri @cur_offset = start_offset @labels = (labels || []).freeze opts = {} opts[:username] = @username if @username opts[:password] = @password if @password @f = SSHFile.new host, filename, opts @loader = Loader.new @f, start_offset, usual, archived, id ## heuristic: use the filename as a label, unless the file ## has a path that probably represents an inbox. end
suggest_labels_for(path;)
click to toggle source
# File lib/sup/mbox/ssh-loader.rb, line 35 def self.suggest_labels_for path; Loader.suggest_labels_for(path) end
Public Instance Methods
connect()
click to toggle source
# File lib/sup/mbox/ssh-loader.rb, line 37 def connect; safely { @f.connect }; end
cur_offset=(o;)
click to toggle source
# File lib/sup/mbox/ssh-loader.rb, line 53 def cur_offset= o; @cur_offset = @loader.cur_offset = o; @dirty = true; end
end_offset()
click to toggle source
# File lib/sup/mbox/ssh-loader.rb, line 49 def end_offset safely { @f.size } end
filename()
click to toggle source
# File lib/sup/mbox/ssh-loader.rb, line 39 def filename; @parsed_uri.path[1..-1] end
host()
click to toggle source
# File lib/sup/mbox/ssh-loader.rb, line 38 def host; @parsed_uri.host; end
id()
click to toggle source
# File lib/sup/mbox/ssh-loader.rb, line 54 def id; @loader.id; end
id=(o;)
click to toggle source
# File lib/sup/mbox/ssh-loader.rb, line 55 def id= o; @id = @loader.id = o; end
next()
click to toggle source
# File lib/sup/mbox/ssh-loader.rb, line 41 def next safely do offset, labels = @loader.next self.cur_offset = @loader.cur_offset # superclass keeps @cur_offset which is used by yaml [offset, (labels + @labels).uniq] # add our labels end end
safely() { || ... }
click to toggle source
# File lib/sup/mbox/ssh-loader.rb, line 59 def safely begin yield rescue Net::SSH::Exception, SocketError, SSHFileError, SystemCallError, IOError => e m = "error communicating with SSH server #{host} (#{e.class.name}): #{e.message}" raise FatalSourceError, m end end
to_s()
click to toggle source
def cur_offset; @loader.cur_offset; end # think we'll be ok without this
# File lib/sup/mbox/ssh-loader.rb, line 57 def to_s; @parsed_uri.to_s; end