diff --git a/CHANGELOG b/CHANGELOG index c9651385..1a3a0ace 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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
+ 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) diff --git a/README.markdown b/README.markdown index c4273204..50a57fb9 100644 --- a/README.markdown +++ b/README.markdown @@ -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 -------------------- diff --git a/examples/example_basic.rb b/examples/example_basic.rb index c326ef13..8f893be6 100644 --- a/examples/example_basic.rb +++ b/examples/example_basic.rb @@ -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 diff --git a/lib/pry/commands.rb b/lib/pry/commands.rb index 902af956..aefc0425 100644 --- a/lib/pry/commands.rb +++ b/lib/pry/commands.rb @@ -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 diff --git a/lib/pry/hooks.rb b/lib/pry/hooks.rb index f757a702..22baee90 100644 --- a/lib/pry/hooks.rb +++ b/lib/pry/hooks.rb @@ -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, diff --git a/lib/pry/version.rb b/lib/pry/version.rb index 75ab551f..900a7f19 100644 --- a/lib/pry/version.rb +++ b/lib/pry/version.rb @@ -1,3 +1,3 @@ class Pry - VERSION = "0.7.2" + VERSION = "0.7.6" end