Class: Gotsha::UserConfig
- Inherits:
-
Object
- Object
- Gotsha::UserConfig
- Defined in:
- lib/gotsha/user_config.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.blank? ⇒ Boolean
16 17 18 |
# File 'lib/gotsha/user_config.rb', line 16 def self.blank? new.to_h.empty? end |
.coerce_env_value(value) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/gotsha/user_config.rb', line 20 def self.coerce_env_value(value) return true if value == "true" return false if value == "false" value end |
.get(key) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/gotsha/user_config.rb', line 5 def self.get(key) config = new.to_h env_key = "GOTSHA_#{key.to_s.upcase}" env_value = ENV[env_key] return config[key] if key.to_sym == :commands return coerce_env_value(env_value) unless env_value.nil? config[key] end |
Instance Method Details
#to_h ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/gotsha/user_config.rb', line 27 def to_h TomlRB.load_file(Config::CONFIG_FILE).transform_keys(&:to_sym) rescue Errno::ENOENT {} rescue TomlRB::ParseError => e raise Errors::HardFail, "Syntax error in config file. Open it by running `gotsha configure`\n\n#{e.}" end |