Class: Bookwatch::Config::YAMLLoader

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

Instance Method Summary collapse

Instance Method Details

#load(path) ⇒ Object



9
10
11
12
13
14
15
16
17
# 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) ⇒ Object



19
20
21
22
23
24
25
# 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