Class: LanGrove::ConfigLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/langrove/ext/config_loader.rb

Class Method Summary collapse

Class Method Details

.load_dir(directory) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/langrove/ext/config_loader.rb', line 9

def self.load_dir( directory )
  
  @config = {
    
    :daemons => {}
    
  }
  
  Dir.glob( "#{directory}/*.yml" ) do |config_part|
    
    self.load_yaml( config_part )
    
  end
  
  return @config
  
end

.load_yaml(file) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/langrove/ext/config_loader.rb', line 27

def self.load_yaml( file )
  
  # no rescue block
  # daemon fails on missing config file
  
  yaml = YAML.load_file( file )
  @config.merge!( yaml ) do |key, oldval, newval|
    
    #
    # so the :daemons: subconfigs dont overwrite
    # each other
    #
    oldval.merge!( newval )
    @config[ key ] = oldval
    
  end
  
  return yaml
    
end