diff options
author | Toon Claes <toon@gitlab.com> | 2019-05-29 10:43:27 +0300 |
---|---|---|
committer | Toon Claes <toon@gitlab.com> | 2019-07-01 14:40:21 +0300 |
commit | d9f4f7faff5e5cf8841e9c58b08256e6c602ab56 (patch) | |
tree | 07f70a10bbfb82f5accf3383c60830d64e39d975 | |
parent | 9d5526073782744a8553fc6b689174a46c29e851 (diff) |
Safe-guard non-existence or emptiness of gdk.yml
Allow gdk.yml to be non-existing or empty.
-rw-r--r-- | lib/gdk/config_settings.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/gdk/config_settings.rb b/lib/gdk/config_settings.rb index 7b13f771d26..6429dbb9507 100644 --- a/lib/gdk/config_settings.rb +++ b/lib/gdk/config_settings.rb @@ -21,7 +21,7 @@ module GDK sub = Class.new(ConfigSettings) blk.call(sub) - sub.new(parent: self, yaml: yaml[name.to_s]) + sub.new(parent: self, yaml: yaml.fetch(name.to_s, {})) end else raise SettingUndefined, "Could not find the setting '#{name}'" @@ -68,9 +68,9 @@ module GDK private def load_yaml! - return {} unless defined?(self.class::FILE) + return {} unless defined?(self.class::FILE) && File.exist?(self.class::FILE) - @yaml = YAML.load_file(self.class::FILE) + @yaml = YAML.load_file(self.class::FILE) || {} end def from_yaml(key, default: nil) |