class SystemWrapper

Public Class Methods

windows?() click to toggle source

static method for use in defaults

# File lib/ceedling/system_wrapper.rb, line 6
def self.windows?
  return ((RbConfig::CONFIG['host_os'] =~ /mswin|mingw/) ? true : false) if defined?(RbConfig)
  return ((Config::CONFIG['host_os'] =~ /mswin|mingw/) ? true : false)
end

Public Instance Methods

add_load_path(path) click to toggle source
# File lib/ceedling/system_wrapper.rb, line 62
def add_load_path(path)
  $LOAD_PATH.unshift(path)
end
cmdline_args() click to toggle source
# File lib/ceedling/system_wrapper.rb, line 28
def cmdline_args
  return ARGV
end
constants_include?(item) click to toggle source
# File lib/ceedling/system_wrapper.rb, line 75
def constants_include?(item)
  # forcing to strings provides consistency across Ruby versions
  return Object.constants.map{|constant| constant.to_s}.include?(item.to_s)
end
env_get(name) click to toggle source
# File lib/ceedling/system_wrapper.rb, line 36
def env_get(name)
  return ENV[name]
end
env_set(name, value) click to toggle source
# File lib/ceedling/system_wrapper.rb, line 32
def env_set(name, value)
  ENV[name] = value
end
eval(string) click to toggle source
# File lib/ceedling/system_wrapper.rb, line 20
def eval(string)
  return eval(string)
end
module_eval(string) click to toggle source
# File lib/ceedling/system_wrapper.rb, line 16
def module_eval(string)
  return Object.module_eval("\"" + string + "\"")
end
require_file(path) click to toggle source
# File lib/ceedling/system_wrapper.rb, line 66
def require_file(path)
  require(path)
end
ruby_success() click to toggle source
# File lib/ceedling/system_wrapper.rb, line 70
def ruby_success
  # We are successful if we've never had an exit code that went boom (either because it's empty or it was 0)
  return ($exit_code.nil? || ($exit_code == 0)) && ($!.nil? || $!.is_a?(SystemExit) && $!.success?)
end
search_paths() click to toggle source
# File lib/ceedling/system_wrapper.rb, line 24
def search_paths
  return ENV['PATH'].split(File::PATH_SEPARATOR)
end
shell_backticks(command, boom = true) click to toggle source
# File lib/ceedling/system_wrapper.rb, line 44
def shell_backticks(command, boom = true)
  retval = `#{command}`.freeze
  $exit_code = ($?.exitstatus).freeze if boom
  return {
    :output    => retval.freeze,
    :exit_code => ($?.exitstatus).freeze
  }
end
shell_system(command, boom = true) click to toggle source
# File lib/ceedling/system_wrapper.rb, line 53
def shell_system(command, boom = true)
  system( command )
  $exit_code = ($?.exitstatus).freeze if boom
  return {
    :output    => "".freeze,
    :exit_code => ($?.exitstatus).freeze
  }
end
time_now() click to toggle source
# File lib/ceedling/system_wrapper.rb, line 40
def time_now
  return Time.now.asctime
end
windows?() click to toggle source

class method so as to be mockable for tests

# File lib/ceedling/system_wrapper.rb, line 12
def windows?
  return SystemWrapper.windows?
end