Class: Zephira::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/zephira/config.rb

Class Method Summary collapse

Class Method Details

.read(key) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/zephira/config.rb', line 7

def self.read(key)
  project_config_path = File.join(Dir.pwd, ".zephira.yml")
  global_config_path = File.expand_path("~/.zephira.yml")

  project_config = File.exist?(project_config_path) ? (YAML.load_file(project_config_path) || {})[key] : nil
  global_config = File.exist?(global_config_path) ? (YAML.load_file(global_config_path) || {})[key] : nil

  ENV[key] || project_config || global_config
end