diff --git a/lib/pry/default_commands/find_method.rb b/lib/pry/default_commands/find_method.rb index b6553ab1..bb7f6edd 100644 --- a/lib/pry/default_commands/find_method.rb +++ b/lib/pry/default_commands/find_method.rb @@ -3,10 +3,19 @@ class Pry FindMethod = Pry::CommandSet.new do create_command "find-method" do + extend Helpers::BaseHelpers + group "Context" + options :requires_gem => "ruby18_source_location" if mri_18? + description "Recursively search for a method within a Class/Module or the current namespace. find-method [-n | -c] METHOD [NAMESPACE]" + + def setup + require 'ruby18_source_location' if mri_18? + end + def options(opti) opti.on :n, :name, "Search for a method by name" opti.on :c, :content, "Search for a method based on content in Regex form" @@ -36,7 +45,7 @@ class Pry else puts text.bold("Methods Matched") puts "--" - puts to_put + stagger_output to_put.join("\n") end end @@ -67,7 +76,11 @@ class Pry end end klass.constants.each do |klazz| - meths += ((res = content_search(pattern, klass.const_get(klazz), current, the_methods)) ? res : []) + begin + meths += ((res = content_search(pattern, klass.const_get(klazz), current, the_methods)) ? res : []) + rescue Pry::RescuableException + next + end end return meths.uniq.flatten end diff --git a/lib/pry/helpers/base_helpers.rb b/lib/pry/helpers/base_helpers.rb index 2f374936..687dcc9f 100644 --- a/lib/pry/helpers/base_helpers.rb +++ b/lib/pry/helpers/base_helpers.rb @@ -110,6 +110,14 @@ class Pry RbConfig::CONFIG['ruby_install_name'] == 'rbx' end + def mri_18? + RUBY_VERSION =~ /1.8/ && RbConfig::CONFIG['ruby_install_name'] == 'ruby' + end + + def mri_19? + RUBY_VERSION =~ /1.9/ && RbConfig::CONFIG['ruby_install_name'] == 'ruby' + end + # a simple pager for systems without `less`. A la windows. def simple_pager(text, output=output()) text_array = text.lines.to_a @@ -138,7 +146,7 @@ class Pry # Sys. $stdout end - + if text.lines.count < page_size || !Pry.pager out.puts text return