Class: Llmp::Config

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

Class Method Summary collapse

Class Method Details

.load(path: nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/llmp/config.rb', line 9

def self.load(path: nil)
  if path
    config_path = path
  else
    config = Runcom::Config.new('llmp/config.yml')
    config_path = config.active || config.passive
  end

  return {} unless config_path
  return {} unless File.exist?(config_path)

  YAML.safe_load(File.read(config_path.to_s)) || {}
rescue Psych::SyntaxError => e
  warn "Warning: Invalid YAML in #{config_path}: #{e.message}"
  {}
end