mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Move eval hooks into evaluate_ruby
This commit is contained in:
parent
e4461e37c7
commit
331f47b0cf
2 changed files with 6 additions and 10 deletions
|
@ -264,19 +264,15 @@ class Pry
|
||||||
target = Pry.binding_for(target)
|
target = Pry.binding_for(target)
|
||||||
|
|
||||||
# It's not actually redundant to inject them continually as we may have
|
# It's not actually redundant to inject them continually as we may have
|
||||||
# moved into the scope of a new Binding (e.g the user typed `cd`)
|
# moved into the scope of a new Binding (e.g the user typed `cd`).
|
||||||
inject_sticky_locals(target)
|
inject_sticky_locals(target)
|
||||||
|
|
||||||
code = r(target)
|
code = r(target)
|
||||||
|
|
||||||
exec_hook :before_eval, code, self
|
evaluate_ruby(code, target)
|
||||||
|
|
||||||
result = evaluate_ruby(code, target)
|
|
||||||
rescue RescuableException => e
|
rescue RescuableException => e
|
||||||
self.last_exception = e
|
self.last_exception = e
|
||||||
e
|
e
|
||||||
ensure
|
|
||||||
exec_hook :after_eval, result, self
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Perform a read.
|
# Perform a read.
|
||||||
|
@ -318,12 +314,13 @@ class Pry
|
||||||
def evaluate_ruby(code, target = binding_stack.last)
|
def evaluate_ruby(code, target = binding_stack.last)
|
||||||
target = Pry.binding_for(target)
|
target = Pry.binding_for(target)
|
||||||
inject_sticky_locals(target)
|
inject_sticky_locals(target)
|
||||||
|
exec_hook :before_eval, code, self
|
||||||
|
|
||||||
target.eval(code, Pry.eval_path, Pry.current_line).tap do |result|
|
result = target.eval(code, Pry.eval_path, Pry.current_line)
|
||||||
set_last_result(result, target, code)
|
set_last_result(result, target, code)
|
||||||
end
|
|
||||||
ensure
|
ensure
|
||||||
update_input_history(code)
|
update_input_history(code)
|
||||||
|
exec_hook :after_eval, result, self
|
||||||
end
|
end
|
||||||
|
|
||||||
# Output the result or pass to an exception handler (if result is an exception).
|
# Output the result or pass to an exception handler (if result is an exception).
|
||||||
|
|
|
@ -236,7 +236,6 @@ describe "Pry::DefaultCommands::Input" do
|
||||||
@str_output.string.should =~ /:test_method_content/
|
@str_output.string.should =~ /:test_method_content/
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
it 'should play a method with the -m switch (multiple line)' do
|
it 'should play a method with the -m switch (multiple line)' do
|
||||||
o = Object.new
|
o = Object.new
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue