Sha256: d9dfc8bcdbb73f421855276b9da91f8584879f21a497a6db9a127ba262c79b6d

Contents?: true

Size: 916 Bytes

Versions: 15

Compression:

Stored size: 916 Bytes

Contents

module Lotus
  module Utils
    # IO utils
    #
    # @since 0.1.0
    class IO
      # Decreases the level of verbosity, during the execution of the given block.
      #
      # Revised version of ActiveSupport's `Kernel.with_warnings` implementation
      # @see https://github.com/rails/rails/blob/v4.1.2/activesupport/lib/active_support/core_ext/kernel/reporting.rb#L25
      #
      # @yield the block of code that generates warnings.
      #
      # @return [void]
      #
      # @since 0.1.0
      #
      # @example
      #   require 'lotus/utils/io'
      #
      #   class Test
      #     TEST_VALUE = 'initial'
      #   end
      #
      #   Lotus::Utils::IO.silence_warnings do
      #     Test::TEST_VALUE = 'redefined'
      #   end
      def self.silence_warnings
        old_verbose, $VERBOSE = $VERBOSE, nil
        yield
      ensure
        $VERBOSE = old_verbose
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
lotus-utils-0.6.1 lib/lotus/utils/io.rb
lotus-utils-0.6.0 lib/lotus/utils/io.rb
lotus-utils-0.5.2 lib/lotus/utils/io.rb
lotus-utils-0.5.1 lib/lotus/utils/io.rb
lotus-utils-0.5.0 lib/lotus/utils/io.rb
lotus-utils-0.4.3 lib/lotus/utils/io.rb
lotus-utils-0.4.2 lib/lotus/utils/io.rb
lotus-utils-0.4.1 lib/lotus/utils/io.rb
lotus-utils-0.4.0 lib/lotus/utils/io.rb
lotus-utils-0.3.5 lib/lotus/utils/io.rb
lotus-utils-0.3.4 lib/lotus/utils/io.rb
lotus-utils-0.3.3 lib/lotus/utils/io.rb
lotus-utils-0.3.2 lib/lotus/utils/io.rb
lotus-utils-0.3.1 lib/lotus/utils/io.rb
lotus-utils-0.3.0 lib/lotus/utils/io.rb