2012-12-31 20:52:06 +00:00
|
|
|
require 'forwardable'
|
|
|
|
|
2012-12-31 18:13:25 +00:00
|
|
|
class Pry
|
|
|
|
class Command::Edit
|
|
|
|
class ExceptionPatcher
|
2012-12-31 20:52:06 +00:00
|
|
|
extend Forwardable
|
|
|
|
|
|
|
|
def_delegators :@edit_context, :state, :_pry_
|
2012-12-31 18:13:25 +00:00
|
|
|
|
|
|
|
def initialize(edit_context)
|
|
|
|
@edit_context = edit_context
|
|
|
|
end
|
|
|
|
|
|
|
|
# perform the patch
|
|
|
|
def perform_patch
|
2012-12-31 20:52:06 +00:00
|
|
|
file_name, line = ContextLocator.new(@edit_context).file_and_line
|
|
|
|
lines = state.dynamical_ex_file || File.read(file_name)
|
2012-12-31 18:13:25 +00:00
|
|
|
|
|
|
|
source = Pry::Editor.edit_tempfile_with_content(lines)
|
2012-12-31 20:52:06 +00:00
|
|
|
_pry_.evaluate_ruby source
|
|
|
|
state.dynamical_ex_file = source.split("\n")
|
2012-12-31 18:13:25 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|