diff --git a/lib/pry/default_commands/find_method.rb b/lib/pry/default_commands/find_method.rb index 5156ca69f..f7b9cf785 100644 --- a/lib/pry/default_commands/find_method.rb +++ b/lib/pry/default_commands/find_method.rb @@ -18,8 +18,8 @@ module DefaultCommands Use the `-n` switch (the default) to search for methods whose name matches the given regex. Use the `-c` switch to search for methods that contain the given code. - e.g find re Pry # find all methods whose name match /re/. Matches Pry#repl, etc. - e.g find -c 'output.puts' Pry # find all methods that contain the code: output.puts + e.g find re Pry # find all methods whose name match /re/ inside the Pry namespace. Matches Pry#repl, etc. + e.g find -c 'output.puts' Pry # find all methods that contain the code: output.puts inside the Pry namepsace. BANNER def setup diff --git a/lib/pry/default_commands/introspection.rb b/lib/pry/default_commands/introspection.rb index 8cf18610a..4c1764fad 100644 --- a/lib/pry/default_commands/introspection.rb +++ b/lib/pry/default_commands/introspection.rb @@ -67,7 +67,7 @@ def options(opt) end def process_module(name) - mod = Pry::WrappedModule.from_str(name) + mod = Pry::WrappedModule.from_str(name, target) if opts.present?(:all) all_modules(mod) @@ -187,8 +187,8 @@ def process description "Show the source for METH or CLASS. Aliases: $, show-method" banner <<-BANNER - Usage: show-method [OPTIONS] [METH|CLASS] - Aliases: $, show-source + Usage: show-source [OPTIONS] [METH|CLASS] + Aliases: $, show-method Show the source for method METH or CLASS. Tries instance methods first and then methods by default. @@ -227,7 +227,7 @@ def process_method end def process_module(name) - mod = Pry::WrappedModule.from_str(name) + mod = Pry::WrappedModule.from_str(name, target) if opts.present?(:all) all_modules(mod) diff --git a/lib/pry/wrapped_module.rb b/lib/pry/wrapped_module.rb index 407463dc7..2777681cf 100644 --- a/lib/pry/wrapped_module.rb +++ b/lib/pry/wrapped_module.rb @@ -26,7 +26,12 @@ class WrappedModule # @example # Pry::WrappedModule.from_str("Pry::Code") def self.from_str(mod_name, binding=TOPLEVEL_BINDING) - Pry::WrappedModule.new(binding.eval(mod_name)) + mod = binding.eval(mod_name) + if mod.is_a?(Module) + Pry::WrappedModule.new(mod) + else + nil + end rescue RescuableException nil end