StdlibDoc::Status::Database (Class)

In: StdlibDoc/Status/Database.rb
Parent: Object

Implements the Database class, representing the status of the stdlib-doc project as stored in the "status.yaml" file.

Other programs use this class as a core piece of the stdlib-doc status puzzle. The main thing you need to know is that from a Database object, you can get the list of library files with the records method, which returns an array of Record objects.

Database should be as tolerant as possible of bad data. As long as the YAML loads OK, it should more or less take it as it comes. Validation of the data is an outside responsibility.

Methods

default_db_path   new   verify  

Attributes

contributors  [R]  { initials => full name }
field_descriptions  [R]  Not needed for any normal program.
records  [R]  [ Database::Record ]
status_descriptions  [R]  Not needed for any normal program.

Classes and Modules

Class StdlibDoc::Status::Database::Record

Public Class methods

[Source]

# File StdlibDoc/Status/Database.rb, line 45
    def self.default_db_path
      DEFAULT_STATUS_DATABASE
    end

status_db_path must be a Pathname object.

[Source]

# File StdlibDoc/Status/Database.rb, line 52
    def initialize(status_db_path=nil)
      status_db_path ||= DEFAULT_STATUS_DATABASE
      unless status_db_path.file?
        raise DatabaseError, "Can't load data (#{status_db_path}): file does not exist"
      end
      data = YAML.load(File.read(status_db_path))
      unless data.is_a? Hash and data.size > 0
        raise DatabaseError, "Failed to load data (from #{status_db_path})."
      end
      @records             = data["FILES"]
      @contributors        = data["CONTRIBUTORS"]
      @field_descriptions  = data["FIELD DESCRIPTIONS"]
      @status_descriptions = data["STATUS DESCRIPTIONS"]

      # Turn @records into an array of Records.
      @records = @records && @records.map { |hash| Record.new(hash) }
    end

Public Instance methods

See if the data is correctly specified and consistent. Returns an array of complaints. TODO: implement! Or implement it outside the class?

[Source]

# File StdlibDoc/Status/Database.rb, line 73
    def verify
      nil
    end

[Validate]