Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 37 lines (31 sloc) 0.874 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
require 'yaml'
require 'singleton'

#
# This class manages the YAML configuration for the Show Booklet generator.
# This class is a singleton.
#
class Configuration
  include Singleton
  
  # The configuration file for the application
  CONFIG_FILE = 'show_booklet_gen.yaml'
  
  #
  # Constructs a new Configuration object. A side-effect of this constructor
  # is that the YAML tree is loaded.
  #
  def initialize
    @tree = YAML::parse(File.open(CONFIG_FILE))
  end
  
  #
  # Returns the value of the specified path. The paths expected are for YAML
  # objects. Example, '/db/db_pass'.
  #
  # +property_path+: the path to the value to return
  #
  # Returns the value of the property. If the path is non-existent, nil is
  # returned.
  #
  def get_value(property_path)
    element = @tree.select(property_path)[0]
    element.nil? ? nil : element.value
  end
  
end
Something went wrong with that request. Please try again.