Sha256: 45e26d08a4d34bb73973ff8ca49cd3af7b71f5df7eb11f13a9a7077c78e4ce0a

Contents?: true

Size: 544 Bytes

Versions: 77

Compression:

Stored size: 544 Bytes

Contents

module Kernel
  def silence_stdout_if(cond, &run)
    silence_stream_if(cond, STDOUT, &run)
  end

  def silence_stderr_if(cond, &run)
    silence_stream_if(cond, STDERR, &run)
  end

  def silence_stream_if(cond, stream, &run)
    if cond
      silence_stream(stream, &run)
    else
      run.call
    end
  end

  def silence_stream(stream)
    old_stream = stream.dup
    stream.reopen(File::NULL)
    stream.sync = true
    yield
  ensure
    stream.reopen(old_stream)
    old_stream.close
  end unless method_defined?(:silence_stream)
end

Version data entries

77 entries across 76 versions & 10 rubygems

Version Path
entreprise7pro-bootstrap-sass-3.4.7 test/support/reporting.rb
entreprise7pro-bootstrap-sass-3.4.6 test/support/reporting.rb
bootstrap-4.6.2.1 test/support/reporting.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/bootstrap-4.6.2/test/support/reporting.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/bootstrap-5.3.3/test/support/reporting.rb
bootstrap-5.3.3 test/support/reporting.rb
bootstrap-propshaft-5.3.2.2 test/support/reporting.rb
bootstrap-propshaft-5.3.2.1 test/support/reporting.rb
bootstrap-propshaft-5.3.2 test/support/reporting.rb
bootstrap-5.3.2 test/support/reporting.rb
bootstrap-5.3.1 test/support/reporting.rb
bootstrap-5.3.0 test/support/reporting.rb
bootstrap-5.3.0.alpha3 test/support/reporting.rb
bootstrap-5.2.3 test/support/reporting.rb
bootstrap-5.2.2 test/support/reporting.rb
bootstrap-5.2.1 test/support/reporting.rb
bootstrap-4.6.2 test/support/reporting.rb
nex-bootstrap-4.6.3 test/support/reporting.rb
bootstrap-5.2.0 test/support/reporting.rb
bootstrap-4.6.1 test/support/reporting.rb