Sha256: 90d7fc444269904650000407710e4694d2b8dbc04c0dc27ecaaafb340457aaab

Contents?: true

Size: 822 Bytes

Versions: 22

Compression:

Stored size: 822 Bytes

Contents

# From ActiveSupport: https://github.com/rails/rails/blob/c2c8ef57d6f00d1c22743dc43746f95704d67a95/activesupport/lib/active_support/core_ext/kernel/reporting.rb#L39

require 'rbconfig'

module Kernel
  # Silences any stream for the duration of the block.
  #
  #   silence_stream(STDOUT) do
  #     puts 'This will never be seen'
  #   end
  #
  #   puts 'But this will'
  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

  # Silences both STDOUT and STDERR, even for subprocesses.
  #
  #   quietly { system 'bundle install' }
  #
  def quietly
    silence_stream(STDOUT) do
      silence_stream(STDERR) do
        yield
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 4 rubygems

Version Path
berkshelf-0.4.0 lib/berkshelf/core_ext/kernel.rb
berkshelf-0.4.0.rc4 lib/berkshelf/core_ext/kernel.rb
berkshelf-0.4.0.rc3 lib/berkshelf/core_ext/kernel.rb
berkshelf-0.4.0.rc2 lib/berkshelf/core_ext/kernel.rb
berkshelf-0.4.0.rc1 lib/berkshelf/core_ext/kernel.rb
solve-0.2.1 lib/solve/core_ext/kernel.rb
berkshelf-0.3.7 lib/berkshelf/core_ext/kernel.rb
berkshelf-0.3.3 lib/berkshelf/core_ext/kernel.rb
berkshelf-0.3.2 lib/berkshelf/core_ext/kernel.rb
berkshelf-0.3.1 lib/berkshelf/core_ext/kernel.rb
berkshelf-0.3.0 lib/berkshelf/core_ext/kernel.rb
berkshelf-0.2.0 lib/berkshelf/core_ext/kernel.rb
berkshelf-0.1.5 lib/berkshelf/core_ext/kernel.rb
berkshelf-0.1.4 lib/berkshelf/core_ext/kernel.rb
berkshelf-0.1.3 lib/berkshelf/core_ext/kernel.rb
berkshelf-0.1.2 lib/berkshelf/core_ext/kernel.rb
berkshelf-0.1.1 lib/berkshelf/core_ext/kernel.rb
knife_cookbook_dependencies_over_http-0.0.8.3 lib/kcd/core_ext/kernel.rb
knife_cookbook_dependencies_over_http-0.0.8.2 lib/kcd/core_ext/kernel.rb
knife_cookbook_dependencies_over_http-0.0.8.1 lib/kcd/core_ext/kernel.rb