Module: Worktree::Config

Defined in:
lib/worktree/config.rb

Class Method Summary collapse

Class Method Details

.configObject



17
18
19
# File 'lib/worktree/config.rb', line 17

def config
  YAML.load_file(Worktree::Config.config_file)
end

.config_fileObject



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

def config_file
  xdg_config_home = ENV.fetch('XDG_CONFIG_HOME') { "#{ENV['HOME']}/.config" }
  _config_file = "#{xdg_config_home}/worktree/worktree.yml"
  unless File.exist?(_config_file)
    raise Worktree::Error, "config file #{_config_file} not found!"
  end

  _config_file
end