lib/discourse_theme/config.rb in discourse_theme-0.8.0 vs lib/discourse_theme/config.rb in discourse_theme-0.9.0
- old
+ new
@@ -1,8 +1,7 @@
# frozen_string_literal: true
class DiscourseTheme::Config
-
class PathSetting
def initialize(config, path)
@config = config
@path = path
end
@@ -37,10 +36,22 @@
def components=(val)
set("components", val)
end
+ def local_discourse_directory_configured?
+ !safe_config["local_discourse_directory"].nil?
+ end
+
+ def local_discourse_directory
+ safe_config["local_discourse_directory"]
+ end
+
+ def local_discourse_directory=(dir)
+ set("local_discourse_directory", dir)
+ end
+
protected
def set(name, val)
hash = @config.raw_config[@path] ||= {}
hash[name] = val
@@ -77,10 +88,10 @@
if File.exist?(@filename)
begin
@raw_config = YAML.load_file(@filename)
raise unless Hash === @raw_config
- rescue
+ rescue StandardError
@raw_config = {}
$stderr.puts "ERROR: #{@filename} contains invalid config, resetting"
end
else
@raw_config = {}