class FlexibleConfig::Overview
Public Instance Methods
call()
click to toggle source
# File lib/flexible_config/overview.rb, line 3 def call available_files.reduce({}) do |memo, i| memo[i] = config_lines_for_file i memo end end
print()
click to toggle source
# File lib/flexible_config/overview.rb, line 10 def print call.each do |key, value| Kernel.puts "#===== #{key.upcase} (#{key}.yml) =====" value.each { |v| Kernel.puts v } Kernel.puts "\n" end end
Private Instance Methods
available_files()
click to toggle source
# File lib/flexible_config/overview.rb, line 20 def available_files WrappedYaml.config_data.keys end
config_lines_for_file(category)
click to toggle source
# File lib/flexible_config/overview.rb, line 24 def config_lines_for_file(category) builder = FlexibleConfig::Builder.new category keys = [] WrappedYaml.config_data[category].values.each do |env| keys += flat_hash(env).keys end keys.uniq.sort.map do |keys| value = begin builder[keys.join '.'] rescue FlexibleConfig::NotFound => e "### NO VALUE ###" end combined_keys = [category] + keys dotted_key = keys.join '.' env_key = combined_keys.map(&:upcase).join '_' from_env = !WrappedEnv[env_key].nil? ? 'ENV OVERRIDE' : '' sprintf("%-40s|%-12s| %-45s = %s", dotted_key, from_env, env_key, value ) end end
flat_hash(h, f = [], g = {})
click to toggle source
# File lib/flexible_config/overview.rb, line 50 def flat_hash(h, f = [], g = {}) return g.update(f => h) unless h.is_a? Hash h.each { |k, r| flat_hash r, f+[k], g } g end