Sha256: 7dfba57c89c43271d4194bfe8ad6f80aecb4e7aaf512a2184f9eaf17359a4165

Contents?: true

Size: 1.36 KB

Versions: 2

Compression:

Stored size: 1.36 KB

Contents

$debug = true
if $debug
  warn 'DEBUG MODE'
  
  #require 'ruby-debug'
  
  Thread.abort_on_exception = true
  
  RubyExt::ClassLoader.error_on_defined_constant = true
  
  module Kernel
    STACK_TRACE_EXCLUDE = [
    /\/rspec/, 
    /\/ruby-debug/, 
    /\/monitor.rb/, 
    /\/timeout.rb/,
#        /gems/, 
    #    /WGUI/,
    /\/Micon/,
    /\/RubyExt/,
    /\/kernel.rb/,
    /\/mongrel/,
    /\/rack/,
    /\/sync/,
    /\/require/,
    /\/site_ruby/,
    /OpenConstructor/,
    ]
    
    alias_method :old_caller, :caller
    def caller int = 0
      stack = old_caller  
      stack = stack[(int+1)..stack.size].delete_if do |line|
        STACK_TRACE_EXCLUDE.any?{|re| line =~ re}
      end
      return stack
    end
    
    def where?
      puts "\nwhere:"
      puts caller
    end
    
#    alias_method :old_raise, :raise
#    def raise *p
#      case p.size
#        when 3
#        e, m, c = p
#        when 2
#        e, m = p
#        c = caller
#        when 1          
#        if p[0].is_a? Exception
#          e = p[0].class
#          m = p[0].message          
#        else
#          e = RuntimeError
#          m = p[0]        
#        end
#        c = caller
#        when 0
#        e, m, c = RuntimeError, "", caller
#      else 
#        old_raise "Invalid Usage!"
#      end
#      old_raise e, m, c
#    end
  end        
end
#def p; end
#def puts; end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby-ext-0.4.1 old/lib/RubyExt/debug.rb
ruby-ext-0.4.0 old/lib/RubyExt/debug.rb