Class: Host

Inherits:
Object
  • Object
show all
Defined in:
lib/hostmanager.rb

Direct Known Subclasses

Forwarded, Local, Zeroconf

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

#hostObject

Returns the value of attribute host.



17
18
19
# File 'lib/hostmanager.rb', line 17

def host
  @host
end

#portObject

Returns the value of attribute port.



17
18
19
# File 'lib/hostmanager.rb', line 17

def port
  @port
end

#user_nameObject

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_stringObject



48
49
# File 'lib/hostmanager.rb', line 48

def control_path_string
end

#remote?Boolean

Returns:

  • (Boolean)


44
45
46
47
# File 'lib/hostmanager.rb', line 44

def remote?
	setup
	true
end

#rsync_scp_localObject



32
33
34
35
# File 'lib/hostmanager.rb', line 32

def rsync_scp_local
	setup
	""
end

#rsync_scp_remoteObject



28
29
30
31
# File 'lib/hostmanager.rb', line 28

def rsync_scp_remote
	setup
	@user_name ? "#@user_name@#@host:" : "#@host:"
end

#setupObject

see Zeroconf



26
27
# File 'lib/hostmanager.rb', line 26

def setup #see Zeroconf
end

#sshObject



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

#sshfsObject



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