Sha256: 84d2a63546adb6b4116ba12e1d5a7a6a842235db8be280d49adc8ba632eb977a

Contents?: true

Size: 802 Bytes

Versions: 3

Compression:

Stored size: 802 Bytes

Contents

require 'rake/comp_tree/tap'

module Rake::CompTree
  module Diagnostic
    def show(desc = nil, stream = STDOUT, &block)
      if desc
        stream.puts(desc)
      end
      if block
        expression = block.call
        eval(expression, block.binding).tap { |result|
          stream.printf("%-16s => %s\n", expression, result.inspect)
        }
      end
    end

    if $DEBUG
      def debug
        yield
      end

      def debugging?
        true
      end

      def trace(desc = nil, &block)
        if desc
          show("#{desc}.".sub(%r!\.\.+\Z!, ""), STDERR, &block)
        else
          show(nil, STDERR, &block)
        end
      end
    else
      # non-$DEBUG
      def debug ; end
      def debugging? ; end
      def trace(*args) ; 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/diagnostic.rb
drake-0.8.2.1.0.7 lib/rake/comp_tree/diagnostic.rb
drake-0.8.2.1.0.9 lib/rake/comp_tree/diagnostic.rb