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

use prompt proc arity instead of to_ary. God this is boring

This commit is contained in:
John Mair 2012-07-13 03:52:55 +12:00
parent 8fd91ec8f2
commit 6214161672
2 changed files with 12 additions and 3 deletions

View file

@ -44,7 +44,7 @@ task :default => [:test]
desc "Run tests"
task :test do
check_dependencies unless ENV['SKIP_DEP_CHECK']
sh "bacon -Itest -rubygems -a -q"
sh "bacon -Itest -rubygems"
end
desc "Run pry"

View file

@ -645,14 +645,23 @@ class Pry
# If input buffer is empty then use normal prompt
if eval_string.empty?
Array(prompt).first.call(c)
generate_prompt(Array(prompt).first, c)
# Otherwise use the wait prompt (indicating multi-line expression)
else
Array(prompt).last.call(c)
generate_prompt(Array(prompt).last, c)
end
end
def generate_prompt(prompt_proc, conf)
if prompt_proc.arity == 1
prompt_proc.call(conf)
else
prompt_proc.call(conf.object, conf.nesting_level, conf._pry_)
end
end
private :generate_prompt
# the array that the prompt stack is stored in
def prompt_stack
@prompt_stack ||= Array.new