Module: Spout::Helpers::Quietly

Included in:
Commands::Deploy
Defined in:
lib/spout/helpers/quietly.rb

Overview

Silences output for tests

Instance Method Summary collapse

Instance Method Details

#quietlyObject



18
19
20
21
22
23
24
# File 'lib/spout/helpers/quietly.rb', line 18

def quietly
  silence_stream(STDOUT) do
    silence_stream(STDERR) do
      yield
    end
  end
end

#silence_stream(stream) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/spout/helpers/quietly.rb', line 8

def silence_stream(stream)
  old_stream = stream.dup
  stream.reopen(/mswin|mingw/ =~ RbConfig::CONFIG["host_os"] ? "NUL:" : "/dev/null")
  stream.sync = true
  yield
ensure
  stream.reopen(old_stream)
end