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



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

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

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



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

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



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

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

#log(h) ⇒ Object



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

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

#old_raiseObject



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

alias old_raise :raise

#raise(*args) ⇒ Object



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

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.).



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

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