class Temp::Config

A Config object loads the Temp configuration file and provides access to its values for other parts of Temp.

Constants

DEFAULT_CONF_FILE
DEFAULT_TEMP_DIR

Attributes

file[R]
template_dir[R]
template_options[RW]
vals[R]

Public Class Methods

new(file = DEFAULT_CONF_FILE, template_options = {}) click to toggle source

Loads a configuration file and sets the configuration variables to the values in the file. If not given a filename, loads the default configuration file. If the configuration file doesn't exist, uses default configuration values. Also accepts template options to make it easier to pass to tempfiles.

# File lib/temp/config.rb, line 20
def initialize(file = DEFAULT_CONF_FILE, template_options = {})
  @file = file
  @template_options = template_options

  if File.file? @file
    @vals = YAML::load_file(@file)
  else
    @vals = {
      :template_dir => DEFAULT_TEMP_DIR
    }
  end

  @template_dir = File.expand_path(@vals[:template_dir])
end