module Terrestrial::Config
Constants
- DEFAULTS
- GLOBAL_KEYS
- PROJECT_KEYS
Public Class Methods
[](key)
click to toggle source
# File lib/terrestrial/config.rb, line 34 def [](key) if key == :translation_files # Translation files should be handed back as an # empty array if it is nil. # This can happen when users remove all translation # files from terrestrial.yml instead of making # it a valid YAML empty list values[:translation_files] || [] else values[key] end end
inspect()
click to toggle source
# File lib/terrestrial/config.rb, line 51 def inspect "<Terrestrial::Config config=#{values.inspect}>" end
load(opts = {})
click to toggle source
# File lib/terrestrial/config.rb, line 24 def load(opts = {}) values.merge!(opts) end
load!(opts = {}, project: true, global: true)
click to toggle source
# File lib/terrestrial/config.rb, line 28 def load!(opts = {}, project: true, global: true) load(opts) _load_project_config if project _load_global_config if global end
project_config_exist?()
click to toggle source
# File lib/terrestrial/config.rb, line 55 def project_config_exist? File.exists?(_project_config_path) end
reset!()
click to toggle source
# File lib/terrestrial/config.rb, line 47 def reset! _reset! end
testing?()
click to toggle source
# File lib/terrestrial/config.rb, line 67 def testing? self[:api_url] != DEFAULTS[:api_url] end
touch_global_config!()
click to toggle source
# File lib/terrestrial/config.rb, line 71 def touch_global_config! FileUtils.touch(_global_config_path) end
update_global_config()
click to toggle source
# File lib/terrestrial/config.rb, line 63 def update_global_config YamlHelper.update(_global_config_path, values.select {|key, val| GLOBAL_KEYS.include? key }) end
update_project_config(fail_if_exists: false)
click to toggle source
# File lib/terrestrial/config.rb, line 59 def update_project_config(fail_if_exists: false) YamlHelper.update(_project_config_path, values.select {|key, val| PROJECT_KEYS.include? key }) end
Private Class Methods
_global_config()
click to toggle source
# File lib/terrestrial/config.rb, line 97 def _global_config YamlHelper.read _global_config_path end
_global_config_path()
click to toggle source
# File lib/terrestrial/config.rb, line 105 def _global_config_path Dir.home + "/.terrestrial" end
_load_global_config()
click to toggle source
# File lib/terrestrial/config.rb, line 85 def _load_global_config values.merge! _global_config end
_load_project_config()
click to toggle source
# File lib/terrestrial/config.rb, line 77 def _load_project_config begin values.merge! _project_config rescue Errno::ENOENT abort "No terrerstrial.yaml found. Are you in the correct folder?" end end
_project_config()
click to toggle source
# File lib/terrestrial/config.rb, line 101 def _project_config YamlHelper.read _project_config_path end
_project_config_path()
click to toggle source
# File lib/terrestrial/config.rb, line 109 def _project_config_path Dir.pwd + "/terrestrial.yml" end
_reset!()
click to toggle source
# File lib/terrestrial/config.rb, line 89 def _reset! @values = Hash.new.merge(DEFAULTS) end
values()
click to toggle source
# File lib/terrestrial/config.rb, line 93 def values @values ||= Hash.new.merge(DEFAULTS) end