class Rubikon::Config::YamlProvider

A configuration provider loading configuration data from YAML files

@author Sebastian Staudt @since 0.5.0

Public Class Methods

load_config(file) click to toggle source

Loads a configuration Hash from a YAML formatted file

@param [String] file The path of the file to load @return [Hash] The configuration data loaded from the file

# File lib/rubikon/config/yaml_provider.rb, line 22
def self.load_config(file)
  YAML.load_file file
end
save_config(config, file) click to toggle source

Saves a configuration Hash into a YAML formatted file

@param [Hash] config The configuration to write @param [String] file The path of the file to write @since 0.6.0

# File lib/rubikon/config/yaml_provider.rb, line 31
def self.save_config(config, file)
  unless config.is_a? Hash
    raise ArgumentError.new('Configuration has to be a Hash')
  end

  file = File.new file, 'w'
  YAML.dump config, file
  file.close
end