Skip to content
Browse files

Cleanup move Backtrace => Rubinius::Backtrace

  • Loading branch information...
1 parent d130ca3 commit 4c9fd74f4f715cf300f8f42a0320c84ed562b9fb Evan Phoenix committed
Showing with 12 additions and 16 deletions.
  1. +5 −9 kernel/common/backtrace.rb
  2. +3 −3 kernel/common/exception.rb
  3. +1 −1 kernel/common/location.rb
  4. +3 −3 spec/core/backtrace/show_spec.rb
View
14 kernel/common/backtrace.rb
@@ -1,7 +1,7 @@
##
# Contains all logic for gathering and displaying backtraces.
-class Backtrace
+class Rubinius::Backtrace
include Enumerable
MAX_WIDTH = 36
@@ -59,7 +59,8 @@ def show(sep="\n", show_color=true)
times = 0
@locations.each do |loc|
- if loc.name == last_name and loc.method == last_method and loc.line == last_line
+ if loc.name == last_name and loc.method == last_method \
+ and loc.line == last_line
times += 1
else
lines.last[-1] = times if lines.size > 0
@@ -81,14 +82,10 @@ def show(sep="\n", show_color=true)
pos = location.position(Dir.getwd)
color = show_color ? color_from_loc(pos, first) : ""
first = false # special handling for first line
+
spaces = max - recv.size
spaces = 0 if spaces < 0
- # trim the path unless we're debugging.
- #unless $DEBUG
- # pos = "...#{pos[pos.size-max-3..-1]}" if pos.size > max
- #end
-
if show_color and location.inlined?
start = " #{' ' * spaces}#{recv} #{@inline_effect}at#{clear}#{color} "
else
@@ -157,6 +154,7 @@ def join(sep)
def color_from_loc(loc, first)
return @first_color if first
+
if loc =~ /^kernel/
@kernel_color
elsif loc =~ /\(eval\)/
@@ -179,8 +177,6 @@ def self.detect_backtrace(obj)
return nil
end
- # HACK: This should be MRI compliant-ish. --rue
- #
def to_mri
return @mri_backtrace if @mri_backtrace
View
6 kernel/common/exception.rb
@@ -44,7 +44,7 @@ def backtrace?
end
def awesome_backtrace
- @backtrace ||= Backtrace.backtrace(@locations)
+ @backtrace ||= Rubinius::Backtrace.backtrace(@locations)
end
def render(header="An exception occurred", io=STDERR, color=true)
@@ -81,11 +81,11 @@ def render(header="An exception occurred", io=STDERR, color=true)
end
def set_backtrace(bt)
- if bt.kind_of? Backtrace
+ if bt.kind_of? Rubinius::Backtrace
@backtrace = bt
else
# See if we stashed a Backtrace object away, and use it.
- if hidden_bt = Backtrace.detect_backtrace(bt)
+ if hidden_bt = Rubinius::Backtrace.detect_backtrace(bt)
@backtrace = hidden_bt
else
@custom_backtrace = bt
View
2 kernel/common/location.rb
@@ -103,7 +103,7 @@ def position(relative_to=nil)
end
end
- # See Backtrace.backtrace
+ # See Rubinius::Backtrace.backtrace
class Missing
def describe
"*** Missing backtrace! Did the VM not create one? ***"
View
6 spec/core/backtrace/show_spec.rb
@@ -1,6 +1,6 @@
require File.expand_path('../../../spec_helper', __FILE__)
-describe "Backtrace" do
+describe "Rubinius::Backtrace" do
it "returns a string if file paths exceed terminal width and show_color is false" do
locs = Rubinius::VM.backtrace(1)
@@ -9,8 +9,8 @@
loc.stub!(:position).and_return(idx.to_s + "a"*90 + ".rb")
end
- bt = Backtrace.new(locs, 65, 20)
+ bt = Rubinius::Backtrace.new(locs, 65, 20)
bt.show("\n", false).should be_kind_of(String)
end
-end
+end

0 comments on commit 4c9fd74

Please sign in to comment.
Something went wrong with that request. Please try again.