Class: Idcf::Cli::Lib::Configure
- Inherits:
-
Object
- Object
- Idcf::Cli::Lib::Configure
- Defined in:
- lib/idcf/cli/lib/configure.rb
Overview
configure
Class Attribute Summary collapse
-
.code_config ⇒ Object
readonly
Returns the value of attribute code_config.
-
.config ⇒ Object
readonly
Returns the value of attribute config.
Class Method Summary collapse
-
.get_code_conf(path, o = {}) ⇒ Object
get code setting value.
-
.get_profile(o) ⇒ Object
get profile.
-
.get_region(o, read_conf = false) ⇒ Object
get region.
-
.get_user_conf(name, profile = 'default') ⇒ Object
get user config value.
- .reload ⇒ Object
Class Attribute Details
.code_config ⇒ Object (readonly)
Returns the value of attribute code_config.
11 12 13 |
# File 'lib/idcf/cli/lib/configure.rb', line 11 def code_config @code_config end |
.config ⇒ Object (readonly)
Returns the value of attribute config.
11 12 13 |
# File 'lib/idcf/cli/lib/configure.rb', line 11 def config @config end |
Class Method Details
.get_code_conf(path, o = {}) ⇒ Object
get code setting value
39 40 41 42 43 44 45 46 47 48 |
# 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) ⇒ Object
get profile
54 55 56 |
# File 'lib/idcf/cli/lib/configure.rb', line 54 def get_profile(o) o['profile'] || 'default' end |
.get_region(o, read_conf = false) ⇒ Object
get region
63 64 65 66 67 68 69 70 |
# 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') ⇒ Object
get user config value
24 25 26 27 28 29 30 31 |
# 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 ⇒ Object
13 14 15 16 |
# File 'lib/idcf/cli/lib/configure.rb', line 13 def reload @config = nil @code_config = nil end |