2012-08-11 20:22:29 -04:00
|
|
|
class Pry
|
2012-12-25 16:35:17 -05:00
|
|
|
class Command::Stat < Pry::ClassCommand
|
|
|
|
match 'stat'
|
2012-08-11 21:26:59 -04:00
|
|
|
group 'Introspection'
|
2012-12-25 16:35:17 -05:00
|
|
|
description 'View method information and set _file_ and _dir_ locals.'
|
2012-08-11 21:26:59 -04:00
|
|
|
command_options :shellwords => false
|
|
|
|
|
2013-01-09 15:23:19 -05:00
|
|
|
banner <<-'BANNER'
|
2012-08-11 20:22:29 -04:00
|
|
|
Usage: stat [OPTIONS] [METH]
|
2013-01-09 15:23:19 -05:00
|
|
|
|
2012-08-11 20:22:29 -04:00
|
|
|
Show method information for method METH and set _file_ and _dir_ locals.
|
2013-01-09 15:23:19 -05:00
|
|
|
|
|
|
|
stat hello_method
|
2012-08-11 20:22:29 -04:00
|
|
|
BANNER
|
|
|
|
|
|
|
|
def options(opt)
|
|
|
|
method_options(opt)
|
|
|
|
end
|
|
|
|
|
|
|
|
def process
|
|
|
|
meth = method_object
|
2012-08-29 04:23:29 -04:00
|
|
|
aliases = meth.aliases
|
|
|
|
|
2012-08-11 20:22:29 -04:00
|
|
|
output.puts unindent <<-EOS
|
|
|
|
Method Information:
|
|
|
|
--
|
|
|
|
Name: #{meth.name}
|
2012-08-29 04:23:29 -04:00
|
|
|
Alias#{ "es" if aliases.length > 1 }: #{ aliases.any? ? aliases.join(", ") : "None." }
|
2012-08-11 20:22:29 -04:00
|
|
|
Owner: #{meth.owner ? meth.owner : "Unknown"}
|
|
|
|
Visibility: #{meth.visibility}
|
|
|
|
Type: #{meth.is_a?(::Method) ? "Bound" : "Unbound"}
|
|
|
|
Arity: #{meth.arity}
|
|
|
|
Method Signature: #{meth.signature}
|
|
|
|
Source Location: #{meth.source_location ? meth.source_location.join(":") : "Not found."}
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
end
|
2012-12-25 16:35:17 -05:00
|
|
|
|
|
|
|
Pry::Commands.add_command(Pry::Command::Stat)
|
2012-08-11 20:22:29 -04:00
|
|
|
end
|