Sha256: 83ac31c24d0b06f43e607ef9f7040e6b0edfbf6db8c0e632fe84171ef88fccfb

Contents?: true

Size: 495 Bytes

Versions: 19

Compression:

Stored size: 495 Bytes

Contents

# utility methods totally not edited from StackOverflow
class Utils
  # captures stdout from a block: out = capture_stdout { code }
  def self.capture_stdout
    old_stdout = $stdout
    $stdout = StringIO.new
    yield
    $stdout.string
  ensure
    $stdout = old_stdout
  end

  # captures stderr from a block: err = capture_stderr { code }
  def self.capture_stderr
    old_stderr = $stderr
    $stderr = StringIO.new
    yield
    $stderr.string
  ensure
    $stderr = old_stderr
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
puppet-check-2.2.2 lib/puppet-check/utils.rb
puppet-check-2.2.1 lib/puppet-check/utils.rb
puppet-check-2.2.0 lib/puppet-check/utils.rb
puppet-check-2.1.0 lib/puppet-check/utils.rb
puppet-check-2.0.1 lib/puppet-check/utils.rb
puppet-check-2.0.0 lib/puppet-check/utils.rb
puppet-check-1.6.1 lib/puppet-check/utils.rb
puppet-check-1.6.0 lib/puppet-check/utils.rb
puppet-check-1.5.1 lib/puppet-check/utils.rb
puppet-check-1.5.0 lib/puppet-check/utils.rb
puppet-check-1.4.1 lib/puppet-check/utils.rb
puppet-check-1.4.0 lib/puppet-check/utils.rb
puppet-check-1.3.2 lib/puppet-check/utils.rb
puppet-check-1.3.1 lib/puppet-check/utils.rb
puppet-check-1.3.0 lib/puppet-check/utils.rb
puppet-check-1.2.1 lib/puppet-check/utils.rb
puppet-check-1.2.0 lib/puppet-check/utils.rb
puppet-check-1.1.0 lib/puppet-check/utils.rb
puppet-check-1.0.0 lib/puppet-check/utils.rb