Class: SshyGuy::Server

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Server

Returns a new instance of Server.



9
10
11
12
# File 'lib/sshyguy/server.rb', line 9

def initialize(config)
  @config = config
  self.class.all << self
end

Class Method Details

.allObject



5
6
7
# File 'lib/sshyguy/server.rb', line 5

def self.all
  @all ||= []
end

Instance Method Details

#commandObject



24
25
26
# File 'lib/sshyguy/server.rb', line 24

def command
  @command ||= Command.new(@config)
end

#folderObject



28
29
30
# File 'lib/sshyguy/server.rb', line 28

def folder
  @config['folder'].presence || 'Default'
end

#groupObject



36
37
38
# File 'lib/sshyguy/server.rb', line 36

def group
  @config['group'].presence || 'Default'
end

#shortcutObject



32
33
34
# File 'lib/sshyguy/server.rb', line 32

def shortcut
  @config['shortcut'].presence
end

#spawnObject



18
19
20
21
22
# File 'lib/sshyguy/server.rb', line 18

def spawn
  SshyGuy.log("Spawning command #{command.to_command}")
  system(command.to_command)
  exit
end

#to_labelObject



14
15
16
# File 'lib/sshyguy/server.rb', line 14

def to_label
  @config['label'] || @config['hostname']
end