Module: Train::Extras::DetectDarwin

Includes:
Uname
Included in:
OSCommon
Defined in:
lib/train/extras/os_detect_darwin.rb

Instance Method Summary collapse

Methods included from Uname

#uname_m, #uname_r, #uname_s

Instance Method Details

#detect_darwinObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/train/extras/os_detect_darwin.rb', line 16

def detect_darwin
  cmd = @backend.run_command('/usr/bin/sw_vers')
  # TODO: print an error in this step of the detection,
  # as it shouldnt happen
  return false if cmd.exit_status != 0
  # TODO: ditto on error
  return false if cmd.stdout.empty?

  name = cmd.stdout[/^ProductName:\s+(.+)$/, 1]
  # TODO: ditto on error
  return false if name.nil?
  @platform[:name] = name.downcase.chomp.tr(' ', '_')
  @platform[:release] = cmd.stdout[/^ProductVersion:\s+(.+)$/, 1]
  @platform[:build] = cmd.stdout[/^BuildVersion:\s+(.+)$/, 1]
  # TODO: keep for now due to backwards compatibility with serverspec
  @platform[:family] = 'darwin'
  detect_darwin_arch
  true
end

#detect_darwin_archObject



36
37
38
# File 'lib/train/extras/os_detect_darwin.rb', line 36

def detect_darwin_arch
  @platform[:arch] = uname_m
end