class TYCiCore::TemplateConfig
Attributes
alias[RW]
keys[RW]
last_version[RW]
project[RW]
sub_keys[RW]
templates_json[RW]
type[RW]
Public Class Methods
new(json)
click to toggle source
# File lib/tuya/ci/core/template/template_configurator.rb, line 77 def initialize(json) @project = 'PROJECT' @templates_json = json['templates'] @last_version = json['last_version'] @sub_keys = Hash.new @type = "" @alias = "" @desc = "" @type_map = Hash.new @templates_json.each do |item| key = item['type'].downcase @type_map[key] = item sub_type_map = Hash.new sub_types = item['sub_types'] if sub_types && sub_types.size > 0 sub_types.each do |sub_item| sub_type_map[sub_item['type']] = sub_item end item['sub_types_map'] = sub_type_map end end @keys = @type_map.keys end
Public Instance Methods
log_sub_type(type)
click to toggle source
# File lib/tuya/ci/core/template/template_configurator.rb, line 119 def log_sub_type(type) puts "Here is the #{type} module type list".magenta.underline item = @type_map[type] sub_types = item['sub_types'] if sub_types && sub_types.size > 0 sub_types.each do |sub_item| puts " #{sub_item['type']} : #{sub_item['desc']}".yellow end end end
log_type()
click to toggle source
# File lib/tuya/ci/core/template/template_configurator.rb, line 112 def log_type puts "Here is the module type list".magenta.underline @templates_json.each do |item| puts "#{item['type']} : #{item['desc']}".green end end
setup(type, sub_type)
click to toggle source
# File lib/tuya/ci/core/template/template_configurator.rb, line 130 def setup(type, sub_type) item = @type_map[type] if sub_type item = item['sub_types_map'][sub_type] end setup_item item end
setup_item(item)
click to toggle source
# File lib/tuya/ci/core/template/template_configurator.rb, line 138 def setup_item(item) @type = item['type'] @alias = item['alias'] @desc = item['desc'] end
sub_types(key)
click to toggle source
# File lib/tuya/ci/core/template/template_configurator.rb, line 103 def sub_types(key) sub_type_map = @type_map[key]['sub_types_map'] if sub_type_map sub_type_map.keys else nil end end