2013-11-06 15:47:26 -05:00
|
|
|
module SiteSettings; end
|
|
|
|
|
|
|
|
class SiteSettings::YamlLoader
|
|
|
|
def initialize(file)
|
|
|
|
@file = file
|
|
|
|
end
|
|
|
|
|
|
|
|
def load
|
|
|
|
yaml = YAML.load_file(@file)
|
2015-04-18 07:53:53 -04:00
|
|
|
yaml.each_key do |category|
|
2013-11-06 15:47:26 -05:00
|
|
|
yaml[category].each do |setting_name, hash|
|
|
|
|
if hash.is_a?(Hash)
|
|
|
|
# Get default value for the site setting:
|
2017-08-06 21:43:09 -04:00
|
|
|
value = hash.delete('default')
|
|
|
|
if value.is_a?(Hash)
|
|
|
|
raise Discourse::Deprecation, "Site setting per env is no longer supported. Error setting: #{setting_name}"
|
|
|
|
end
|
2013-11-06 15:47:26 -05:00
|
|
|
|
2017-08-06 21:43:09 -04:00
|
|
|
if hash['hidden']&.is_a?(Hash)
|
|
|
|
raise Discourse::Deprecation, "Hidden site setting per env is no longer supported. Error setting: #{setting_name}"
|
2013-11-06 15:47:26 -05:00
|
|
|
end
|
|
|
|
|
2017-08-06 21:43:09 -04:00
|
|
|
yield category, setting_name, value, hash.deep_symbolize_keys!
|
2013-11-06 15:47:26 -05:00
|
|
|
else
|
|
|
|
# Simplest case. site_setting_name: 'default value'
|
|
|
|
yield category, setting_name, hash, {}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2014-10-03 01:53:01 -04:00
|
|
|
end
|