Class: PrettyDebug

Inherits:
Object show all
Defined in:
lib/pretty_debug.rb

Constant Summary collapse

Hook =
%w[
	initialize
	method_missing
	singleton_method_added
	singleton_method_removed
	singleton_method_undefined
	respond_to_missing?
	extended
	included
	method_added
	method_removed
	method_undefined
	const_missing
	inherited
	intitialize_copy
	intitialize_clone
	intitialize_dup
]

Class Method Summary collapse

Class Method Details

.backtrace_locations(e) ⇒ Object



138
139
140
141
# File 'lib/pretty_debug.rb', line 138

def self.backtrace_locations e
	e.complement_backtrace_locations
	caller_locations(e.backtrace_locations)
end

.caller_locations(a) ⇒ Object



160
161
162
163
164
165
166
167
# File 'lib/pretty_debug.rb', line 160

def self.caller_locations a
	a
	.map{|l| [l.absolute_path, l.lineno, l.base_label]}
	.transpose.tap do |_, _, ms|
		ms.map!{|m| Hook.include?(m) ? "(#{m})" : m}
		ms[-1] = ""; ms.rotate!(-1)
	end.transpose
end

.message(e) ⇒ Object



134
135
136
137
# File 'lib/pretty_debug.rb', line 134

def self.message e
	e.complement_backtrace_locations
	e.message.dup.tap{|s| s[0] = s[0].upcase unless s.empty?}.sub(/(?<=[^.])\z/, ".")
end