class Ettin::Sources::YamlSource
Config data from a yaml file
Attributes
path[R]
Public Class Methods
handles?(_target)
click to toggle source
# File lib/ettin/sources/yaml_source.rb, line 14 def self.handles?(_target) true end
new(path)
click to toggle source
# File lib/ettin/sources/yaml_source.rb, line 18 def initialize(path) @path = path end
Public Instance Methods
load()
click to toggle source
# File lib/ettin/sources/yaml_source.rb, line 22 def load return {} unless File.exist?(path) begin YAML.safe_load(ERB.new(File.read(path)).result) || {} rescue Psych::SyntaxError => e raise "YAML syntax error occurred while parsing #{@path}. " \ "Please note that YAML must be consistently indented using " \ "spaces. Tabs are not allowed. " \ "Error: #{e.message}" end end