Sha256: ace55bf58d3b1349d2daba8db82526672a136c8f1a58808c264c1ccd2a076446

Contents?: true

Size: 1.32 KB

Versions: 17

Compression:

Stored size: 1.32 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

17 entries across 17 versions & 1 rubygems

Version Path
depengine-3.0.20 lib/depengine/provider/cdb_filesystem.rb
depengine-3.0.19 lib/depengine/provider/cdb_filesystem.rb
depengine-3.0.18 lib/depengine/provider/cdb_filesystem.rb
depengine-3.0.17 lib/depengine/provider/cdb_filesystem.rb
depengine-3.0.16 lib/depengine/provider/cdb_filesystem.rb
depengine-3.0.15 lib/depengine/provider/cdb_filesystem.rb
depengine-3.0.14 lib/depengine/provider/cdb_filesystem.rb
depengine-3.0.13 lib/depengine/provider/cdb_filesystem.rb
depengine-3.0.12 lib/depengine/provider/cdb_filesystem.rb
depengine-3.0.11 lib/depengine/provider/cdb_filesystem.rb
depengine-3.0.10 lib/depengine/provider/cdb_filesystem.rb
depengine-3.0.9 lib/depengine/provider/cdb_filesystem.rb
depengine-3.0.8 lib/depengine/provider/cdb_filesystem.rb
depengine-3.0.7 lib/depengine/provider/cdb_filesystem.rb
depengine-3.0.6 lib/depengine/provider/cdb_filesystem.rb
depengine-3.0.5 lib/depengine/provider/cdb_filesystem.rb
depengine-3.0.4 lib/depengine/provider/cdb_filesystem.rb