Class: SmartMachine::Base

Inherits:
Object
  • Object
show all
Includes:
Logger
Defined in:
lib/smart_machine/base.rb

Instance Method Summary collapse

Methods included from Logger

configure_logger_for, included, #logger, logger_for

Constructor Details

#initializeBase

Returns a new instance of Base.



9
10
# File 'lib/smart_machine/base.rb', line 9

def initialize
end

Instance Method Details

#machine_has_engine_installed?Boolean

Returns:

  • (Boolean)


25
26
27
28
# File 'lib/smart_machine/base.rb', line 25

def machine_has_engine_installed?
  machine = SmartMachine::Machine.new
  machine.run_on_machine(commands: ["which smartengine | grep -q '/smartengine'"])
end

#platform_on_machine?(os:, distro_name: nil) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/smart_machine/base.rb', line 12

def platform_on_machine?(os:, distro_name: nil)
  case os
  when "linux"
    command = "(uname | grep -q 'Linux')"
    command += " && (cat /etc/os-release | grep -q 'NAME=\"Debian GNU/Linux\"')" if distro_name == "debian"
  when "mac"
    command = "(uname | grep -q 'Darwin')"
  end

  machine = SmartMachine::Machine.new
  command ? machine.run_on_machine(commands: command) : false
end

#user_bash(command) ⇒ Object



30
31
32
33
# File 'lib/smart_machine/base.rb', line 30

def user_bash(command)
  remove_envs = %w(RUBY_MAJOR RUBY_VERSION RUBY_DOWNLOAD_SHA256 GEM_HOME BUNDLE_APP_CONFIG BUNDLE_SILENCE_ROOT_WARNING)
  'env -u ' + remove_envs.join(' -u ') + ' bash --login -c \'' + command + '\''
end