class Idcf::Cli::Lib::Configure
configure
Attributes
code_config[R]
config[R]
Public Class Methods
get_code_conf(path, o = {})
click to toggle source
get code setting value
@param path [String] find path @param o [Hash] options @return String or Hash @raise
# File lib/idcf/cli/lib/configure.rb, line 39 def get_code_conf(path, o = {}) profile = get_profile(o) return get_user_conf(path, profile) rescue StandardError => _e return code_config.find(path) if code_config f_path = Idcf::Cli::Conf::Const::CODE_CONF_PATH @code_config = Idcf::Cli::Lib::Util::YmlConf.new(f_path) code_config.find(path) end
get_profile(o)
click to toggle source
get profile
@param o [Hash] options @return String
# File lib/idcf/cli/lib/configure.rb, line 54 def get_profile(o) o['profile'] || 'default' end
get_region(o, read_conf = false)
click to toggle source
get region
@param o [Hash] options @param read_conf [Boolean] @return String
# File lib/idcf/cli/lib/configure.rb, line 63 def get_region(o, read_conf = false) return o['region'] if o['region'] region = '' region = get_user_conf('region', get_profile(o)) if read_conf region.empty? ? 'default' : region rescue StandardError => _e 'default' end
get_user_conf(name, profile = 'default')
click to toggle source
get user config value
@param name [String] @param profile [String] @return String or Hash @raise
# File lib/idcf/cli/lib/configure.rb, line 24 def get_user_conf(name, profile = 'default') return config.find(name, profile) if config @config = load_user_conf msg = 'Run the command `configure`' raise Idcf::Cli::Error::CliError, msg unless config config.find(name, profile) end
reload()
click to toggle source
# File lib/idcf/cli/lib/configure.rb, line 13 def reload @config = nil @code_config = nil end
Protected Class Methods
load_user_conf()
click to toggle source
load user config read only object
@return Idcf::Cli::Lib::Util::IniConf
# File lib/idcf/cli/lib/configure.rb, line 78 def load_user_conf result = nil [ Idcf::Cli::Conf::Const::USER_CONF_GLOBAL, Idcf::Cli::Conf::Const::USER_CONF_PATH ].each do |v| tmp = Idcf::Cli::Lib::Util::IniConf.new(File.expand_path(v)) next if tmp.load_error? result = result.nil? ? tmp : result.merge!(tmp) end result end