Class: PrettyDebug
Constant Summary collapse
- Hook =
%w[ at_exit set_trace_func 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 prepend append_features extend_features prepend_features ]
Class Method Summary collapse
- .backtrace_locations(e) ⇒ Object
- .beautify(a) ⇒ Object
- .caller_locations ⇒ Object
- .format(&pr) ⇒ Object
- .message(e) ⇒ Object
- .reject(&pr) ⇒ Object
- .select(&pr) ⇒ Object
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 PrettyArray.new(beautify(e.backtrace_locations)) end |
.beautify(a) ⇒ Object
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/pretty_debug.rb', line 169 def self.beautify a a .map{|l| [l.realpath, l.lineno, l.label]} .transpose.tap do |_, _, ms| ms.map! do |m| case m when *Hook then "(#{m})" when /\A(rescue in )?block( .*)? in / then "(entered block)" when /\Arescue in / then "" else m end end ms[-1] = ""; ms.rotate!(-1) end.transpose end |
.caller_locations ⇒ Object
142 143 144 |
# File 'lib/pretty_debug.rb', line 142 def self.caller_locations PrettyArray.new(beautify(Kernel.caller_locations)) end |
.format(&pr) ⇒ Object
133 |
# File 'lib/pretty_debug.rb', line 133 def self.format ≺ @format = pr end |
.message(e) ⇒ Object
134 135 136 137 |
# File 'lib/pretty_debug.rb', line 134 def self. e e.complement_backtrace_locations e..to_s.sub(/./, &:upcase).sub(/(?<=[^.])\z/, ".").tr("'", "`") end |
.reject(&pr) ⇒ Object
125 126 127 128 |
# File 'lib/pretty_debug.rb', line 125 def self.reject &pr @reject = pr @select = ->f, m{true} end |
.select(&pr) ⇒ Object
129 130 131 132 |
# File 'lib/pretty_debug.rb', line 129 def self.select &pr @select = pr @reject = ->f, m{false} end |