Class: ConfigSpartan

Inherits:
Object
  • Object
show all
Defined in:
lib/config_spartan.rb,
lib/config_spartan/version.rb

Constant Summary collapse

VERSION =
"1.0.1"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfigSpartan

Returns a new instance of ConfigSpartan.



15
16
17
# File 'lib/config_spartan.rb', line 15

def initialize
  @config = Hashie::Mash.new
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



9
10
11
# File 'lib/config_spartan.rb', line 9

def config
  @config
end

Class Method Details

.create(&block) ⇒ Object



11
12
13
# File 'lib/config_spartan.rb', line 11

def self.create(&block)
  new.tap{ |spartan| spartan.instance_eval(&block) }.config
end

Instance Method Details

#file(path) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/config_spartan.rb', line 19

def file(path)
  data = File.read(path)
  yaml = ERB.new(data).result
  hash = YAML.load(yaml)
  mash = Hashie::Mash.new(hash)
  @config.deep_merge!(mash)
end