class Object

Public Instance Methods

capture_output() { || ... } click to toggle source

helpers

# File lib/modulator/gateway/routes/console.rb, line 4
def capture_output
  previous_stdout, $stdout = $stdout, StringIO.new
  previous_stderr, $stderr = $stderr, StringIO.new
  yield
  $stdout.string if $stdout.string.size > 0
  $stderr.string if $stderr.string.size > 0
  ensure
    $stdout = previous_stdout
    $stderr = previous_stderr
end
render_cf_call_output(cf_call_result, cf_call_output, cf_call_name = 'aws cf sdk call') click to toggle source

cf call return value or its capture from stdout

# File lib/modulator/gateway/routes/console.rb, line 16
def render_cf_call_output(cf_call_result, cf_call_output, cf_call_name = 'aws cf sdk call')
  if cf_call_result
    cf_call_result.to_hash
  else
    {cf_call_name => cf_call_output.split("\n").first}
  end
end
stringify_keys() click to toggle source
# File lib/utils.rb, line 39
def stringify_keys
  case self
  when Hash
    hash = {}
    each {|k, v| hash[k.to_s] = v.stringify_keys}
    hash
  when Array
    map {|x| x.stringify_keys}
  else
    self
  end
end
symbolize_keys() click to toggle source
# File lib/utils.rb, line 25
def symbolize_keys
  case self
  when Hash
    hash = {}
    each {|k, v| hash[k.to_sym] = v.symbolize_keys}
    hash
  when Array
    map {|x| x.symbolize_keys}
  else
    self
  end
end