7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/configman/modules/utils.rb', line 7
def self.sort_into_sections(config_hash, expected_keys, loaded_modules)
loaded_modules_upcase = loaded_modules.map(&:upcase)
sorted_config = Hash.new { |hash, key| hash[key] = {} }
config_hash.each do |key, value|
section_found = false
expected_keys.each do |section, keys|
next unless loaded_modules_upcase.include?(section.upcase)
next unless keys.include?(key)
sorted_config[section][key] = value
section_found = true
break
end
sorted_config['General'][key] = value unless section_found
end
sorted_config
end
|