lib/isomer/sources/yaml.rb in isomer-0.0.1 vs lib/isomer/sources/yaml.rb in isomer-0.1.0

- old
+ new

@@ -1,13 +1,16 @@ require 'yaml' class Isomer::Sources::Yaml < Isomer::Sources::Base - attr_reader :file, :base + attr_reader :file, :base, :required def initialize(parameters, options={}) @file = options[:file] + raise Isomer::Error, "YAML source requires the 'file' parameter" if file.nil? || file.empty? + @base = options[:base] + @required = !!options[:required] super(parameters) end def load @@ -16,8 +19,11 @@ if base && values.has_key?(base) @configuration = values[base] else @configuration = values end + else + raise Isomer::Error, "Missing required configuration file '#{file}'" if required + @configuration = {} end end end