version bump 0.3.0, added method_doc and friends, added cat, updated README, adjusted Rakefile to use 0.2.0 method_source gem

This commit is contained in:
John Mair 2010-12-19 00:21:58 +13:00
parent 6491b0454f
commit d2009e6de1
5 changed files with 38 additions and 13 deletions

View File

@ -144,8 +144,8 @@ end.
* Pry sessions can nest arbitrarily deeply -- to go back one level of nesting type 'exit' or 'quit' or 'back'
* Use `_` to recover last result.
* Pry has multi-line support built in.
* Pry has unique commands not found in any other REPL: `show_method`,
`jump_to`, `ls`, `cd`
* Pry has unique commands not found in any other REPL: `show_method`, `method_doc`
`jump_to`, `ls`, `cd`, `cat`
* Pry gives good control over nested sessions (important when exploring complicated runtime state)
* Pry is not based on the IRB codebase.
* Pry uses [RubyParser](https://github.com/seattlerb/ruby_parser) to
@ -202,11 +202,15 @@ If you want to access a method of the same name, prefix the invocation by whites
are nested sessions).
* `ls` returns a list of local variables and instance variables in the
current scope
* `cat <var>` calls `inspect` on `<var>`
* `cd <var>` starts a `Pry` session on the variable <var>. E.g `cd @x`
* `show_method <methname>` Displays the sourcecode for the method
<methname>. E.g `show_method hello`
* `show_instance_method <methname>` Displays the sourcecode for the
instance method <methname>. E.g `show_instance_method goodbye`
* `method_doc <methname>` Displays comments for `<methname>`
* `instance_method_doc <methname>` Displays comments for instance
method `<methname>`
* `exit_program` or `quit_program` will end the currently running
program.
* `nesting` shows Pry nesting information.

View File

@ -20,7 +20,7 @@ def apply_spec_defaults(s)
s.description = s.summary
s.require_path = 'lib'
s.add_dependency("ruby_parser",">=2.0.5")
s.add_dependency("method_source",">=0.1.4")
s.add_dependency("method_source",">=0.2.0")
s.homepage = "http://banisterfiend.wordpress.com"
s.has_rdoc = 'yard'
s.files = Dir["ext/**/extconf.rb", "ext/**/*.h", "ext/**/*.c", "lib/**/*.rb",

View File

@ -3,8 +3,7 @@
direc = File.dirname(__FILE__)
require 'ruby_parser'
require 'method_source'
require "method_source"
require "#{direc}/pry/version"
require "#{direc}/pry/input"
require "#{direc}/pry/output"
@ -158,18 +157,32 @@ class Pry
when "ls"
output.ls(target)
eval_string.clear
when /^cat\s+(.+)/
var = $~.captures.first
output.cat(target, var)
eval_string.clear
when /^cd\s+(.+)/
obj = $~.captures.first
target.eval("#{obj}.pry")
eval_string.clear
when /^method_doc\s*(.+)/
meth_name = ($~.captures).first
doc = target.eval("method(:#{meth_name})").comment
output.show_doc doc
eval_string.clear
when /^instance_method_doc\s*(.+)/
meth_name = ($~.captures).first
doc = target.eval("instance_method(:#{meth_name})").comment
output.show_doc doc
eval_string.clear
when /^show_method\s*(.+)/
meth_name = ($~.captures).first
code = get_method_source(target, meth_name, :method)
code = target.eval("method(:#{meth_name})").source
output.show_method code
eval_string.clear
when /^show_instance_method\s*(.+)/
meth_name = ($~.captures).first
code = get_method_source(target, meth_name, :instance_method)
code = target.eval("instance_method(:#{meth_name})").source
output.show_method code
eval_string.clear
when /^jump_to\s*(\d*)/
@ -190,10 +203,6 @@ class Pry
end
end
def get_method_source(target, meth_name, kind)
target.eval("#{kind}(:#{meth_name}).source")
end
def prompt(eval_string, target, nest)
target_self = target.eval('self')
@ -212,6 +221,7 @@ class Pry
end
else
require 'ruby_parser'
def valid_expression?(code)
RubyParser.new.parse(code)

View File

@ -30,9 +30,12 @@ class Pry
puts "! Refresh the REPL"
puts "nesting Show nesting information"
puts "ls Show the list of variables in the current scope"
puts "cat <var> Show output of <var>.inspect"
puts "cd <var> Start a Pry session on <var> (use `cd ..` to go back)"
puts "show_method <methname> Show the sourcecode for the method <method_name>"
puts "show_method <methname> Show the sourcecode for the method <methname>"
puts "show_instance_method <methname> Show the sourcecode for the instance method <method_name>"
puts "method_doc <methname> Show the comments above <methname>"
puts "instance_method_doc <methname> Show the comments above instance method <methname>"
puts "exit/quit/back End the current Pry session"
puts "exit_all End all nested Pry sessions"
puts "exit_program/quit_program End the current program"
@ -63,11 +66,19 @@ class Pry
def ls(target)
puts "#{target.eval('Pry.view(local_variables + instance_variables)')}"
end
def cat(target, var)
puts target.eval("#{var}.inspect")
end
def show_method(code)
code.display
end
def show_doc(doc)
doc.display
end
def warn_already_at_level(nesting_level)
puts "Already at nesting level #{nesting_level}"
end

View File

@ -1,3 +1,3 @@
class Pry
VERSION = "0.2.8"
VERSION = "0.3.0"
end