idcfcloud 0.2.2 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +12 -0
  3. data/.rubocop.yml +12 -2
  4. data/README.md +15 -4
  5. data/idcfcloud.gemspec +7 -8
  6. data/lib/idcf/cli/command/morio.rb +4 -4
  7. data/lib/idcf/cli/conf/const.rb +32 -29
  8. data/lib/idcf/cli/controller/base.rb +50 -23
  9. data/lib/idcf/cli/controller/cdn.rb +3 -0
  10. data/lib/idcf/cli/controller/compute.rb +15 -1
  11. data/lib/idcf/cli/controller/extend/command.rb +25 -2
  12. data/lib/idcf/cli/controller/extend/search_module.rb +0 -10
  13. data/lib/idcf/cli/controller/extend/util.rb +12 -0
  14. data/lib/idcf/cli/controller/include/client.rb +1 -1
  15. data/lib/idcf/cli/controller/include/command.rb +1 -1
  16. data/lib/idcf/cli/controller/include/util.rb +3 -5
  17. data/lib/idcf/cli/controller/include/validate.rb +1 -1
  18. data/lib/idcf/cli/extend/configure.rb +2 -4
  19. data/lib/idcf/cli/extend/update.rb +20 -20
  20. data/lib/idcf/cli/extend/update_file.rb +3 -3
  21. data/lib/idcf/cli/gem_ext/idcf/json_hyper_schema/expands/link_info_base_extension.rb +25 -9
  22. data/lib/idcf/cli/gem_ext/thor/init_util.rb +6 -3
  23. data/lib/idcf/cli/index.rb +17 -5
  24. data/lib/idcf/cli/lib/api.rb +5 -4
  25. data/lib/idcf/cli/lib/configure.rb +2 -2
  26. data/lib/idcf/cli/lib/convert/filter/field_filter.rb +9 -12
  27. data/lib/idcf/cli/lib/convert/filter/json_path_filter.rb +1 -1
  28. data/lib/idcf/cli/lib/convert/formatter/base.rb +1 -2
  29. data/lib/idcf/cli/lib/convert/formatter/csv_format.rb +15 -32
  30. data/lib/idcf/cli/lib/convert/formatter/json_format.rb +1 -1
  31. data/lib/idcf/cli/lib/convert/formatter/table_format.rb +2 -2
  32. data/lib/idcf/cli/lib/convert/formatter/xml_format.rb +1 -1
  33. data/lib/idcf/cli/lib/convert/helper.rb +16 -5
  34. data/lib/idcf/cli/lib/document.rb +42 -0
  35. data/lib/idcf/cli/lib/util/cli_file.rb +1 -1
  36. data/lib/idcf/cli/lib/util/cli_logger.rb +3 -3
  37. data/lib/idcf/cli/lib/util/ini_conf.rb +2 -2
  38. data/lib/idcf/cli/lib/util/input.rb +40 -5
  39. data/lib/idcf/cli/lib/util/yml_conf.rb +1 -1
  40. data/lib/idcf/cli/service/base.rb +6 -6
  41. data/lib/idcf/cli/service/ilb/base_server_for_protocol.rb +22 -18
  42. data/lib/idcf/cli/validate/custom/month_check_validator.rb +1 -1
  43. data/lib/idcf/cli/validate/custom/require_relation_validator.rb +2 -2
  44. data/lib/idcf/cli/validate/define/base.rb +3 -2
  45. data/lib/idcf/cli/version.rb +1 -1
  46. metadata +45 -44
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 09cbeede1098617cb40e566cd20f240d6b2d0404
4
- data.tar.gz: d7a1709c7246eb5a56d83cb2b310830d40f4383a
3
+ metadata.gz: 6941bbdef01e10485802468bf365d7d105146ba1
4
+ data.tar.gz: a32b22a5411de149cf8fd792e5b79c0df512ec89
5
5
  SHA512:
6
- metadata.gz: e9f9c7a579f7772f72b190fce4e712e1b63dcb2144952b5e42d69faa31a7572e97aad5009b7ff933b9dd14ddc49f04f429dab5ba509c5bfc47a110cda1fcc8c1
7
- data.tar.gz: 8374e4292620361ca1e6e2eb798316dcaeb852cf810549062493ab2643049c4d03e995b9534aff6dbce7d4af7c5df63d264527b8aa3e6c0a3e613c2d640a102e
6
+ metadata.gz: 18b046b27be00e1770388bd6067b5d37748a5ed56862e27a5e68cc995fd944a1d15649a5a6206695708f5f61b360b439e1d9c82f210f71c21f892cd78d86e00e
7
+ data.tar.gz: b1af470e7aac83d807b319e7308851e513541207b9993f65a4cf1ec5bd2047c7640d7bbde2b68c86596ed1731c13afb3a15c5f7726cbda7977ad3b1c91356fa3
data/.codeclimate.yml CHANGED
@@ -12,11 +12,23 @@ engines:
12
12
  enabled: true
13
13
  rubocop:
14
14
  enabled: true
15
+ structure:
16
+ exclude_paths:
17
+ - 'test/**/*'
15
18
  ratings:
16
19
  paths:
17
20
  - "**.rb"
21
+ checks:
22
+ argument-count:
23
+ config:
24
+ threshold: 6
25
+ method-complexity:
26
+ config:
27
+ threshold: 9
28
+
18
29
  exclude_paths:
19
30
  - vendor/bundle
20
31
  - .idea
21
32
  - bin
22
33
  - doc
34
+ - output
data/.rubocop.yml CHANGED
@@ -28,7 +28,7 @@ LineLength:
28
28
  Exclude:
29
29
  - 'test/**/*'
30
30
  Style/ClassLength:
31
- Max: 150
31
+ Max: 160
32
32
  Exclude:
33
33
  - 'test/**/*'
34
34
  Style/ModuleLength:
@@ -38,4 +38,14 @@ Style/ModuleLength:
38
38
  ParameterLists:
39
39
  Max: 6
40
40
  Style/DoubleNegation:
41
- Enabled: false
41
+ Enabled: false
42
+ Style/SymbolArray:
43
+ Exclude:
44
+ - 'test/**/*'
45
+ Style/IndentHeredoc:
46
+ EnforcedStyle: active_support
47
+ Style/PercentLiteralDelimiters:
48
+ Exclude:
49
+ - 'test/**/*'
50
+ Lint/InterpolationCheck:
51
+ Enabled: false
data/README.md CHANGED
@@ -55,8 +55,9 @@ cat [attributes file path] | echo -e "'"$(cat)"'" | xargs -L1 idcfcloud <service
55
55
  | secret-key | | [Configuration file description] | Secret Key |
56
56
  | no-ssl | | | Not using SSL |
57
57
  | no-vssl | | | Not using Verify SSL |
58
- | json-path | | | Narrowing the data part of a return value using json-path<br/>https://github.com/joshbuddy/jsonpath |
59
- | fields | | | Limiting the return value to be displayed (applied only to the latest hash)<br/>Punctuation: comma (",") |
58
+ | json-path | j | | Narrowing the data part of a return value using json-path<br/>https://github.com/joshbuddy/jsonpath |
59
+ | fields | f | | Limiting the return value to be displayed (applied only to the latest hash)<br/>Punctuation: comma (",") |
60
+ | version | | [latest] | The API version to be used |
60
61
 
61
62
 
62
63
  #### How to Narrow Down (Examples)
@@ -75,8 +76,18 @@ idcfcloud your list_billing_history --json-path '$.data[?(@.month=="2017-10")]'
75
76
 
76
77
  [Your](#your)
77
78
 
78
- ### Compute(Bata)<a name="compute"></a>
79
- \* If you encounter any problem, please contact us or file a pull request.
79
+ ### Common Features
80
+
81
+ versions
82
+
83
+ Get a supported API version.
84
+
85
+ ```code
86
+ $ idcfcloud your versions
87
+ ```
88
+
89
+
90
+ ### Compute<a name="compute"></a>
80
91
 
81
92
  http://docs.idcf.jp/cloud/api/
82
93
 
data/idcfcloud.gemspec CHANGED
@@ -1,4 +1,3 @@
1
- # coding: utf-8
2
1
  lib = File.expand_path('../lib', __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'idcf/cli/version'
@@ -31,15 +30,15 @@ Gem::Specification.new do |spec|
31
30
 
32
31
  spec.add_dependency 'activemodel', '~> 4.2', '>= 4.2.3'
33
32
  spec.add_dependency 'activesupport', '~> 4.2', '>= 4.2.3'
34
- spec.add_dependency 'inifile', '~> 3.0', '>= 3.0.0'
35
- spec.add_dependency 'thor', '~> 0.19.4'
36
33
  spec.add_dependency 'builder', '~> 3.1'
34
+ spec.add_dependency 'CFPropertyList', '~> 2.3.5'
35
+ spec.add_dependency 'facter', '~> 2.5.1'
36
+ spec.add_dependency 'idcf-faraday_middleware', '~> 0.0.2'
37
+ spec.add_dependency 'idcf-json_hyper_schema', '~> 0.2.0'
38
+ spec.add_dependency 'inifile', '~> 3.0', '>= 3.0.0'
39
+ spec.add_dependency 'jsonpath', '~> 0.8.10'
37
40
  spec.add_dependency 'kosi', '~> 1.0', '>= 1.0.0'
38
41
 
39
42
  spec.add_dependency 'open_uri_redirections', '~> 0.2.1'
40
- spec.add_dependency 'idcf-json_hyper_schema', '~> 0.1.0'
41
- spec.add_dependency 'idcf-faraday_middleware', '~> 0.0.2'
42
- spec.add_dependency 'jsonpath', '~> 0.8.10'
43
- spec.add_dependency 'facter', '~> 2.5.1'
44
- spec.add_dependency 'CFPropertyList', '~> 2.3.5'
43
+ spec.add_dependency 'thor', '~> 0.19.4'
45
44
  end
@@ -11,7 +11,7 @@ module Idcf
11
11
  module Command
12
12
  # morio command
13
13
  class Morio
14
- MORIO_TXT = <<-'EOS'.freeze
14
+ MORIO_TXT = <<-TEXT.freeze
15
15
  -+sso+-
16
16
  .... -ssssssso`
17
17
  `-/ossssss+/. `ssssssso`
@@ -25,7 +25,7 @@ module Idcf
25
25
  ./osssssssssssssssssssssss+.
26
26
  `-:+oosssssssssssso+:.
27
27
  ``````````
28
- EOS
28
+ TEXT
29
29
  ATTRIBUTES_OFF = "\e[0m".freeze
30
30
  MORIO_COLOR = "\e[38;5;45m".freeze
31
31
  TITLE_COLOR = "\e[38;5;45m".freeze
@@ -81,7 +81,7 @@ module Idcf
81
81
  result << [k.to_s, data.body] if data.success?
82
82
  end
83
83
  end
84
- rescue
84
+ rescue StandardError => _e
85
85
  []
86
86
  end
87
87
 
@@ -108,7 +108,7 @@ module Idcf
108
108
  if content && content.class == Array && content.size == 2
109
109
  title = content[1].present? ? "#{content[0]} : " : content[0]
110
110
  txt = content[1].present? ? content[1] : ''
111
- add_str = format(" #{TITLE_COLOR}%s#{TEXT_COLOR}%s", title, txt)
111
+ add_str = format(" #{TITLE_COLOR}%<title>s#{TEXT_COLOR}%<txt>s", title: title, txt: txt)
112
112
  end
113
113
  "#{base_str}#{add_str}"
114
114
  end
@@ -1,4 +1,3 @@
1
- require 'date'
2
1
  require 'logger'
3
2
  require 'idcf/cli/version'
4
3
  module Idcf
@@ -6,32 +5,36 @@ module Idcf
6
5
  module Conf
7
6
  # const
8
7
  class Const
9
- VERSION_STR = "idcfcloud version #{Idcf::Cli::VERSION}".freeze
10
- now = DateTime.now.strftime('%Y%m%d%H%M%S%6N')
11
- dir_path = File.dirname(__FILE__)
12
- BASE_PATH = File.expand_path("#{dir_path}/../../../")
13
- LOCAL_ERROR_PREFIX = '[idcfcli]'.freeze
14
- HEADERS =
8
+ DOCUMENT_URL = 'https://www.idcf.jp/api-docs/'.freeze
9
+ DOCUMENT_ID_PREFIX = 'reference'.freeze
10
+ DOCUMENT_ID_SEP = '_'.freeze
11
+ DOCUMENT_SPACE_CONVERSION = '-'.freeze
12
+ VERSION_STR = "idcfcloud version #{Idcf::Cli::VERSION}".freeze
13
+ now = Time.now.strftime('%Y%m%d%H%M%S%6N')
14
+ dir_path = File.dirname(__FILE__)
15
+ BASE_PATH = File.expand_path("#{dir_path}/../../../")
16
+ LOCAL_ERROR_PREFIX = '[idcfcli]'.freeze
17
+ HEADERS =
15
18
  {
16
19
  'User-Agent': "IDCF CLI v#{Idcf::Cli::VERSION}"
17
20
  }.freeze
18
- USER_DIR_PATH = '~/.idcfcloud'.freeze
19
- VALIDATOR_DIR_PATH = 'idcf/cli/validate/define'.freeze
20
- CODE_CONF_PATH = "#{BASE_PATH}/idcf/cli/conf/conf.yml".freeze
21
- USER_CONF_PATH = "#{USER_DIR_PATH}/config.ini".freeze
22
- USER_CONF_GLOBAL = "#{BASE_PATH}/../config/config.ini".freeze
23
- REGIONS = %w(jp-east jp-east-2 jp-west).freeze
24
- GLOBAL_CONF_ITEMS =
21
+ USER_DIR_PATH = '~/.idcfcloud'.freeze
22
+ VALIDATOR_DIR_PATH = 'idcf/cli/validate/define'.freeze
23
+ CODE_CONF_PATH = "#{BASE_PATH}/idcf/cli/conf/conf.yml".freeze
24
+ USER_CONF_PATH = "#{USER_DIR_PATH}/config.ini".freeze
25
+ USER_CONF_GLOBAL = "#{BASE_PATH}/../config/config.ini".freeze
26
+ REGIONS = %w[jp-east jp-east-2 jp-west].freeze
27
+ GLOBAL_CONF_ITEMS =
25
28
  {
26
29
  output_log: {
27
30
  default: 'Y',
28
- list: %w(Y n)
31
+ list: %w[Y n]
29
32
  },
30
33
  log_path: {
31
34
  default: '~/.idcfcloud/log'
32
35
  }
33
36
  }.freeze
34
- USER_CONF_ITEMS =
37
+ USER_CONF_ITEMS =
35
38
  {
36
39
  api_key: nil,
37
40
  secret_key: nil,
@@ -39,22 +42,22 @@ module Idcf
39
42
  list: REGIONS
40
43
  }
41
44
  }.freeze
42
- FULL_HREF_REGEXP = Regexp.new('\A[a-zA-Z]*:?//').freeze
43
- CMD_FILE_DIR = "#{BASE_PATH}/idcf/cli/conf/service".freeze
44
- CMD_FILE_EXT = 'json'.freeze
45
- SERVICE_PATH = 'idcf/cli/service'.freeze
46
- TEMPLATE_DIR = "#{BASE_PATH}/idcf/cli/templates".freeze
47
- OUT_DIR = "#{BASE_PATH}/../output".freeze
48
- COMP_PATHS = {
45
+ FULL_HREF_REGEXP = Regexp.new('\A[a-zA-Z]*:?//').freeze
46
+ CMD_FILE_DIR = "#{BASE_PATH}/idcf/cli/conf/service".freeze
47
+ CMD_FILE_EXT = 'json'.freeze
48
+ SERVICE_PATH = 'idcf/cli/service'.freeze
49
+ TEMPLATE_DIR = "#{BASE_PATH}/idcf/cli/templates".freeze
50
+ OUT_DIR = "#{BASE_PATH}/../output".freeze
51
+ COMP_PATHS = {
49
52
  bash: '~/.bash_profile',
50
53
  zsh: '~/.zprofile'
51
54
  }.freeze
52
- LOG_FILE_PREFIX = 'cli_log_'.freeze
53
- LOG_FILE_NAME = "#{LOG_FILE_PREFIX}#{now}.log".freeze
54
- LOG_LEVEL = Logger::INFO.freeze
55
- CLASSIFY_RULE = [
56
- %w(sslalgorithms_ids SslalgorithmsIds),
57
- %w(dns Dns)
55
+ LOG_FILE_PREFIX = 'cli_log_'.freeze
56
+ LOG_FILE_NAME = "#{LOG_FILE_PREFIX}#{now}.log".freeze
57
+ LOG_LEVEL = Logger::INFO.freeze
58
+ CLASSIFY_RULE = [
59
+ %w[sslalgorithms_ids SslalgorithmsIds],
60
+ %w[dns Dns]
58
61
  ].freeze
59
62
  end
60
63
  end
@@ -11,6 +11,7 @@ require_relative './extend/init'
11
11
  require_relative './include/init'
12
12
  require 'jsonpath'
13
13
  require 'idcf/cli/lib/include/recurring_calling'
14
+ require 'idcf/cli/lib/document'
14
15
 
15
16
  module Idcf
16
17
  module Cli
@@ -35,9 +36,13 @@ module Idcf
35
36
  class_option :no_vssl,
36
37
  desc: 'not use verify ssl'
37
38
  class_option :json_path,
38
- desc: 'data filter json_path'
39
+ aliases: '-j',
40
+ desc: 'data filter json_path'
39
41
  class_option :fields,
40
- desc: 'field filter'
42
+ aliases: '-f',
43
+ desc: 'field filter'
44
+ class_option :version,
45
+ desc: 'api version'
41
46
 
42
47
  attr_reader :config, :code_conf, :cmd, :m_classes
43
48
 
@@ -49,7 +54,11 @@ module Idcf
49
54
  attr_accessor :links
50
55
 
51
56
  def init(argv)
52
- o = Thor::Options.new(class_options).parse(argv)
57
+ o = Thor::Options.new(class_options).parse(argv)
58
+ region = get_region(o)
59
+ version = service_version(o)
60
+ Idcf::Cli::Lib::Document.init(region: region, version: version)
61
+
53
62
  register_schema_method(o)
54
63
 
55
64
  make_module_classes.each do |cn, c|
@@ -83,28 +92,38 @@ module Idcf
83
92
  name.underscore.split('/').last
84
93
  end
85
94
 
86
- # service version
95
+ # service version list
87
96
  #
88
- # @param o [Hash]
89
- # @return String
90
- def service_version(o)
91
- sn = service_name
92
- list = Idcf::Cli::Lib::Configure.get_code_conf(sn, o)
93
- result = o[:version].nil? ? list.keys.last : o[:version]
94
- msg = "not found input version[#{o[:version]}]"
95
- raise Idcf::Cli::Error::CliError, msg unless list.keys.include?(result)
96
- result
97
+ # @return [Array]
98
+ def service_versions(region)
99
+ [].tap do |result|
100
+ sn = service_name
101
+ Idcf::Cli::Lib::Configure.get_code_conf(sn).each do |k, v|
102
+ v['region'].each_key do |reg|
103
+ next unless region == reg
104
+ result << k
105
+ break
106
+ end
107
+ end
108
+ end
97
109
  end
98
110
  end
99
111
 
112
+ desc 'versions', 'versions'
113
+
114
+ def versions
115
+ list = self.class.service_versions(self.class.get_region(options))
116
+ puts make_result_str(make_result_data(list, options), options)
117
+ end
118
+
100
119
  protected
101
120
 
102
121
  def execute(cmd, *args)
103
122
  data = run(cmd, args, options)
104
- puts make_result_str(data, false, options)
123
+ puts make_result_str(data, options)
105
124
  Idcf::Cli::Lib::Util::CliLogger.delete
106
125
  Idcf::Cli::Lib::Util::CliLogger.cleaning(options)
107
- rescue => e
126
+ rescue StandardError => e
108
127
  self.class.error_exit(e)
109
128
  end
110
129
 
@@ -202,26 +221,34 @@ module Idcf
202
221
 
203
222
  def make_result_data(data, o)
204
223
  format = output_format(o, '')
205
- table_flag = %w(csv table).include?(format)
224
+ table_flag = %w[csv table].include?(format)
206
225
  helper = Idcf::Cli::Lib::Convert::Helper.new
207
226
 
208
- if helper.filter_target?(o)
209
- result = helper.filter(data, o, table_flag)
210
- elsif table_flag
211
- result = make_table_data(data)
212
- else
213
- result = make_base_response
214
- result[:data] = data
227
+ return data_filter(data, o, table_flag) if helper.filter_target?(o)
228
+ if table_flag
229
+ return data.class == Hash ? make_table_data(data) : data
215
230
  end
231
+ result = make_base_response
232
+ result[:data] = data
216
233
  result
217
234
  end
218
235
 
236
+ def data_filter(data, o, table_flag)
237
+ helper = Idcf::Cli::Lib::Convert::Helper.new
238
+ data = make_field_data(data) if helper.only_filter_fields?(o)
239
+ [Hash, Array].include?(data.class) ? helper.filter(data, o, table_flag) : data
240
+ end
241
+
219
242
  # table data
220
243
  # @param data [Hash]
221
244
  # @return Hash
222
245
  def make_table_data(data)
223
246
  data
224
247
  end
248
+
249
+ def make_field_data(data)
250
+ data
251
+ end
225
252
  end
226
253
  end
227
254
  end
@@ -8,6 +8,9 @@ module Idcf
8
8
  class Cdn < Base
9
9
  default_command :help
10
10
 
11
+ class_option :version,
12
+ desc: 'API Version'
13
+
11
14
  class << self
12
15
  def description
13
16
  'Contents Cache Service'
@@ -16,7 +16,7 @@ module Idcf
16
16
 
17
17
  class << self
18
18
  def description
19
- 'Computeing Service(beta)'
19
+ 'Computeing Service'
20
20
  end
21
21
  end
22
22
 
@@ -38,6 +38,20 @@ module Idcf
38
38
  faraday
39
39
  end
40
40
 
41
+ def make_table_data(data)
42
+ return data unless data.class == Hash
43
+ keys = data.keys
44
+ return data unless keys.count == 2 && keys.include?('count')
45
+ data.each do |k, v|
46
+ return v unless k == 'count'
47
+ end
48
+ data
49
+ end
50
+
51
+ def make_field_data(data)
52
+ make_table_data(data)
53
+ end
54
+
41
55
  # raise api error msg
42
56
  #
43
57
  # @param res [Faraday::Responce]
@@ -1,18 +1,24 @@
1
1
  require 'idcf/cli/conf/const'
2
2
  require 'idcf/cli/lib/api'
3
+ require 'idcf/cli/lib/document'
3
4
  module Idcf
4
5
  module Cli
5
6
  module Controller
6
7
  module Extend
7
8
  # command
8
9
  module Command
10
+ attr_reader :public_commands
11
+
9
12
  # register schema method by link
10
13
  #
11
14
  # @param link [Idcf::JsonHyperSchema::Expands::LinkInfoBase]
12
15
  def register_schema_method_by_link!(link)
13
- param_str = Idcf::Cli::Lib::Api.command_param_str(link)
16
+ param_str = Idcf::Cli::Lib::Api.command_param_str(link)
14
17
  method_desc = "#{link.title} #{param_str}"
15
- desc method_desc.strip, link.description
18
+ description = link.description
19
+ desc method_desc.strip, description
20
+ description = "#{description}\n\n#{Idcf::Cli::Lib::Document.make_document_desc(link)}"
21
+ long_desc description
16
22
  define_method link.title.to_sym do |*args|
17
23
  execute(__method__, *args)
18
24
  end
@@ -43,6 +49,23 @@ module Idcf
43
49
  method_option opn, option
44
50
  end
45
51
  end
52
+
53
+ def desc(usage, description, options = {})
54
+ super(usage, description, options)
55
+ @public_commands ||= []
56
+ cmd = usage.split(' ').shift
57
+ @public_commands << cmd unless @public_commands.include?(cmd)
58
+ end
59
+
60
+ def subcommand_structure
61
+ result = super
62
+ list = @public_commands
63
+ list.concat(superclass.public_commands) if superclass.respond_to?(:public_commands)
64
+ list.each do |cmd|
65
+ result[cmd] = nil unless result.key?(cmd)
66
+ end
67
+ result
68
+ end
46
69
  end
47
70
  end
48
71
  end
@@ -22,7 +22,6 @@ module Idcf
22
22
  def make_module_classes
23
23
  return @m_classes if @m_classes
24
24
  result = {}
25
- add_classify_rule
26
25
 
27
26
  make_service_paths.each do |fn, path|
28
27
  require path
@@ -32,15 +31,6 @@ module Idcf
32
31
  @m_classes = result
33
32
  end
34
33
 
35
- # add classify rule
36
- def add_classify_rule
37
- Idcf::Cli::Conf::Const::CLASSIFY_RULE.each do |rule|
38
- ActiveSupport::Inflector.inflections do |inflect|
39
- inflect.irregular(*rule)
40
- end
41
- end
42
- end
43
-
44
34
  # make service paths
45
35
  #
46
36
  # @return Hash
@@ -27,6 +27,18 @@ module Idcf
27
27
  v = service_version(o)
28
28
  "#{dir}/#{fn}_#{v}_#{region}.#{ext}"
29
29
  end
30
+
31
+ # service version
32
+ #
33
+ # @param o [Hash]
34
+ # @return String
35
+ def service_version(o)
36
+ versions = service_versions(get_region(o))
37
+ result = o[:version].nil? ? versions.last : o[:version]
38
+ msg = "not found input version[#{o[:version]}]"
39
+ raise Idcf::Cli::Error::CliError, msg unless versions.include?(result)
40
+ result
41
+ end
30
42
  end
31
43
  end
32
44
  end
@@ -54,7 +54,7 @@ module Idcf
54
54
  def faraday_setting(faraday, o)
55
55
  prof = Idcf::Cli::Lib::Configure.get_profile(o)
56
56
  op = {}
57
- [:api_key, :secret_key].each do |v|
57
+ %i[api_key secret_key].each do |v|
58
58
  op[v] = o.key?(v) ? o[v] : Idcf::Cli::Lib::Configure.get_user_conf(v.to_s, prof)
59
59
  end
60
60
  faraday.request(faraday_request)
@@ -20,7 +20,7 @@ module Idcf
20
20
  args.each do |v|
21
21
  begin
22
22
  result << JSON.parse(v, symbolize_names: false)
23
- rescue
23
+ rescue StandardError => _e
24
24
  result << v
25
25
  end
26
26
  end
@@ -12,10 +12,10 @@ module Idcf
12
12
  # @param err_f [Boolean]
13
13
  # @param o [Hash]
14
14
  # @return Stirng
15
- def make_result_str(data, err_f, o)
15
+ def make_result_str(data, o)
16
16
  message = data.class == Hash ? data[:message] : {}
17
17
  f = output_format(o, message)
18
- Idcf::Cli::Lib::Convert::Helper.new.format(data, err_f, f)
18
+ Idcf::Cli::Lib::Convert::Helper.new.format(data, f)
19
19
  end
20
20
 
21
21
  # output format
@@ -25,9 +25,7 @@ module Idcf
25
25
  # @return String
26
26
  def output_format(o, message)
27
27
  default_output = Idcf::Cli::Lib::Configure.get_code_conf('output', o)
28
- if message.class == Hash && !message[:output].nil?
29
- return default_output
30
- end
28
+ return default_output if message.class == Hash && !message[:output].nil?
31
29
 
32
30
  f = o[:output]
33
31
  f.nil? ? default_output : f
@@ -60,7 +60,7 @@ module Idcf
60
60
  next
61
61
  end
62
62
  end
63
- cli_error 'Validate load error'
63
+ cli_error('Validate load error')
64
64
  end
65
65
 
66
66
  # make validation error
@@ -25,9 +25,7 @@ module Idcf
25
25
 
26
26
  def make_profiles(config, o)
27
27
  [].tap do |result|
28
- if o[:profile] != 'default' && !check_profile?(config, 'default')
29
- result << 'default'
30
- end
28
+ result << 'default' if o[:profile] != 'default' && !check_profile?(config, 'default')
31
29
  result << o[:profile]
32
30
  end
33
31
  end
@@ -35,7 +33,7 @@ module Idcf
35
33
  def check_profile?(config, name)
36
34
  conf = config[name]
37
35
  return false if conf.nil?
38
- Idcf::Cli::Conf::Const::USER_CONF_ITEMS.each do |k, _v|
36
+ Idcf::Cli::Conf::Const::USER_CONF_ITEMS.each_key do |k|
39
37
  return false if conf[k.to_s].strip.empty?
40
38
  end
41
39
  true