Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Stop overriding Ruby's Object#method in Airbrake::Backtrace::Line #188

Merged
merged 1 commit into from

2 participants

@thommahoney

The use of the :method attribute for the Line class overrides Object#method, causing unexpected errors.

This will likely require a minor version bump.

Note, I can't get the cucumber tests to pass either before or after this change.

@shime shime merged commit cc94133 into from
@shime

Thanks, test suite is passing now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 2, 2013
  1. @thommahoney
This page is out of date. Refresh to see the latest.
View
16 lib/airbrake/backtrace.rb
@@ -14,26 +14,26 @@ class Line
# The line number portion of the line
attr_reader :number
- # The method of the line (such as index)
- attr_reader :method
+ # The method_name of the line (such as index)
+ attr_reader :method_name
# Parses a single line of a given backtrace
# @param [String] unparsed_line The raw line from +caller+ or some backtrace
# @return [Line] The parsed backtrace line
def self.parse(unparsed_line)
- _, file, number, method = unparsed_line.match(INPUT_FORMAT).to_a
- new(file, number, method)
+ _, file, number, method_name = unparsed_line.match(INPUT_FORMAT).to_a
+ new(file, number, method_name)
end
- def initialize(file, number, method)
+ def initialize(file, number, method_name)
self.file = file
self.number = number
- self.method = method
+ self.method_name = method_name
end
# Reconstructs the line in a readable fashion
def to_s
- "#{file}:#{number}:in `#{method}'"
+ "#{file}:#{number}:in `#{method_name}'"
end
def ==(other)
@@ -46,7 +46,7 @@ def inspect
private
- attr_writer :file, :number, :method
+ attr_writer :file, :number, :method_name
end
# holder for an Array of Backtrace::Line instances
View
10 lib/airbrake/notice.rb
@@ -156,9 +156,11 @@ def to_xml
error.message(error_message)
error.backtrace do |backtrace|
self.backtrace.lines.each do |line|
- backtrace.line(:number => line.number,
- :file => line.file,
- :method => line.method)
+ backtrace.line(
+ :number => line.number,
+ :file => line.file,
+ :method_name => line.method_name
+ )
end
end
end
@@ -223,7 +225,7 @@ def to_json
{
'file' => line.file,
'line' => line.number.to_i,
- 'function' => line.method
+ 'function' => line.method_name
}
end
}],
View
2  resources/airbrake_2_4.xsd
@@ -38,7 +38,7 @@
<xs:complexType>
<xs:attribute name="file" type="xs:string" use="required"/>
<xs:attribute name="number" type="xs:string" use="required"/>
- <xs:attribute name="method" type="xs:string" use="optional"/>
+ <xs:attribute name="method_name" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
View
8 test/backtrace_test.rb
@@ -13,12 +13,12 @@ class BacktraceTest < Test::Unit::TestCase
line = backtrace.lines.first
assert_equal '13', line.number
assert_equal 'app/models/user.rb', line.file
- assert_equal 'magic', line.method
+ assert_equal 'magic', line.method_name
line = backtrace.lines.last
assert_equal '8', line.number
assert_equal 'app/controllers/users_controller.rb', line.file
- assert_equal 'index', line.method
+ assert_equal 'index', line.method_name
end
should "parse a windows backtrace into lines" do
@@ -32,12 +32,12 @@ class BacktraceTest < Test::Unit::TestCase
line = backtrace.lines.first
assert_equal '13', line.number
assert_equal 'C:/Program Files/Server/app/models/user.rb', line.file
- assert_equal 'magic', line.method
+ assert_equal 'magic', line.method_name
line = backtrace.lines.last
assert_equal '8', line.number
assert_equal 'C:/Program Files/Server/app/controllers/users_controller.rb', line.file
- assert_equal 'index', line.method
+ assert_equal 'index', line.method_name
end
should "be equal with equal lines" do
View
2  test/notice_test.rb
@@ -351,7 +351,7 @@ def user
assert_valid_node(@document, "//error/backtrace/line/@number", @notice.backtrace.lines.first.number)
assert_valid_node(@document, "//error/backtrace/line/@file", @notice.backtrace.lines.first.file)
- assert_valid_node(@document, "//error/backtrace/line/@method", @notice.backtrace.lines.first.method)
+ assert_valid_node(@document, "//error/backtrace/line/@method_name", @notice.backtrace.lines.first.method_name)
assert_valid_node(@document, "//request/url", @notice.url)
assert_valid_node(@document, "//request/component", @notice.controller)
Something went wrong with that request. Please try again.