Sha256: f01830311d4cc545aacf7a696aa403d46cd05705d0cc934da14c860f9e35e038
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
require 'yao' require 'yaml' module Kakine class Config OS_PARAMS = %w[auth_url username password] @@config = {} def self.setup load_config load_env validate_config setup_yao end private def self.load_config config = begin YAML.load_file(File.join(Dir.home, '.kakine')) rescue Errno::ENOENT return end @@config.merge!(config) end def self.load_env OS_PARAMS.each do |param| env = "OS_#{param.upcase}" @@config[param] = ENV[env] if ENV[env] end end def self.validate_config OS_PARAMS.each do |param| unless @@config[param] raise "Configuration '#{param}' is missing. Check your ~/.kakine or export OS_#{param.upcase}." end end end def self.setup_yao Yao.configure do auth_url @@config['auth_url'] tenant_name Kakine::Option.tenant_name username @@config['username'] password @@config['password'] client_cert @@config['client_cert'] client_key @@config['client_key'] region_name @@config['region_name'] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kakine-0.6.5 | lib/kakine/config.rb |