Class: Wrapbox::ConfigRepository

Inherits:
Object
  • Object
show all
Defined in:
lib/wrapbox/config_repository.rb

Instance Method Summary collapse

Constructor Details

#initializeConfigRepository

Returns a new instance of ConfigRepository.



6
7
8
# File 'lib/wrapbox/config_repository.rb', line 6

def initialize
  @configs = {}
end

Instance Method Details

#defaultObject



26
27
28
# File 'lib/wrapbox/config_repository.rb', line 26

def default
  @configs[:default]
end

#get(name) ⇒ Object Also known as: []



30
31
32
# File 'lib/wrapbox/config_repository.rb', line 30

def get(name)
  name ? @configs[name.to_sym] : default
end

#load_config(name, configuration) ⇒ Object



22
23
24
# File 'lib/wrapbox/config_repository.rb', line 22

def load_config(name, configuration)
  @configs[name.to_sym] = Configuration.load_config(configuration)
end

#load_yaml(yaml_file) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/wrapbox/config_repository.rb', line 10

def load_yaml(yaml_file)
  file = ERB.new(File.read(yaml_file)).result
  configs = if Gem::Version.new(Psych::VERSION) >= Gem::Version.new("4.0.0")
    YAML.load(file, aliases: true)
  else
    YAML.load(file)
  end
  configs.each do |name, configuration|
    load_config(name, configuration.merge("name" => name))
  end
end