From 331f47b0cf5d88529c9522394725f4701b5dac66 Mon Sep 17 00:00:00 2001 From: Ryan Fitzgerald Date: Tue, 7 Aug 2012 21:02:54 -0700 Subject: [PATCH] Move eval hooks into evaluate_ruby --- lib/pry/pry_instance.rb | 15 ++++++--------- test/test_default_commands/test_input.rb | 1 - 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/lib/pry/pry_instance.rb b/lib/pry/pry_instance.rb index 36aa9dc1..6f6f256a 100644 --- a/lib/pry/pry_instance.rb +++ b/lib/pry/pry_instance.rb @@ -264,19 +264,15 @@ class Pry target = Pry.binding_for(target) # 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) code = r(target) - exec_hook :before_eval, code, self - - result = evaluate_ruby(code, target) + evaluate_ruby(code, target) rescue RescuableException => e self.last_exception = e e - ensure - exec_hook :after_eval, result, self end # Perform a read. @@ -318,12 +314,13 @@ class Pry def evaluate_ruby(code, target = binding_stack.last) target = Pry.binding_for(target) inject_sticky_locals(target) + exec_hook :before_eval, code, self - target.eval(code, Pry.eval_path, Pry.current_line).tap do |result| - set_last_result(result, target, code) - end + result = target.eval(code, Pry.eval_path, Pry.current_line) + set_last_result(result, target, code) ensure update_input_history(code) + exec_hook :after_eval, result, self end # Output the result or pass to an exception handler (if result is an exception). diff --git a/test/test_default_commands/test_input.rb b/test/test_default_commands/test_input.rb index be228478..7c27cbd1 100644 --- a/test/test_default_commands/test_input.rb +++ b/test/test_default_commands/test_input.rb @@ -236,7 +236,6 @@ describe "Pry::DefaultCommands::Input" do @str_output.string.should =~ /:test_method_content/ end - it 'should play a method with the -m switch (multiple line)' do o = Object.new