Module: Kernel

Defined in:
lib/pretty_debug.rb,
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

#class_check(v, klass, &pr) ⇒ Object



67
68
69
70
71
72
# File 'lib/pretty_debug.rb', line 67

def class_check v, klass, &pr
	unless v.kind_of?(klass)
		ArgumentError.raise(
			"#{pr.call + " " if pr}should be #{klass.expand} but is #{v.expand}")
	end
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
# File 'lib/pretty_debug.rb', line 109

def log h; ErrorMsgProcess.synchronize{puts(h.ltsv)} end

#old_raiseObject



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

alias old_raise :raise

#raise(*args) ⇒ Object



111
112
113
114
115
116
# File 'lib/pretty_debug.rb', line 111

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

#suppress_warningObject

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



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

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