mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
version 0.7.6, supercharged 'whereami' method, added AROUND parameter. Improved rubinius support
This commit is contained in:
parent
7fa5f47693
commit
f4d7e418af
6 changed files with 27 additions and 13 deletions
|
@ -1,3 +1,8 @@
|
|||
26/3/2011 version 0.7.6
|
||||
* `whereami` command now accepts parameter AROUND, to display AROUND lines on eitherside of invocation line.
|
||||
* made it so `whereami` is invoked even if no method exists in current context (i.e in rspec tests)
|
||||
* added rubinius support for `whereami` invocation in HOOKS by checking for __unknown__.rb rather than just <main>
|
||||
|
||||
15/3/2011 version 0.7.0
|
||||
* add pry-doc support with syntax highlighting for docs
|
||||
* add 'mj' option to ls (restrict to singleton methods)
|
||||
|
|
|
@ -269,9 +269,6 @@ If you want to access a method of the same name, prefix the invocation by whites
|
|||
* `jump-to NEST_LEVEL` Unwinds the Pry stack (nesting level) until the appropriate nesting level is reached.
|
||||
* `exit-all` breaks out of all Pry nesting levels and returns to the
|
||||
calling process.
|
||||
* You can type `Pry.start(obj)` or `obj.pry` to nest another Pry session within the
|
||||
current one with `obj` as the receiver of the new session. Very useful
|
||||
when exploring large or complicated runtime state.
|
||||
|
||||
Syntax Highlighting
|
||||
--------------------
|
||||
|
|
|
@ -14,4 +14,4 @@ end
|
|||
# Start pry session at top-level.
|
||||
# The local variable `a` and the `hello` method will
|
||||
# be accessible.
|
||||
pry
|
||||
binding.pry
|
||||
|
|
|
@ -158,26 +158,34 @@ class Pry
|
|||
output.puts "Last result: #{Pry.view(Pry.last_result)}"
|
||||
end
|
||||
|
||||
command "whereami", "Show the code context for the session." do
|
||||
command "whereami", "Show the code context for the session. Shows AROUND lines around the invocation line. AROUND defaults to 5 lines. " do |num|
|
||||
file = target.eval('__FILE__')
|
||||
line_num = target.eval('__LINE__')
|
||||
klass = target.eval('self.class')
|
||||
|
||||
if num
|
||||
i_num = num.to_i
|
||||
else
|
||||
i_num = 5
|
||||
end
|
||||
|
||||
meth_name = meth_name_from_binding.call(target)
|
||||
if !meth_name
|
||||
output.puts "Cannot find containing method. Did you remember to use \`binding.pry\` ?"
|
||||
meth_name = "N/A" if !meth_name
|
||||
|
||||
# FIX ME!!! this line is screwed
|
||||
# check_for_dynamically_defined_method.call()
|
||||
if file =~ /(\(.*\))|<.*>/
|
||||
output.puts "Cannot find local context."
|
||||
next
|
||||
end
|
||||
|
||||
check_for_dynamically_defined_method.call(file)
|
||||
|
||||
output.puts "--\nFrom #{file} @ line #{line_num} in #{klass}##{meth_name}:\n--"
|
||||
|
||||
# This method inspired by http://rubygems.org/gems/ir_b
|
||||
File.open(file).each_with_index do |line, index|
|
||||
line_n = index + 1
|
||||
next unless line_n > (line_num - 6)
|
||||
break if line_n > (line_num + 5)
|
||||
next unless line_n > (line_num - i_num - 1)
|
||||
break if line_n > (line_num + i_num)
|
||||
if line_n == line_num
|
||||
code =" =>#{line_n.to_s.rjust(3)}: #{line.chomp}"
|
||||
if Pry.color
|
||||
|
@ -557,6 +565,8 @@ e.g: show-method hello_method
|
|||
|
||||
next if options[:h]
|
||||
|
||||
meth_name = meth_name_from_binding.call(target) if !meth_name
|
||||
|
||||
if (meth = get_method_object.call(meth_name, target, options)).nil?
|
||||
output.puts "Invalid method name: #{meth_name}. Type `show-method --help` for help"
|
||||
next
|
||||
|
|
|
@ -9,7 +9,9 @@ class Pry
|
|||
# ensure we're actually in a method
|
||||
meth_name = target.eval('__method__')
|
||||
file = target.eval('__FILE__')
|
||||
if ![:__script__, nil, :__binding__, :__binding_impl__].include?(meth_name) && file !~ /(\(.*\))|<.*>/
|
||||
|
||||
# /unknown/ for rbx
|
||||
if file !~ /(\(.*\))|<.*>/ && file !~ /__unknown__/
|
||||
Pry.run_command "whereami", :output => out, :show_output => true, :context => target, :commands => Pry::Commands
|
||||
end
|
||||
end,
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
class Pry
|
||||
VERSION = "0.7.2"
|
||||
VERSION = "0.7.6"
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue