mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
fix the failing Pry#prompt specs.
this is a strange and odd case. Pry.prompt is a delegate to Pry.config, as it has always been. the same delegate was setup on an instance of Pry, but never used because we define #prompt and #prompt= with our implementation. the thing that would make the most sense (to me) is to not support Pry.prompt anymore and recommend the use of Pry.config.prompt instead. a lot of code relies on Pry.prompt though, so we have to support the delegate to config and implement custom behavior for the pry instance.
This commit is contained in:
parent
eab4241ff6
commit
325016eb3a
3 changed files with 29 additions and 1 deletions
|
@ -3,7 +3,6 @@ module Pry::Config::Convenience
|
||||||
:input,
|
:input,
|
||||||
:output,
|
:output,
|
||||||
:commands,
|
:commands,
|
||||||
:prompt,
|
|
||||||
:print,
|
:print,
|
||||||
:exception_handler,
|
:exception_handler,
|
||||||
:quiet?,
|
:quiet?,
|
||||||
|
|
|
@ -20,6 +20,14 @@ class Pry
|
||||||
|
|
||||||
extend Pry::Config::Convenience
|
extend Pry::Config::Convenience
|
||||||
config_shortcut *Pry::Config.shortcuts
|
config_shortcut *Pry::Config.shortcuts
|
||||||
|
|
||||||
|
def prompt=(value)
|
||||||
|
config.prompt = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def prompt
|
||||||
|
config.prompt
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.main
|
def self.main
|
||||||
|
|
|
@ -69,6 +69,7 @@ class Pry
|
||||||
@backtrace = options[:backtrace] || caller
|
@backtrace = options[:backtrace] || caller
|
||||||
@config = Pry::Config.new
|
@config = Pry::Config.new
|
||||||
@config.merge!(options)
|
@config.merge!(options)
|
||||||
|
push_prompt(config.prompt)
|
||||||
@input_array = Pry::HistoryArray.new config.memory_size
|
@input_array = Pry::HistoryArray.new config.memory_size
|
||||||
@output_array = Pry::HistoryArray.new config.memory_size
|
@output_array = Pry::HistoryArray.new config.memory_size
|
||||||
@custom_completions = config.command_completer
|
@custom_completions = config.command_completer
|
||||||
|
@ -78,6 +79,26 @@ class Pry
|
||||||
exec_hook(:when_started, options[:target], options, self)
|
exec_hook(:when_started, options[:target], options, self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# The current prompt.
|
||||||
|
# This is the prompt at the top of the prompt stack.
|
||||||
|
#
|
||||||
|
# @example
|
||||||
|
# self.prompt = Pry::SIMPLE_PROMPT
|
||||||
|
# self.prompt # => Pry::SIMPLE_PROMPT
|
||||||
|
#
|
||||||
|
# @return [Array<Proc>] Current prompt.
|
||||||
|
def prompt
|
||||||
|
prompt_stack.last
|
||||||
|
end
|
||||||
|
|
||||||
|
def prompt=(new_prompt)
|
||||||
|
if prompt_stack.empty?
|
||||||
|
push_prompt new_prompt
|
||||||
|
else
|
||||||
|
prompt_stack[-1] = new_prompt
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Initialize this instance by pushing its initial context into the binding
|
# Initialize this instance by pushing its initial context into the binding
|
||||||
# stack. If no target is given, start at the top level.
|
# stack. If no target is given, start at the top level.
|
||||||
def push_initial_binding(target=nil)
|
def push_initial_binding(target=nil)
|
||||||
|
|
Loading…
Add table
Reference in a new issue