class Synco::Server
Attributes
host[RW]
The host name (e.g. DNS entry) for the given server.
mountpoint[RW]
name[R]
The name of the server in the configuration (might be the same as the host).
root[RW]
The root path on the server in which all other directories will be relative to.
shell[RW]
The shell to use to connect to the server.
Public Class Methods
new(name, root: '/', shell: nil, **options)
click to toggle source
Calls superclass method
Synco::Controller::new
# File lib/synco/server.rb, line 29 def initialize(name, root: '/', shell: nil, **options) super() @name = name case @name when Symbol @host = "localhost" else @host = name.to_s end @root = root @shell = shell || Shells::SSH.new @options = options end
Public Instance Methods
connection_command()
click to toggle source
# File lib/synco/server.rb, line 77 def connection_command @shell.connection_command(self) end
connection_string(directory, on: nil)
click to toggle source
Give a general connection string (e.g +“host:/directory”+ or +“/directory”+ if local).
# File lib/synco/server.rb, line 69 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
full_path(directory = "")
click to toggle source
Give the full path for a particular subdirectory.
# File lib/synco/server.rb, line 62 def full_path(directory = "") path = File.expand_path(directory.to_s, @root) Directory.normalize(path) end
same_host?(other)
click to toggle source
# File lib/synco/server.rb, line 81 def same_host?(other) @host == other.host end
to_s()
click to toggle source
String representation of the server for logging.
# File lib/synco/server.rb, line 86 def to_s "#{@host}:#{full_path}" end