mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
combined default_prompt and wait_prompt into one prompt array called default_prompt; added ls_methods and ls_imethods commands, version bump to 0.4.0
This commit is contained in:
parent
7135d5179e
commit
47d34790e7
4 changed files with 37 additions and 27 deletions
|
@ -85,6 +85,14 @@ class Pry
|
|||
out.puts "Invalid nest level. Must be between 0 and #{max_nest_level}. Got #{break_level}."
|
||||
opts[:eval_string].clear
|
||||
end
|
||||
end,
|
||||
"ls_methods" => proc do |opts|
|
||||
out.puts "#{Pry.view(opts[:target].eval('public_methods(false)'))}"
|
||||
opts[:eval_string].clear
|
||||
end,
|
||||
"ls_imethods" => proc do |opts|
|
||||
out.puts "#{Pry.view(opts[:target].eval('public_instance_methods(false)'))}"
|
||||
opts[:eval_string].clear
|
||||
end
|
||||
}
|
||||
end
|
||||
|
@ -105,7 +113,9 @@ class Pry
|
|||
"show_idoc" => "Show the comments above instance method <methname>",
|
||||
"show_method" => "Show sourcecode for method <methname>",
|
||||
"show_imethod" => "Show sourcecode for instance method <methname>",
|
||||
"jump_to" => "Jump to a Pry session further up the stack, exiting all sessions below."
|
||||
"jump_to" => "Jump to a Pry session further up the stack, exiting all sessions below.",
|
||||
"ls_methods" => "List public methods defined on class of receiver.",
|
||||
"ls_imethods" => "List public instance methods defined on receiver."
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -143,7 +153,7 @@ class Pry
|
|||
out.puts "--"
|
||||
out.puts "Receiver: #{Pry.view(target.eval('self'))}"
|
||||
out.puts "Nesting level: #{nesting.level}"
|
||||
out.puts "Local variables: #{target.eval('Pry.view(local_variables)')}"
|
||||
out.puts "Local variables: #{Pry.view(target.eval('local_variables'))}"
|
||||
out.puts "Pry instance: #{Pry.active_instance}"
|
||||
out.puts "Last result: #{Pry.view(Pry.last_result)}"
|
||||
end
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
class Pry
|
||||
DEFAULT_PROMPT = proc do |v, nest|
|
||||
if nest == 0
|
||||
"pry(#{Pry.view(v)})> "
|
||||
else
|
||||
"pry(#{Pry.view(v)}):#{Pry.view(nest)}> "
|
||||
end
|
||||
end
|
||||
|
||||
WAIT_PROMPT = proc do |v, nest|
|
||||
if nest == 0
|
||||
"pry(#{Pry.view(v)})* "
|
||||
else
|
||||
"pry(#{Pry.view(v)}):#{Pry.view(nest)}* "
|
||||
end
|
||||
end
|
||||
DEFAULT_PROMPT = [
|
||||
proc do |v, nest|
|
||||
if nest == 0
|
||||
"pry(#{Pry.view(v)})> "
|
||||
else
|
||||
"pry(#{Pry.view(v)}):#{Pry.view(nest)}> "
|
||||
end
|
||||
end,
|
||||
|
||||
proc do |v, nest|
|
||||
if nest == 0
|
||||
"pry(#{Pry.view(v)})* "
|
||||
else
|
||||
"pry(#{Pry.view(v)}):#{Pry.view(nest)}* "
|
||||
end
|
||||
end
|
||||
]
|
||||
|
||||
SIMPLE_PROMPT = proc { "pry> " }
|
||||
SIMPLE_WAIT = proc { "pry* " }
|
||||
SIMPLE_PROMPT = [proc { "pry> " }, proc { "pry* " }]
|
||||
end
|
||||
|
|
|
@ -6,7 +6,7 @@ class Pry
|
|||
attr_accessor :last_result, :active_instance
|
||||
attr_accessor :input, :output
|
||||
attr_accessor :commands, :print, :hooks
|
||||
attr_accessor :default_prompt, :wait_prompt
|
||||
attr_accessor :default_prompt
|
||||
end
|
||||
|
||||
def self.start(target=TOPLEVEL_BINDING, options={})
|
||||
|
@ -15,7 +15,7 @@ class Pry
|
|||
|
||||
def self.view(obj)
|
||||
case obj
|
||||
when String, Array, Hash, Symbol, nil
|
||||
when String, Hash, Array, Symbol, nil
|
||||
obj.inspect
|
||||
else
|
||||
obj.to_s
|
||||
|
@ -27,7 +27,6 @@ class Pry
|
|||
@output = Output.new
|
||||
@commands = Commands.new(@output)
|
||||
@default_prompt = DEFAULT_PROMPT
|
||||
@wait_prompt = WAIT_PROMPT
|
||||
@print = DEFAULT_PRINT
|
||||
@hooks = DEFAULT_HOOKS
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
class Pry
|
||||
|
||||
ConfigOptions = [:input, :output, :commands, :print,
|
||||
:default_prompt, :wait_prompt, :hooks]
|
||||
:default_prompt, :hooks]
|
||||
|
||||
attr_accessor *ConfigOptions
|
||||
|
||||
|
@ -35,7 +35,7 @@ class Pry
|
|||
Pry.active_instance = self
|
||||
|
||||
# Make sure special locals exist
|
||||
target.eval("__pry__ = Pry.active_instance")
|
||||
target.eval("_pry_ = Pry.active_instance")
|
||||
target.eval("_ = Pry.last_result")
|
||||
|
||||
break_level = catch(:breakout) do
|
||||
|
@ -67,7 +67,7 @@ class Pry
|
|||
target = binding_for(target)
|
||||
Pry.last_result = target.eval r(target)
|
||||
Pry.active_instance = self
|
||||
target.eval("__pry__ = Pry.active_instance")
|
||||
target.eval("_pry_ = Pry.active_instance")
|
||||
target.eval("_ = Pry.last_result")
|
||||
rescue SystemExit => e
|
||||
exit
|
||||
|
@ -111,9 +111,9 @@ class Pry
|
|||
target_self = target.eval('self')
|
||||
|
||||
if eval_string.empty?
|
||||
default_prompt.call(target_self, nest)
|
||||
default_prompt.first.call(target_self, nest)
|
||||
else
|
||||
wait_prompt.call(target_self, nest)
|
||||
default_prompt.last.call(target_self, nest)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue