1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

removed unnecessary pry_command? method from command_processor.rb. And removed #clear singleton method on val and eval_string, converted to #replace

This commit is contained in:
John Mair 2011-05-31 20:45:42 +12:00
parent 6a60955ec6
commit 9abb4db3e2
2 changed files with 5 additions and 19 deletions

View file

@ -16,14 +16,6 @@ class Pry
# @param [String] val The string passed in from the Pry prompt. # @param [String] val The string passed in from the Pry prompt.
# @return [Boolean] Whether the string is a valid command. # @return [Boolean] Whether the string is a valid command.
def valid_command?(val) def valid_command?(val)
pry_command?(val)
end
# Is the string a valid pry command?
# @param [String] val The string passed in from the Pry prompt.
# @return [Boolean] Whether the string is a valid Pry command.
def pry_command?(val)
!!(command_matched(val)[0]) !!(command_matched(val)[0])
end end
@ -48,7 +40,6 @@ class Pry
target.eval(dumped_str) target.eval(dumped_str)
end end
# Determine whether a Pry command was matched and return command data # Determine whether a Pry command was matched and return command data
# and argument string. # and argument string.
# This method should not need to be invoked directly. # This method should not need to be invoked directly.
@ -72,18 +63,13 @@ class Pry
# multi-line input. # multi-line input.
# @param [Binding] target The receiver of the commands. # @param [Binding] target The receiver of the commands.
def process_commands(val, eval_string, target) def process_commands(val, eval_string, target)
def val.clear() replace("") end
def eval_string.clear() replace("") end
# no command was matched, so return to caller
return if !pry_command?(val)
command, captures, pos = command_matched(val) command, captures, pos = command_matched(val)
# no command was matched, so return to caller
return if !command
val.replace interpolate_string(val, target) if command.options[:interpolate] val.replace interpolate_string(val, target) if command.options[:interpolate]
arg_string = val[pos..-1].strip arg_string = val[pos..-1].strip
args = arg_string ? Shellwords.shellwords(arg_string) : [] args = arg_string ? Shellwords.shellwords(arg_string) : []
options = { options = {
@ -121,7 +107,7 @@ class Pry
ret = commands.run_command(context, command, *args) ret = commands.run_command(context, command, *args)
# Tick, tock, im getting rid of this shit soon. # Tick, tock, im getting rid of this shit soon.
options[:val].clear options[:val].replace("")
ret ret
end end

View file

@ -5,7 +5,7 @@ class Pry
command "!", "Clear the input buffer. Useful if the parsing process goes wrong and you get stuck in the read loop." do command "!", "Clear the input buffer. Useful if the parsing process goes wrong and you get stuck in the read loop." do
output.puts "Input buffer cleared!" output.puts "Input buffer cleared!"
eval_string.clear eval_string.replace("")
end end
command "show-input", "Show the current eval_string" do command "show-input", "Show the current eval_string" do