diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-01-31 05:10:58 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-01-31 05:10:58 +0000 |
commit | d2bb8975e18ca089819145bf4b3c1c228973ce0d (patch) | |
tree | 0590c6ceae16c39c822a25c7bf8a3fabfdfd06f6 /lib/rdoc/ri/driver.rb | |
parent | ae8095e44dae9b440f07780d230d816f684a8f8a (diff) | |
download | ruby-d2bb8975e18ca089819145bf4b3c1c228973ce0d.tar.gz |
* lib/rdoc/ri/display.rb (display_method_list, display_class_list):
use @formatter.raw_print_line instead of puts.
* lib/rdoc/ri/driver.rb (select_methods): new method to collect all
instance/class methods which match with passed pattern.
* lib/rdoc/ri/driver.rb (run): use class_cache's result directly
instead of select_classes' because it's removed now.
* lib/rdoc/ri/driver.rb (run): search methods when passed name is not
class name. [ruby-core:15309]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc/ri/driver.rb')
-rw-r--r-- | lib/rdoc/ri/driver.rb | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/lib/rdoc/ri/driver.rb b/lib/rdoc/ri/driver.rb index 9afdf7b7bc..67817b1806 100644 --- a/lib/rdoc/ri/driver.rb +++ b/lib/rdoc/ri/driver.rb @@ -346,7 +346,7 @@ Options may also be set in the 'RI' environment variable. def run if @names.empty? then - @display.list_known_classes select_classes + @display.list_known_classes class_cache.keys.sort else @names.each do |name| case name @@ -371,17 +371,33 @@ Options may also be set in the 'RI' environment variable. if class_cache.key? name then display_class name else - @display.list_known_classes select_classes(/^#{name}/) + methods = select_methods(/^#{name}/) + if methods.size == 0 + abort "Nothing known about #{name}" + elsif methods.size == 1 + @display.display_method_info methods.first + else + @display.display_method_list methods + end end end end end end - def select_classes(pattern = nil) - classes = class_cache.keys.sort - classes = classes.grep pattern if pattern - classes + def select_methods(pattern) + methods = [] + class_cache.keys.sort.each do |klass| + class_cache[klass]["instance_methods"].map{|h|h["name"]}.grep(pattern) do |name| + method = load_cache_for(klass)[klass+'#'+name] + methods << method if method + end + class_cache[klass]["class_methods"].map{|h|h["name"]}.grep(pattern) do |name| + method = load_cache_for(klass)[klass+'::'+name] + methods << method if method + end + end + methods end def write_cache(cache, path) |