Module: Kernel

Defined in:
lib/pretty_debug.rb,
lib/pretty_debug.rb

Constant Summary collapse

ErrorMsgProcess =
Mutex.new

Instance Method Summary collapse

Instance Method Details

#caller_location(i) ⇒ Object



26
# File 'lib/pretty_debug.rb', line 26

def caller_location i; caller_locations(i + 1, 1).first end

#load_relative(f, *rest) ⇒ Object



27
28
29
# File 'lib/pretty_debug.rb', line 27

def load_relative f, *rest; 
  load(File.expand_path(f, caller_location(1).dirname), *rest)
end

#log(h) ⇒ Object



109
110
111
112
# File 'lib/pretty_debug.rb', line 109

def log h
  h["time"] ||= Time.now.full
  ErrorMsgProcess.synchronize{puts(h.ltsv)}
end

#old_raiseObject



113
# File 'lib/pretty_debug.rb', line 113

alias old_raise :raise

#raise(*args) ⇒ Object



114
115
116
117
118
119
# File 'lib/pretty_debug.rb', line 114

def raise *args
  old_raise *args
rescue => e
  e.backtrace_locations = caller_locations
  old_raise(e)
end

#supress_warningObject

Supress warning message (“already initialized constants”, etc.).



103
104
105
106
107
# File 'lib/pretty_debug.rb', line 103

def supress_warning
  original_verbose, $VERBOSE = $VERBOSE, nil
  yield
  $VERBOSE =  original_verbose
end