Module: SpecInfra::Helper::DetectOS

Defined in:
lib/specinfra/helper/detect_os.rb

Instance Method Summary collapse

Instance Method Details

#commandsObject



4
5
6
# File 'lib/specinfra/helper/detect_os.rb', line 4

def commands
  self.class.const_get('SpecInfra').const_get('Command').const_get(os[:family]).new
end

#osObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/specinfra/helper/detect_os.rb', line 8

def os
  property[:os_by_host] = {} if ! property[:os_by_host]
  host = SpecInfra.configuration.ssh ? SpecInfra.configuration.ssh.host : 'localhost'

  if property[:os_by_host][host]
    os_by_host = property[:os_by_host][host]
  else
    # Set command object explicitly to avoid `stack too deep`
    os_by_host = backend(SpecInfra::Command::Base.new).check_os
    property[:os_by_host][host] = os_by_host
  end

  os_by_host
end