Sha256: 3a5a4a91a2afece48cacfff85655cf28027eb4264184c0f0f3b65acb015ae3bc
Contents?: true
Size: 1.35 KB
Versions: 6
Compression:
Stored size: 1.35 KB
Contents
module Provider class CDB_FILESYSTEM def load_yaml(filename) if File.file? filename begin YAML::load_file(filename) rescue StringIndexOutOfBoundsException => e puts "Error: YAML parsing in #{filename}" raise "YAML not parsable" false rescue Exception => e puts "Error: YAML parsing in #{filename}" raise "YAML not parsable" false end else raise "File not found: #{filename}" end end def read_data(cdb_path, options={}) config = Hash.new basedir = File.join(($recipe_config[:recipe_base_dir] || $recipe_config[:deploy_home]),'cdb') filename = '' if cdb_path.nil? or cdb_path.empty? $log.writer.error "Error while talking to configuration database, no cdb path given!" exit 1 end paths = cdb_path.split('/') paths.each do |path| basedir = File.join( basedir, path.to_s ) filename = basedir + '.yaml' additional_config = load_yaml(filename) if additional_config.is_a?(Hash) if options[:disable_merge] config = additional_config else config.merge!( additional_config ) end end end config.to_json end end end
Version data entries
6 entries across 6 versions & 1 rubygems