Sha256: 7acf6cb7527db483894ae080be926bebffeebcc66e919290b82a7f6365cecc09

Contents?: true

Size: 610 Bytes

Versions: 11

Compression:

Stored size: 610 Bytes

Contents

module Spout
  module Helpers
    module Quietly

      # From Rails: http://apidock.com/rails/v3.2.13/Kernel/silence_stream
      def silence_stream(stream)
        old_stream = stream.dup
        stream.reopen(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ? '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

11 entries across 11 versions & 1 rubygems

Version Path
spout-0.10.2 lib/spout/helpers/quietly.rb
spout-0.10.1 lib/spout/helpers/quietly.rb
spout-0.10.0 lib/spout/helpers/quietly.rb
spout-0.10.0.rc3 lib/spout/helpers/quietly.rb
spout-0.10.0.rc2 lib/spout/helpers/quietly.rb
spout-0.10.0.rc lib/spout/helpers/quietly.rb
spout-0.10.0.beta10 lib/spout/helpers/quietly.rb
spout-0.10.0.beta9 lib/spout/helpers/quietly.rb
spout-0.10.0.beta8 lib/spout/helpers/quietly.rb
spout-0.10.0.beta7 lib/spout/helpers/quietly.rb
spout-0.10.0.beta6 lib/spout/helpers/quietly.rb