class Vermillion::Cfg

Public Instance Methods

bootstrap!() click to toggle source

Perform first run tasks and create or read config file values

# File lib/client/config.rb, line 7
def bootstrap!
  populate_config

  return if valid_config?

  # no config file found, lets create one using the firstrun controller
  require 'client/controller/firstrun'

  controller = Vermillion::Controller::Firstrun.new
  controller.default

  populate_config
end
get(name) click to toggle source

Get a specific value from the config file data Params:

name

String/symbol key value

# File lib/client/config.rb, line 42
def get(name)
  @yml[name.to_sym]
end
options() click to toggle source

Returns a hash of all module constants and their values

# File lib/client/config.rb, line 22
def options
  keys = Vermillion.constants.select { |name| constant?(name) }
  hash = {}

  keys.each { |key| hash[key] = Vermillion.const_get(key) }
  hash
end
populate_config() click to toggle source

Populates the internal hash which stores any values set in the config file

# File lib/client/config.rb, line 31
def populate_config
  file = File.expand_path("~/.vermillion.yml")
  fmt = Vermillion::Helper.load('formatting')

  @yml = fmt.symbolize(::YAML.load_file(file))
  self
end

Private Instance Methods

constant?(name) click to toggle source

Checks if string is a constant

# File lib/client/config.rb, line 54
def constant?(name)
  name == name.upcase
end
valid_config?() click to toggle source

Check if configuration data exists

# File lib/client/config.rb, line 49
def valid_config?
  !@yml.nil?
end