Class: Myco::Backtrace
- Inherits:
-
Rubinius::Backtrace
- Object
- Rubinius::Backtrace
- Myco::Backtrace
- Defined in:
- lib/myco/backtrace.rb
Instance Method Summary collapse
-
#initialize ⇒ Backtrace
constructor
A new instance of Backtrace.
- #show(sep = "\n", show_color = true) ⇒ Object
-
#try_gem_path(file) ⇒ Object
If file is in one of the GEM_PATHs, mutate the string and return true.
Methods inherited from Rubinius::Backtrace
Constructor Details
Instance Method Details
#show(sep = "\n", show_color = true) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/myco/backtrace.rb', line 16 def show(sep="\n", show_color=true) show_color &&= @colorize clear = show_color ? "\033[0m" : "" bold = show_color ? "\033[1m" : "" sbullet = "{" ebullet = "}" @locations.map do |loc| file = (loc.position(Dir.getwd) || "").sub /(\:\d+)$/, ' \1' color = show_color ? color_from_loc(file, false) : "" color = @gem_color if try_gem_path file file_width = file.length + 1 + sbullet.length place = loc.instance_variable_get(:@method_module).to_s + '#' place += loc.method.name.to_s place_width = place.length + 1 + ebullet.length padding = @width - file_width - place_width padding += @width until padding >= 0 file_line = bold + color + sbullet + ' ' + clear + color + file place_line = color + bold + place + ' ' + ebullet + clear output = file_line + ' '*padding + place_line output = nil if file == "(myco_internal) :1" output end.compact.reverse.join sep end |
#try_gem_path(file) ⇒ Object
If file is in one of the GEM_PATHs, mutate the string and return true
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/myco/backtrace.rb', line 46 def try_gem_path file @gem_paths.each do |gem_path| if file.start_with? gem_path and not gem_path.empty? file.sub! File.join(gem_path, 'gems'), '' file.sub! %r{/[^/]*/}, '' return true end end return false end |