class Bookwatch::Config::YAMLLoader

Public Instance Methods

load(path) click to toggle source
# File lib/bookwatch/config/yaml_loader.rb, line 9
def load(path)
  if File.exist?(path)
    config(path)
  else
    raise FileNotFoundError.new, "YAML"
  end
rescue Psych::SyntaxError => e
  raise InvalidSyntaxError.new e
end
load_key(path, key) click to toggle source
# File lib/bookwatch/config/yaml_loader.rb, line 19
def load_key(path, key)
  if File.exist?(path)
    config(path)[key]
  end
rescue Psych::SyntaxError => e
  raise InvalidSyntaxError.new e
end

Private Instance Methods

config(path) click to toggle source
# File lib/bookwatch/config/yaml_loader.rb, line 29
def config(path)
  YAML.load_file(path) || {}
end