Method: RDoc::Servlet#store_for

Defined in:
lib/rdoc/servlet.rb

#store_for(source_name) ⇒ Object

Returns an RDoc::Store for the given source_name (‘ruby’ or a gem name).



419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
# File 'lib/rdoc/servlet.rb', line 419

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