Module: MaxConf

Defined in:
lib/maxconf.rb

Overview

option: default

description


“file”: undefined

config file to be used, default is

'$HOME/.maxcdn.yml'
“[opt]”: n/a

set or overide [opt]

Example:

require 'maxconf'

conf = MaxConf.load()
puts conf["alias"]
=> YOUR_ALIAS

conf = MaxConf.load("/path/to/maxcdn.yml")
puts conf["alias"]
=> YOUR_ALIAS

opts = {
  "file" => "/path/to/maxcdn.yml",
  "alias" => "ALIAS_OVERIDE"
}
conf = MaxConf.load(opts)
puts conf["alias"]
=> ALIAS_OVERIDE

Class Method Summary collapse

Class Method Details

.load(opts = {}) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/maxconf.rb', line 33

def self.load opts={}
  if opts.class == String
    opts = { "file" => opts }
  end

  file = opts.delete("file") || opts.delete(:file) || DEFAULT_FILE
  conf = YAML.load_file(file)

  # overide config with passed options
  opts.each do |key, val|
    conf[key] = val
  end

  return conf
end