Skip to content

Commit

Permalink
version 0.4.5 fixed show_method command
Browse files Browse the repository at this point in the history
  • Loading branch information
banister committed Jan 27, 2011
1 parent d890d7b commit d0cf3ef
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
@@ -1,3 +1,6 @@
27/1/2010 version 0.4.5
* fixed show_method (though fragile as it references __binding_impl__
directly, making a name change to that method difficult
27/1/2010 version 0.4.4
* oops, added examples/ directory
26/1/2010 version 0.4.3
Expand Down
20 changes: 12 additions & 8 deletions lib/pry/commands.rb
Expand Up @@ -76,18 +76,22 @@ class Commands < CommandBase
end

command "show_method", "Show sourcecode for method <methname>." do |meth_name|
if meth_name
meth_name = target.eval("__method__").to_s if !meth_name
doc = target.eval("method(\"#{meth_name}\")").source
output.puts doc
else
output.puts "Error: Not in a method."
context_meth_name = target.eval("__method__")
meth_name = context_meth_name if !meth_name

# fragile as it hard-codes in the __binding_impl__ method name
# from core_extensions.rb
if meth_name && meth_name != :__binding_impl__
code = target.eval("method(\"#{meth_name.to_s}\")").source
output.puts code
next
end
output.puts "Error: Not in a method."
end

command "show_imethod", "Show sourcecode for instance method <methname>." do |meth_name|
doc = target.eval("instance_method(\"#{meth_name}\")").source
output.puts doc
code = target.eval("instance_method(\"#{meth_name}\")").source
output.puts code
end

command "jump_to", "Jump to a Pry session further up the stack, exiting all sessions below." do |break_level|
Expand Down
2 changes: 1 addition & 1 deletion lib/pry/version.rb
@@ -1,3 +1,3 @@
class Pry
VERSION = "0.4.4"
VERSION = "0.4.5"
end

0 comments on commit d0cf3ef

Please sign in to comment.