Class: Host
- Inherits:
-
Object
show all
- Defined in:
- lib/hostmanager.rb
Defined Under Namespace
Classes: Forwarded, Local, Zeroconf
Constant Summary
collapse
- @@ssh_option_string =
""
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(user_name, host) ⇒ Host
Returns a new instance of Host.
23
24
25
|
# File 'lib/hostmanager.rb', line 23
def initialize(user_name, host)
@host = host; @user_name = user_name.gsub(/ /, '\ '); @port = nil
end
|
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
17
18
19
|
# File 'lib/hostmanager.rb', line 17
def host
@host
end
|
#port ⇒ Object
Returns the value of attribute port.
17
18
19
|
# File 'lib/hostmanager.rb', line 17
def port
@port
end
|
#user_name ⇒ Object
Returns the value of attribute user_name.
17
18
19
|
# File 'lib/hostmanager.rb', line 17
def user_name
@user_name
end
|
Class Method Details
.from_string(string) ⇒ Object
18
19
20
21
22
|
# File 'lib/hostmanager.rb', line 18
def self.from_string(string)
return Zeroconf.from_string(string) if string =~ /\(zeroconf\)/
user_name, host = string.split('@')
return host =~ /\S/ ? new(user_name, host) : Local.new
end
|
Instance Method Details
#control_path_string ⇒ Object
48
49
|
# File 'lib/hostmanager.rb', line 48
def control_path_string
end
|
#remote? ⇒ Boolean
44
45
46
47
|
# File 'lib/hostmanager.rb', line 44
def remote?
setup
true
end
|
#rsync_scp_local ⇒ Object
32
33
34
35
|
# File 'lib/hostmanager.rb', line 32
def rsync_scp_local
setup
""
end
|
#rsync_scp_remote ⇒ Object
28
29
30
31
|
# File 'lib/hostmanager.rb', line 28
def rsync_scp_remote
setup
@user_name ? "#@user_name@#@host:" : "#@host:"
end
|
#setup ⇒ Object
26
27
|
# File 'lib/hostmanager.rb', line 26
def setup end
|
#ssh ⇒ Object
36
37
38
39
|
# File 'lib/hostmanager.rb', line 36
def ssh
setup
@user_name ? "ssh #@@ssh_option_string #@user_name@#@host" : "ssh #@@ssh_option_string #@host"
end
|
#sshfs ⇒ Object
40
41
42
43
|
# File 'lib/hostmanager.rb', line 40
def sshfs
setup
@user_name ? "sshfs #@@ssh_option_string #@user_name@#@host:" : "sshfs #@@ssh_option_string #@host:"
end
|