Move all hacking of rbx paths into Pry::Code

This commit is contained in:
Conrad Irwin 2013-05-10 00:42:55 -07:00
parent 4b612fb03f
commit 71b364e97c
6 changed files with 6 additions and 26 deletions

View File

@ -63,6 +63,8 @@ class Pry
Pry.line_buffer.drop(1)
elsif Pry::Method::Patcher.code_for(filename)
Pry::Method::Patcher.code_for(filename)
elsif RbxPath.is_core_path?(filename)
File.read RbxPath.convert_path_to_full(filename)
else
File.read(abs_path(filename))
end

View File

@ -44,8 +44,7 @@ class Pry
end
def backtrace_file
file = Array(ex.bt_source_location_for(backtrace_level)).first
(file && RbxPath.is_core_path?(file)) ? RbxPath.convert_path_to_full(file) : file
Array(ex.bt_source_location_for(backtrace_level)).first
end
def backtrace_line

View File

@ -21,8 +21,6 @@ class Pry
raise CommandError, "Exception has no associated file." if file_name.nil?
raise CommandError, "Cannot edit exceptions raised in REPL." if Pry.eval_path == file_name
file_name = RbxPath.convert_path_to_full(file_name) if RbxPath.is_core_path?(file_name)
[file_name, line]
end

View File

@ -302,15 +302,6 @@ class Pry
source_location.nil? ? :c : :ruby
end
def source_location
if @method.source_location && rbx?
file, line = @method.source_location
[RbxPath.convert_path_to_full(file), line]
else
@method.source_location
end
end
# @return [String, nil] The name of the file the method is defined in, or
# `nil` if the filename is unavailable.
def source_file

View File

@ -112,13 +112,13 @@ class Pry
# @return [Array] The source location of the base method used to
# calculate the source location of the candidate.
def first_method_source_location
@first_method_source_location ||= adjusted_source_location(method_candidates[@rank].first.source_location)
@first_method_source_location ||= method_candidates[@rank].first.source_location
end
# @return [Array] The source location of the last method in this
# candidate's module definition.
def last_method_source_location
@end_method_source_location ||= adjusted_source_location(method_candidates[@rank].last.source_location)
@end_method_source_location ||= method_candidates[@rank].last.source_location
end
# Return the number of lines between the start of the class definition
@ -131,16 +131,6 @@ class Pry
end_method_line - line
end
def adjusted_source_location(sl)
file, line = sl
if file && RbxPath.is_core_path?(file)
file = RbxPath.convert_path_to_full(file)
end
[file, line]
end
end
end
end

View File

@ -2,7 +2,7 @@ class Pry
module RbxPath
module_function
def is_core_path?(path)
path.start_with?("kernel") || path.start_with?("lib")
Pry::Helpers::BaseHelpers.rbx? && (path.start_with?("kernel") || path.start_with?("lib")) && File.exist?(convert_path_to_full(path))
end
def convert_path_to_full(path)