Class: Idcf::Cli::Controller::Base
- Extended by:
- Extend::Init
- Includes:
- Include::Init, Lib::Include::RecurringCalling
- Defined in:
- lib/idcf/cli/controller/base.rb
Overview
Controller Base
Class Attribute Summary collapse
-
.links ⇒ Object
Returns the value of attribute links.
Instance Attribute Summary collapse
-
#cmd ⇒ Object
readonly
Returns the value of attribute cmd.
-
#code_conf ⇒ Object
readonly
Returns the value of attribute code_conf.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#m_classes ⇒ Object
readonly
Returns the value of attribute m_classes.
Class Method Summary collapse
- .init(argv) ⇒ Object
- .register_schema_method(o) ⇒ Object
- .self_call? ⇒ Boolean
-
.service_name ⇒ Object
service name.
-
.service_versions(region) ⇒ Array
service version list.
Instance Method Summary collapse
Methods included from Extend::Util
#get_region, #make_schema_path, #service_version
Methods included from Extend::SearchModule
#make_model_name, #make_module_classes, #make_service_paths, #search_module_class
Methods included from Extend::Override
Methods included from Lib::Include::RecurringCalling
Methods inherited from Thor
command_help_string, command_regist, description, error_exit, exit_on_failure?, module_path, sub_command_regist, subcommand_structure
Class Attribute Details
.links ⇒ Object
Returns the value of attribute links.
54 55 56 |
# File 'lib/idcf/cli/controller/base.rb', line 54 def links @links end |
Instance Attribute Details
#cmd ⇒ Object (readonly)
Returns the value of attribute cmd.
47 48 49 |
# File 'lib/idcf/cli/controller/base.rb', line 47 def cmd @cmd end |
#code_conf ⇒ Object (readonly)
Returns the value of attribute code_conf.
47 48 49 |
# File 'lib/idcf/cli/controller/base.rb', line 47 def code_conf @code_conf end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
47 48 49 |
# File 'lib/idcf/cli/controller/base.rb', line 47 def config @config end |
#m_classes ⇒ Object (readonly)
Returns the value of attribute m_classes.
47 48 49 |
# File 'lib/idcf/cli/controller/base.rb', line 47 def m_classes @m_classes end |
Class Method Details
.init(argv) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/idcf/cli/controller/base.rb', line 56 def init(argv) o = Thor::Options.new().parse(argv) region = get_region(o) version = service_version(o) Idcf::Cli::Lib::Document.init(region: region, version: version) register_schema_method(o) make_module_classes.each do |cn, c| register_module_method!(cn, c) end end |
.register_schema_method(o) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/idcf/cli/controller/base.rb', line 69 def register_schema_method(o) path = make_schema_path(o) unless File.exist?(path) raise Idcf::Cli::Error::CliError, 'Run the command `update`' if self_call? return nil end analyst = Idcf::JsonHyperSchema::Analyst.new @links = analyst.load(path).links @links.each do |link| register_schema_method_by_link!(link) end end |
.self_call? ⇒ Boolean
84 85 86 |
# File 'lib/idcf/cli/controller/base.rb', line 84 def self_call? ARGV.include?(name.underscore.split('/').pop) end |
.service_name ⇒ Object
service name
91 92 93 |
# File 'lib/idcf/cli/controller/base.rb', line 91 def service_name name.underscore.split('/').last end |
.service_versions(region) ⇒ Array
service version list
98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/idcf/cli/controller/base.rb', line 98 def service_versions(region) [].tap do |result| sn = service_name Idcf::Cli::Lib::Configure.get_code_conf(sn).each do |k, v| v['region'].each_key do |reg| next unless region == reg result << k break end end end end |
Instance Method Details
#versions ⇒ Object
114 115 116 117 |
# File 'lib/idcf/cli/controller/base.rb', line 114 def versions list = self.class.service_versions(self.class.get_region()) puts make_result_str(make_result_data(list, ), ) end |