class Server
Definitions
attr :name
The name of the server in the configuration (might be the same as the host).
attr_accessor :host
The host name (e.g. DNS entry) for the given server.
attr_accessor :root
The root path on the server in which all other directories will be relative to.
attr_accessor :shell
The shell to use to connect to the server.
def full_path(directory = "")
Give the full path for a particular subdirectory.
Implementation
def full_path(directory = "")
path = File.expand_path(directory.to_s, @root)
Directory.normalize(path)
end
def connection_string(directory, on: nil)
Give a general connection string (e.g +"host:/directory"+ or +"/directory"+ if local).
Implementation
def connection_string(directory, on: nil)
if self.host == on.host
return full_path(directory).to_s
else
return @host + ":" + Shellwords.escape(full_path(directory))
end
end
def to_s
String representation of the server for logging.
Implementation
def to_s
"#{@host}:#{full_path}"
end