Class: PrettyDebug
Constant Summary collapse
- Stackline =
/\A(?'f'.+?):(?'l'\d+)(?::in `(?'m'.*)'|(?'m'.*))?\z/m
- NoncallLine =
/\Ablock(?: \(\d+ levels\))? in |\A\</
Instance Attribute Summary collapse
-
#backtrace ⇒ Object
Returns the value of attribute backtrace.
-
#message ⇒ Object
Returns the value of attribute message.
Class Method Summary collapse
Instance Attribute Details
#backtrace ⇒ Object
Returns the value of attribute backtrace.
45 46 47 |
# File 'lib/pretty_debug.rb', line 45 def backtrace @backtrace end |
#message ⇒ Object
Returns the value of attribute message.
45 46 47 |
# File 'lib/pretty_debug.rb', line 45 def end |
Class Method Details
.clean(stack) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/pretty_debug.rb', line 56 def self.clean stack raise "Cannot parse. No backtrace given" unless stack return [] if stack.empty? caller_file_i = $LOADED_FEATURES.index(caller.first.match(Stackline)[:f]).to_i stack .map{|l| m = l.match(Stackline); [m[:f].ellipsis(55), m[:l].to_i, m[:m]]} .transpose.tap do |_, _, m| m.rotate!(-1) m[0] = "" while i = m.index{|m| m == "method_missing"}; m[i] = m[i - 1] end end.transpose .reject{|_, _, m| m =~ NoncallLine} # .reject{|f, _, _| $LOADED_FEATURES.include?(f)} # .reject{|f, _, _| $LOADED_FEATURES.index(f).to_i > caller_file_i} end |
.message ⇒ Object
55 |
# File 'lib/pretty_debug.rb', line 55 def self.; $!..dup.tap{|s| s[0] = s[0].upcase}.sub(/(?<=[^.])\z/, ".") end |
.new_internal ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/pretty_debug.rb', line 46 def self.new_internal new.tap do |error| called_location = clean(caller)[2] error.backtrace = clean($@).take_while{|a| a != called_location} error. = $!. end end |