Flowdock
method

class_cache

Importance_0
v1_9_1_378 - Show latest stable - 0 notes - Class: Driver
class_cache() public

No documentation

This method has no description. You can help the Ruby community by adding new notes.

Hide source
# File lib/rdoc/ri/driver.rb, line 332
  def class_cache
    return @class_cache if @class_cache

    # Get the documentation directories used to make the cache in order to see
    # whether the cache is valid for the current ri instantiation.
    if(File.readable?(@cache_doc_dirs_path))
      cache_doc_dirs = IO.read(@cache_doc_dirs_path).split("\n")
    else
      cache_doc_dirs = []
    end

    newest = map_dirs('created.rid') do |f|
      File.mtime f if test ff, f
    end.max

    # An up to date cache file must have been created more recently than
    # the last modification of any of the documentation directories.  It also
    # must have been created with the same documentation directories
    # as those from which ri currently is sourcing documentation.
    up_to_date = (File.exist?(class_cache_file_path) and
                  newest and newest < File.mtime(class_cache_file_path) and
                  (cache_doc_dirs == @doc_dirs))

    if up_to_date and @use_cache then
      open class_cache_file_path, 'rb' do |fp|
        begin
          @class_cache = Marshal.load fp.read
        rescue
          #
          # This shouldn't be necessary, since the up_to_date logic above
          # should force the cache to be recreated when a new version of
          # rdoc is installed.  This seems like a worthwhile enhancement
          # to ri's robustness, however.
          #
          $stderr.puts "Error reading the class cache; recreating the class cache!"
          @class_cache = create_class_cache
        end
      end
    else
      @class_cache = create_class_cache
    end

    @class_cache
  end
Register or log in to add new notes.