Sha256: 7f8b07fb599357e9acdcaac6aafcbf66153401b784618146be35546b689982d0

Contents?: true

Size: 732 Bytes

Versions: 5

Compression:

Stored size: 732 Bytes

Contents

module Vcloud
  module Core
    class ConfigLoader

      def load_config(config_file, schema = nil)
        input_config = YAML::load(File.open(config_file))

        # There is no way in YAML or Ruby to symbolize keys in a hash
        json_string = JSON.generate(input_config)
        config = JSON.parse(json_string, :symbolize_names => true)

        if schema
          validation = Core::ConfigValidator.validate(:base, config, schema)
          unless validation.valid?
            validation.errors.each do |error|
              Vcloud::Core.logger.fatal(error)
            end
            raise("Supplied configuration does not match supplied schema")
          end
        end
        config
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
vcloud-core-0.0.13 lib/vcloud/core/config_loader.rb
vcloud-core-0.0.12 lib/vcloud/core/config_loader.rb
vcloud-core-0.0.11 lib/vcloud/core/config_loader.rb
vcloud-core-0.0.10 lib/vcloud/core/config_loader.rb
vcloud-core-0.0.9 lib/vcloud/core/config_loader.rb