Class: BuildkiteWatcher::ConfigLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/buildkite_watcher/config_loader.rb

Constant Summary collapse

CONFIG_FILE_NAME =
".buildkite_watcher"
SECRETS_FILE_NAME =
".buildkite_watcher_secrets"
EXTENSION =
".yml"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.load(config = TTY::Config.new, secrets = TTY::Config.new, prompt = TTY::Prompt.new) ⇒ Object



14
15
16
# File 'lib/buildkite_watcher/config_loader.rb', line 14

def self.load(config = TTY::Config.new, secrets = TTY::Config.new, prompt = TTY::Prompt.new)
  new(config, secrets, prompt).load
end

Instance Method Details

#loadObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/buildkite_watcher/config_loader.rb', line 18

def load
  config.filename = CONFIG_FILE_NAME
  config.extname = EXTENSION
  config.append_path Dir.pwd
  config.exist? ? config.read : generate_config_file

  secrets.filename = SECRETS_FILE_NAME
  config.extname = EXTENSION
  secrets.append_path Dir.home

  secrets.exist? ? secrets.read : generate_secrets_file

  Config.new(config, secrets)
end