Sha256: 5fbc5e3cd7915bd991752101ab75ef652a00245d000151f930e4aba6a1bbc779

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

Contents

require 'thread'

module Rake::CompTree
  module Misc
    def let
      yield self
    end

    def singleton_class
      class << self
        self
      end
    end

    module Gensym
      @mutex = Mutex.new
      @count = 0

      def gensym(prefix = nil)
        count = Gensym.module_eval {
          @mutex.synchronize {
            @count += 1
          }
        }
        "#{prefix || :G}_#{count}".to_sym
      end
    end
    include Gensym

    def call_private(method, *args, &block)
      instance_eval { send(method, *args, &block) }
    end

    def with_warnings(value = true)
      previous = $VERBOSE
      $VERBOSE = value
      begin
        yield
      ensure
        $VERBOSE = previous
      end
    end

    def no_warnings(&block)
      with_warnings(false, &block)
    end

    def abort_on_exception(value = true)
      previous = Thread.abort_on_exception
      Thread.abort_on_exception = value
      begin
        yield
      ensure
        Thread.abort_on_exception = previous
      end
    end

    extend self
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
drake-0.8.2.1.0.10 lib/rake/comp_tree/misc.rb
drake-0.8.2.1.0.7 lib/rake/comp_tree/misc.rb
drake-0.8.2.1.0.9 lib/rake/comp_tree/misc.rb