From ecc38598662af10a3a362e30fe87c699eb1d57e9 Mon Sep 17 00:00:00 2001 From: John Mair Date: Mon, 23 May 2011 19:24:00 +1200 Subject: [PATCH] added experiment rue-(\d) and :(.*) regex commands --- lib/pry/default_commands/input.rb | 1 - lib/pry/extended_commands/experimental.rb | 12 ++++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/pry/default_commands/input.rb b/lib/pry/default_commands/input.rb index 183cea7f..5692af68 100644 --- a/lib/pry/default_commands/input.rb +++ b/lib/pry/default_commands/input.rb @@ -12,7 +12,6 @@ class Pry replacement_line = "" if !replacement_line input_array = opts[:eval_string].each_line.to_a[0..-2] + [opts[:arg_string] + "\n"] opts[:eval_string].replace input_array.join("\n") -# binding.pry end alias_command "%", "amend-line", "" diff --git a/lib/pry/extended_commands/experimental.rb b/lib/pry/extended_commands/experimental.rb index f2798cee..976a40d7 100644 --- a/lib/pry/extended_commands/experimental.rb +++ b/lib/pry/extended_commands/experimental.rb @@ -7,8 +7,16 @@ class Pry output.puts opts[:eval_string] end - command "power" do - instance_eval opts[:ni_arg_string] + command /rue-(\d)/, "Experimental amend-line, where the N in rue-N represents line to replace", :interpolate => false do |replacement_line| + replacement_line = "" if !replacement_line + input_array = opts[:eval_string].each_line.to_a + line_number = opts[:captures].first.to_i + input_array[line_number] = opts[:arg_string] + opts[:eval_string].replace input_array.join("\n") + end + + command /:(.*)/, "Experimental shell forwarder, forward all lines after ':' to shell" do + system(opts[:captures].first) end command "play-string", "Play a string as input" do