### Home Classes Methods

### In Files

- lib/rdoc/ri/paths.rb

### Methods

- ::each
- ::gem_dir
- ::gemdirs
- ::home_dir
- ::path
- ::raw_path
- ::site_dir
- ::system_dir

### Files

- CONTRIBUTING.rdoc
- CVE-2013-0256.rdoc
- ExampleRDoc.rdoc
- LICENSE.rdoc
- Manifest.txt
- README.rdoc
- RI.rdoc
- Rakefile
- TODO.rdoc

### Class/Module Index

Quicksearch

- RDoc
- RDoc::Alias
- RDoc::AnonClass
- RDoc::AnyMethod
- RDoc::Attr
- RDoc::ClassModule
- RDoc::CodeObject
- RDoc::Comment
- RDoc::Constant
- RDoc::Context
- RDoc::Context::Section
- RDoc::CrossReference
- RDoc::ERBIO
- RDoc::ERBPartial
- RDoc::Encoding
- RDoc::Error
- RDoc::Extend
- RDoc::Gauntlet
- RDoc::Generator
- RDoc::Generator::Darkfish
- RDoc::Generator::JsonIndex
- RDoc::Generator::Markup
- RDoc::Generator::RI
- RDoc::GhostMethod
- RDoc::Include
- RDoc::Markdown
- RDoc::Markdown::Literals
- RDoc::Markup
- RDoc::Markup::AttrChanger
- RDoc::Markup::AttrSpan
- RDoc::Markup::AttributeManager
- RDoc::Markup::Attributes
- RDoc::Markup::BlankLine
- RDoc::Markup::BlockQuote
- RDoc::Markup::Document
- RDoc::Markup::Formatter
- RDoc::Markup::FormatterTestCase
- RDoc::Markup::HardBreak
- RDoc::Markup::Include
- RDoc::Markup::IndentedParagraph
- RDoc::Markup::List
- RDoc::Markup::ListItem
- RDoc::Markup::Paragraph
- RDoc::Markup::Parser
- RDoc::Markup::Parser::Error
- RDoc::Markup::Parser::ParseError
- RDoc::Markup::PreProcess
- RDoc::Markup::Raw
- RDoc::Markup::Rule
- RDoc::Markup::Special
- RDoc::Markup::TextFormatterTestCase
- RDoc::Markup::ToAnsi
- RDoc::Markup::ToBs
- RDoc::Markup::ToHtml
- RDoc::Markup::ToHtmlCrossref
- RDoc::Markup::ToHtmlSnippet
- RDoc::Markup::ToJoinedParagraph
- RDoc::Markup::ToLabel
- RDoc::Markup::ToMarkdown
- RDoc::Markup::ToRdoc
- RDoc::Markup::ToTableOfContents
- RDoc::Markup::ToTest
- RDoc::Markup::ToTtOnly
- RDoc::Markup::Verbatim
- RDoc::MetaMethod
- RDoc::MethodAttr
- RDoc::Mixin
- RDoc::NormalClass
- RDoc::NormalModule
- RDoc::Options
- RDoc::Parser
- RDoc::Parser::C
- RDoc::Parser::ChangeLog
- RDoc::Parser::Markdown
- RDoc::Parser::RD
- RDoc::Parser::Ruby
- RDoc::Parser::RubyTools
- RDoc::Parser::Simple
- RDoc::Parser::Text
- RDoc::RD
- RDoc::RD::BlockParser
- RDoc::RD::Inline
- RDoc::RD::InlineParser
- RDoc::RDoc
- RDoc::RI
- RDoc::RI::Driver
- RDoc::RI::Driver::Error
- RDoc::RI::Driver::NotFoundError
- RDoc::RI::Error
- RDoc::RI::Paths
- RDoc::Require
- RDoc::RubyLex
- RDoc::RubyLex::Error
- RDoc::RubyToken
- RDoc::RubygemsHook
- RDoc::Servlet
- RDoc::SingleClass
- RDoc::Stats
- RDoc::Stats::Normal
- RDoc::Stats::Quiet
- RDoc::Stats::Verbose
- RDoc::Store
- RDoc::Store::Error
- RDoc::Store::MissingFileError
- RDoc::Task
- RDoc::Task
- RDoc::TestCase
- RDoc::TokenStream
- RDoc::TomDoc
- RDoc::TopLevel
- Object

No matching classes.

# RDoc::RI::Paths

The directories where ri data lives. Paths can be enumerated via ::each, or queried individually via ::system_dir, ::site_dir, ::home_dir and ::gem_dir.

### Public Class Methods

each(system = true, site = true, home = true, gems = :latest, *extra_dirs) click to toggle source

Iterates over each selected path yielding the directory and type.

Yielded types:

:system | Where Ruby's ri data is stored. Yielded when `system` is true
:site | Where ri for installed libraries are stored. Yielded when `site` is true. Normally no ri data is stored here.
:home | ~/.rdoc. Yielded when `home` is true.
:gem | ri data for an installed gem. Yielded when `gems` is true.
:extra | ri data directory from the command line. Yielded for each entry in `extra_dirs`

    # File lib/rdoc/ri/paths.rb, line 46
    def self.each system = true, site = true, home = true, gems = :latest, *extra_dirs # :yields: directory, type
      return enum_for __method__, system, site, home, gems, *extra_dirs unless
        block_given?

      extra_dirs.each do |dir|
        yield dir, :extra
      end

      yield system_dir,  :system if system
      yield site_dir,    :site   if site
      yield home_dir,    :home   if home and HOMEDIR

      gemdirs(gems).each do |dir|
        yield dir, :gem
      end if gems

      nil
    end

gem_dir(name, version) click to toggle source

The ri directory for the gem with `gem_name`.

    # File lib/rdoc/ri/paths.rb, line 68
    def self.gem_dir name, version
      req = Gem::Requirement.new "= #{version}"

      spec = Gem::Specification.find_by_name name, req

      File.join spec.doc_dir, 'ri'
    end

gemdirs(filter = :latest) click to toggle source

The latest installed gems' ri directories. `filter` can be :all or :latest.

A `filter` :all includes all versions of gems and includes gems without ri documentation.

    # File lib/rdoc/ri/paths.rb, line 83
    def self.gemdirs filter = :latest
      require 'rubygems' unless defined?(Gem)

      ri_paths = {}

      all = Gem::Specification.map do |spec|
        [File.join(spec.doc_dir, 'ri'), spec.name, spec.version]
      end

      if filter == :all then
        gemdirs = []

        all.group_by do |_, name, _|
          name
        end.sort_by do |group, _|
          group
        end.map do |group, items|
          items.sort_by do |_, _, version|
            version
          end.reverse_each do |dir,|
            gemdirs << dir
          end
        end

        return gemdirs
      end

      all.each do |dir, name, ver|
        next unless File.exist? dir

        if ri_paths[name].nil? or ver > ri_paths[name].first then
          ri_paths[name] = [ver, name, dir]
        end
      end

      ri_paths.sort_by { |_, (_, name, _)| name }.map { |k, v| v.last }
    rescue LoadError
      []
    end

home_dir() click to toggle source

The location of the rdoc data in the user's home directory.

Like ::system, ri data in the user's home directory is rare and predates libraries distributed via RubyGems. ri data is rarely generated into this directory.

    # File lib/rdoc/ri/paths.rb, line 130
    def self.home_dir
      HOMEDIR
    end

path(system = true, site = true, home = true, gems = :latest, *extra_dirs) click to toggle source

Returns existing directories from the selected documentation directories as an Array.

See also ::each

    # File lib/rdoc/ri/paths.rb, line 140
    def self.path(system = true, site = true, home = true, gems = :latest, *extra_dirs)
      path = raw_path system, site, home, gems, *extra_dirs

      path.select { |directory| File.directory? directory }
    end

raw_path(system, site, home, gems, *extra_dirs) click to toggle source

Returns selected documentation directories including nonexistent directories.

See also ::each

    # File lib/rdoc/ri/paths.rb, line 152
    def self.raw_path(system, site, home, gems, *extra_dirs)
      path = []

      each(system, site, home, gems, *extra_dirs) do |dir, type|
        path << dir
      end

      path.compact
    end

site_dir() click to toggle source

The location of ri data installed into the site dir.

Historically this was available for documentation installed by Ruby libraries predating RubyGems. It is unlikely to contain any content for modern Ruby installations.

    # File lib/rdoc/ri/paths.rb, line 169
    def self.site_dir
      File.join BASE, 'site'
    end

system_dir() click to toggle source

The location of the built-in ri data.

This data is built automatically when `make` is run when Ruby is installed. If you did not install Ruby by hand you may need to install the documentation yourself. Please consult the documentation for your package manager or Ruby installer for details. You can also use the rdoc-data gem to install system ri data for common versions of Ruby.

    # File lib/rdoc/ri/paths.rb, line 182
    def self.system_dir
      File.join BASE, 'system'
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.