module Config
@author Edmundo Sanchez Configuration
module
Constants
- VERSION
Public Class Methods
env_variables(*variables)
click to toggle source
Read Environmental Variables and set configuration Note All values will be strings by definition @param [Array] List of Environmental variables
# File lib/config.rb, line 41 def self.env_variables(*variables) variables.map! do |var| [var,ENV[var]] end self.set(Hash[*variables.flatten]) end
get()
click to toggle source
Get configuration @return [Config] configuration
# File lib/config.rb, line 11 def self.get @configuration ||= Configuration.new end
json_file(path)
click to toggle source
Read JSON file and set configuration @param [String] Absolute Path to Yaml file
# File lib/config.rb, line 34 def self.json_file(path) file = File.read(path) self.set JSON.parse(file) end
reset()
click to toggle source
Reset the configuration to an empty Configuration
object
# File lib/config.rb, line 24 def self.reset @configuration = Configuration.new end
set(config)
click to toggle source
Set Configuration
with a block @param [Hash] Configuration
Hash
# File lib/config.rb, line 16 def self.set(config) @configuration = Configuration.new do |conf| config.each do |key,value| conf.instance_variable_set("@#{key}",value) end end end
yaml_file(path)
click to toggle source
Read YAML file and set configuration @param [String] Absolute Path to Yaml file
# File lib/config.rb, line 29 def self.yaml_file(path) self.set YAML.load_file(path) end