Sha256: a4afe3f51b81b3851a298b665ac4c165c794d9b4caffa5ad60c40dc5a653f62e

Contents?: true

Size: 639 Bytes

Versions: 5

Compression:

Stored size: 639 Bytes

Contents

module Spout
  module Helpers
    # Silences output for tests
    module Quietly
      # From Rails: http://apidock.com/rails/v3.2.13/Kernel/silence_stream
      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

      # From Rails: http://apidock.com/rails/v3.2.13/Kernel/quietly
      def quietly
        silence_stream(STDOUT) do
          silence_stream(STDERR) do
            yield
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spout-0.11.0 lib/spout/helpers/quietly.rb
spout-0.11.0.rc lib/spout/helpers/quietly.rb
spout-0.11.0.beta3 lib/spout/helpers/quietly.rb
spout-0.11.0.beta2 lib/spout/helpers/quietly.rb
spout-0.11.0.beta1 lib/spout/helpers/quietly.rb