Class: Bard::SSHServer

Inherits:
Object
  • Object
show all
Defined in:
lib/bard/plugins/ssh/server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri_string, **options) ⇒ SSHServer

Returns a new instance of SSHServer.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/bard/plugins/ssh/server.rb', line 7

def initialize(uri_string, **options)
  @uri_string = uri_string
  @options = options

  uri = parse_uri(uri_string)
  @user = uri.user || ENV['USER']
  @host = uri.host
  @port = uri.port ? uri.port.to_s : "22"

  @path = options[:path]
  @gateway = options[:gateway]
  @ssh_key = options[:ssh_key]
  @env = options[:env]
end

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



5
6
7
# File 'lib/bard/plugins/ssh/server.rb', line 5

def env
  @env
end

#gatewayObject (readonly)

Returns the value of attribute gateway.



5
6
7
# File 'lib/bard/plugins/ssh/server.rb', line 5

def gateway
  @gateway
end

#hostObject (readonly)

Returns the value of attribute host.



5
6
7
# File 'lib/bard/plugins/ssh/server.rb', line 5

def host
  @host
end

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/bard/plugins/ssh/server.rb', line 5

def path
  @path
end

#portObject (readonly)

Returns the value of attribute port.



5
6
7
# File 'lib/bard/plugins/ssh/server.rb', line 5

def port
  @port
end

#ssh_keyObject (readonly)

Returns the value of attribute ssh_key.



5
6
7
# File 'lib/bard/plugins/ssh/server.rb', line 5

def ssh_key
  @ssh_key
end

#userObject (readonly)

Returns the value of attribute user.



5
6
7
# File 'lib/bard/plugins/ssh/server.rb', line 5

def user
  @user
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



40
41
42
43
# File 'lib/bard/plugins/ssh/server.rb', line 40

def ==(other)
  return false unless other.is_a?(Bard::SSHServer)
  state == other.state
end

#connection_stringObject



36
37
38
# File 'lib/bard/plugins/ssh/server.rb', line 36

def connection_string
  "#{user}@#{host}"
end

#hashObject



46
47
48
# File 'lib/bard/plugins/ssh/server.rb', line 46

def hash
  state.hash
end

#hostnameObject



26
27
28
# File 'lib/bard/plugins/ssh/server.rb', line 26

def hostname
  host
end

#ssh_uriObject



22
23
24
# File 'lib/bard/plugins/ssh/server.rb', line 22

def ssh_uri
  URI("ssh://#{user}@#{host}:#{port}")
end

#to_sObject



30
31
32
33
34
# File 'lib/bard/plugins/ssh/server.rb', line 30

def to_s
  str = "#{user}@#{host}"
  str += ":#{port}" if port && port != "22"
  str
end