1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00
pry--pry/lib/pry/commands/edit/exception_patcher.rb

25 lines
612 B
Ruby

require 'forwardable'
class Pry
class Command::Edit
class ExceptionPatcher
extend Forwardable
def_delegators :@edit_context, :state, :_pry_
def initialize(edit_context)
@edit_context = edit_context
end
# perform the patch
def perform_patch
file_name, line = ContextLocator.new(@edit_context).file_and_line
lines = state.dynamical_ex_file || File.read(file_name)
source = Pry::Editor.edit_tempfile_with_content(lines)
_pry_.evaluate_ruby source
state.dynamical_ex_file = source.split("\n")
end
end
end
end