class RDoc::Servlet

def store_for source_name

def store_for source_name
  case source_name
  when 'home' then
    RDoc::Store.new RDoc::RI::Paths.home_dir, :home
  when 'ruby' then
    RDoc::Store.new RDoc::RI::Paths.system_dir, :system
  when 'site' then
    RDoc::Store.new RDoc::RI::Paths.site_dir, :site
  when /\Aextra-(\d+)\z/ then
    index = $1.to_i - 1
    ri_dir = installed_docs[index][4]
    RDoc::Store.new ri_dir, :extra
  else
    ri_dir, type = ri_paths.find do |dir, dir_type|
      next unless dir_type == :gem
      source_name == dir[%r%/([^/]*)/ri$%, 1]
    end
    raise WEBrick::HTTPStatus::NotFound,
          "Could not find gem \"#{ERB::Util.html_escape(source_name)}\". Are you sure you installed it?" unless ri_dir
    store = RDoc::Store.new ri_dir, type
    return store if File.exist? store.cache_path
    raise WEBrick::HTTPStatus::NotFound,
          "Could not find documentation for \"#{ERB::Util.html_escape(source_name)}\". Please run `gem rdoc --ri gem_name`"
  end
end