class Utils

utility methods totally not edited from StackOverflow

Public Class Methods

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

captures stderr from a block: err = capture_stderr { code }

# File lib/puppet-check/utils.rb, line 14
def self.capture_stderr
  old_stderr = $stderr
  $stderr = StringIO.new
  yield
  $stderr.string
ensure
  $stderr = old_stderr
end
capture_stdout() { || ... } click to toggle source

captures stdout from a block: out = capture_stdout { code }

# File lib/puppet-check/utils.rb, line 4
def self.capture_stdout
  old_stdout = $stdout
  $stdout = StringIO.new
  yield
  $stdout.string
ensure
  $stdout = old_stdout
end