Permalink
Browse files

version 0.7.6, supercharged 'whereami' method, added AROUND parameter…

…. Improved rubinius support
  • Loading branch information...
1 parent 7fa5f47 commit f4d7e418af9446697e8a368db4e55f212f14a64b @banister committed Mar 26, 2011
Showing with 27 additions and 13 deletions.
  1. +5 −0 CHANGELOG
  2. +0 −3 README.markdown
  3. +1 −1 examples/example_basic.rb
  4. +17 −7 lib/pry/commands.rb
  5. +3 −1 lib/pry/hooks.rb
  6. +1 −1 lib/pry/version.rb
View
@@ -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)
View
@@ -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 @@ def hello
# Start pry session at top-level.
# The local variable `a` and the `hello` method will
# be accessible.
-pry
+binding.pry
View
@@ -158,26 +158,34 @@ class Commands < CommandBase
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 @@ class Commands < CommandBase
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
View
@@ -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,
View
@@ -1,3 +1,3 @@
class Pry
- VERSION = "0.7.2"
+ VERSION = "0.7.6"
end

0 comments on commit f4d7e41

Please sign in to comment.