Skip to content

Commit

Permalink
0.9.7.2 hotfix: fixed indentation issues, now passing eval_string int…
Browse files Browse the repository at this point in the history
…o Pry#run_command
  • Loading branch information
banister committed Oct 27, 2011
1 parent 4927936 commit e8f5d55
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG
@@ -1,3 +1,11 @@
27/10/2011 version 0.9.7.2 hotfix
* fixed indentation for 'super if' and 'ensure', 'next if', etc
* refactored Pry#run_command so it can accept an eval_string parameter (so amend-line and so on can work with it)
* changed ^D so it no longer resets indent level automatically

26/10/2011 version 0.9.7.1 hotfix
* fixed gem dependecy issues

25/10/2011 version 0.9.7

MAJOR NEW FEATURES:
Expand Down
16 changes: 9 additions & 7 deletions lib/pry/pry_instance.rb
Expand Up @@ -254,6 +254,8 @@ def r(target=TOPLEVEL_BINDING, eval_string="")
val = ""
loop do
val = retrieve_line(eval_string, target)

# eval_string may be mutated by this method
process_line(val, eval_string, target)

break if valid_expression?(eval_string)
Expand Down Expand Up @@ -302,12 +304,10 @@ def retrieve_line(eval_string, target)

val = readline(current_prompt + indentation)

# exit session if we receive EOF character (^D)
# invoke handler if we receive EOF character (^D)
if !val
output.puts ""
Pry.config.control_d_handler.call(eval_string, self)

@indent.reset if Pry.config.auto_indent
""
else
# Change the eval_string into the input encoding (Issue 284)
Expand Down Expand Up @@ -359,12 +359,14 @@ def process_line(val, eval_string, target)
end

# Run the specified command.
# @param [String] The command (and its params) to execute.
# @param [Binding] The binding to use..
# @param [String] val The command (and its params) to execute.
# @param [String] eval_string The current input buffer.
# @param [Binding] target The binding to use..
# @return [Pry::CommandContext::VOID_VALUE]
# @example
# pry_instance.run_command("ls -m")
def run_command(val, target = binding_stack.last)
process_line(val, "", target)
def run_command(val, eval_string = "", target = binding_stack.last)
process_line(val, eval_string, target)
Pry::CommandContext::VOID_VALUE
end

Expand Down
2 changes: 1 addition & 1 deletion lib/pry/version.rb
@@ -1,3 +1,3 @@
class Pry
VERSION = "0.9.7.1"
VERSION = "0.9.7.2"
end
11 changes: 10 additions & 1 deletion test/test_pry.rb
Expand Up @@ -184,10 +184,19 @@ class Hello
it 'should run a command in a specified context' do
b = Pry.binding_for(7)
p = Pry.new(:output => StringIO.new)
p.run_command("ls -m", b)
p.run_command("ls -m", "", b)
p.output.string.should =~ /divmod/
end

it 'should run a command that modifies the passed in eval_string' do
b = Pry.binding_for(7)
p = Pry.new(:output => StringIO.new)
eval_string = "def hello\npeter pan\n"
p.run_command("amend-line !", eval_string, b)
eval_string.should =~ /def hello/
eval_string.should.not =~ /peter pan/
end

it 'should run a command in the context of a session' do
mock_pry("@session_ivar = 10", "_pry_.run_command('ls')").should =~ /@session_ivar/
end
Expand Down

0 comments on commit e8f5d55

Please sign in to comment.