Skip to content
This repository
Browse code

0.9.7.2 hotfix: fixed indentation issues, now passing eval_string int…

…o Pry#run_command
  • Loading branch information...
commit e8f5d55c319cb8d078a0a7da035e7179d6bb49bd 1 parent 4927936
John Mair banister authored
8 CHANGELOG
... ... @@ -1,3 +1,11 @@
  1 +27/10/2011 version 0.9.7.2 hotfix
  2 +* fixed indentation for 'super if' and 'ensure', 'next if', etc
  3 +* refactored Pry#run_command so it can accept an eval_string parameter (so amend-line and so on can work with it)
  4 +* changed ^D so it no longer resets indent level automatically
  5 +
  6 +26/10/2011 version 0.9.7.1 hotfix
  7 +* fixed gem dependecy issues
  8 +
1 9 25/10/2011 version 0.9.7
2 10
3 11 MAJOR NEW FEATURES:
16 lib/pry/pry_instance.rb
@@ -254,6 +254,8 @@ def r(target=TOPLEVEL_BINDING, eval_string="")
254 254 val = ""
255 255 loop do
256 256 val = retrieve_line(eval_string, target)
  257 +
  258 + # eval_string may be mutated by this method
257 259 process_line(val, eval_string, target)
258 260
259 261 break if valid_expression?(eval_string)
@@ -302,12 +304,10 @@ def retrieve_line(eval_string, target)
302 304
303 305 val = readline(current_prompt + indentation)
304 306
305   - # exit session if we receive EOF character (^D)
  307 + # invoke handler if we receive EOF character (^D)
306 308 if !val
307 309 output.puts ""
308 310 Pry.config.control_d_handler.call(eval_string, self)
309   -
310   - @indent.reset if Pry.config.auto_indent
311 311 ""
312 312 else
313 313 # Change the eval_string into the input encoding (Issue 284)
@@ -359,12 +359,14 @@ def process_line(val, eval_string, target)
359 359 end
360 360
361 361 # Run the specified command.
362   - # @param [String] The command (and its params) to execute.
363   - # @param [Binding] The binding to use..
  362 + # @param [String] val The command (and its params) to execute.
  363 + # @param [String] eval_string The current input buffer.
  364 + # @param [Binding] target The binding to use..
  365 + # @return [Pry::CommandContext::VOID_VALUE]
364 366 # @example
365 367 # pry_instance.run_command("ls -m")
366   - def run_command(val, target = binding_stack.last)
367   - process_line(val, "", target)
  368 + def run_command(val, eval_string = "", target = binding_stack.last)
  369 + process_line(val, eval_string, target)
368 370 Pry::CommandContext::VOID_VALUE
369 371 end
370 372
2  lib/pry/version.rb
... ... @@ -1,3 +1,3 @@
1 1 class Pry
2   - VERSION = "0.9.7.1"
  2 + VERSION = "0.9.7.2"
3 3 end
11 test/test_pry.rb
@@ -184,10 +184,19 @@ class Hello
184 184 it 'should run a command in a specified context' do
185 185 b = Pry.binding_for(7)
186 186 p = Pry.new(:output => StringIO.new)
187   - p.run_command("ls -m", b)
  187 + p.run_command("ls -m", "", b)
188 188 p.output.string.should =~ /divmod/
189 189 end
190 190
  191 + it 'should run a command that modifies the passed in eval_string' do
  192 + b = Pry.binding_for(7)
  193 + p = Pry.new(:output => StringIO.new)
  194 + eval_string = "def hello\npeter pan\n"
  195 + p.run_command("amend-line !", eval_string, b)
  196 + eval_string.should =~ /def hello/
  197 + eval_string.should.not =~ /peter pan/
  198 + end
  199 +
191 200 it 'should run a command in the context of a session' do
192 201 mock_pry("@session_ivar = 10", "_pry_.run_command('ls')").should =~ /@session_ivar/
193 202 end

0 comments on commit e8f5d55

Please sign in to comment.
Something went wrong with that request. Please try again.