Skip to content

Commit

Permalink
Fixed a bug where searching ri for a non-existing class would display…
Browse files Browse the repository at this point in the history
… an error
  • Loading branch information
stcrocco committed Mar 6, 2015
1 parent 2bbe056 commit ea13956
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions plugins/ruberri/search.rb
@@ -1,32 +1,32 @@
=begin
Copyright (C) 2011 by Stefano Crocco
stefano.crocco@alice.it
This program is free software; you can redistribute it andor modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the
Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
=begin
Copyright (C) 2011 by Stefano Crocco
stefano.crocco@alice.it
This program is free software; you can redistribute it andor modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the
Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
=end

require 'yaml'
require 'rdoc/ri/driver'

module Ruber

module RI

class Search

def search text
drv = RDoc::RI::Driver.new
classes = find_classes drv, text
Expand All @@ -44,7 +44,7 @@ def search text
end
content
end

def prepare_class_list classes
found = {:type => :class}
list = []
Expand All @@ -60,7 +60,7 @@ def prepare_class_list classes
found[:list] = list
found
end

def prepare_method_list methods
found = {:type => :method}
list = []
Expand All @@ -80,7 +80,7 @@ def prepare_method_list methods
def find_classes drv, name
begin cls = drv.expand_class(Regexp.quote(name))
rescue RDoc::RI::Driver::NotFoundError
return
return []
end
stores = drv.classes[cls]
return unless stores
Expand All @@ -90,7 +90,7 @@ def find_classes drv, name
end
classes
end

def find_methods drv, name
found = drv.load_methods_matching name
return nil if found.empty?
Expand All @@ -101,11 +101,11 @@ def find_methods drv, name
end
methods.empty? ? nil : methods
end

end

end

end

puts YAML.dump(Ruber::RI::Search.new.search(ARGV[0] || ''))

0 comments on commit ea13956

Please sign in to comment.