module Siba::OptionsLoader
Public Class Methods
load_erb(path_to_file)
click to toggle source
# File lib/siba/options_loader.rb, line 32 def load_erb(path_to_file) data = Siba::FileHelper.read path_to_file ERB.new(data).result end
load_hash_from_yml(path_to_yml)
click to toggle source
# File lib/siba/options_loader.rb, line 28 def load_hash_from_yml(path_to_yml) YAML.load(load_erb path_to_yml) end
load_yml(path_to_yml)
click to toggle source
# File lib/siba/options_loader.rb, line 10 def load_yml(path_to_yml) logger.debug "Loading options from #{path_to_yml}" raise Siba::Error, "Options file must have .yml extension: #{path_to_yml}" unless path_to_yml =~ /\.yml$/ unless File.exists? path_to_yml raise Siba::Error, "Could not read the options file #{path_to_yml}. Make sure the file exists and you have read access to it." end begin hash = load_hash_from_yml path_to_yml raise Siba::Error, "invalid format" unless hash.is_a? Hash return hash rescue Exception => e raise Siba::Error, "Error loading options file #{path_to_yml}: " + e.message end end