Class: TYCiCore::ODMConfigModules
- Inherits:
-
ConfigModules
- Object
- ConfigModules
- TYCiCore::ODMConfigModules
- Defined in:
- lib/tuya/ci/core/config/odm_config_modules.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
Attributes inherited from ConfigModules
#advance_fields, #config_path, #pod_path
Instance Method Summary collapse
- #add_mix(key, value) ⇒ Object
-
#initialize(config_path = "./config_modules.json", pod_path = "./Pods/") ⇒ ODMConfigModules
constructor
A new instance of ODMConfigModules.
-
#remove_mix(key) ⇒ Object
def add_mix(mixHash) mix = @content if mix.nil? || mix.empty? mix = mixHash else mix = mix.merge(mixHash) end end.
- #save(target = @config_path) ⇒ Object
-
#setup_modules ⇒ Object
根据 pod目录生成 modules.
- #update_config(key, value) ⇒ Object
Methods inherited from ConfigModules
#config_hash, #module?, #module_lib?, #modules_in_pods
Constructor Details
#initialize(config_path = "./config_modules.json", pod_path = "./Pods/") ⇒ ODMConfigModules
Returns a new instance of ODMConfigModules.
8 9 10 11 12 |
# File 'lib/tuya/ci/core/config/odm_config_modules.rb', line 8 def initialize(config_path="./config_modules.json", pod_path="./Pods/") @config_path = config_path @pod_path = pod_path @content = config_hash end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
6 7 8 |
# File 'lib/tuya/ci/core/config/odm_config_modules.rb', line 6 def content @content end |
Instance Method Details
#add_mix(key, value) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/tuya/ci/core/config/odm_config_modules.rb', line 14 def add_mix(key, value) mix = @content["mixMap"] if mix.nil? || mix.empty? mix = Hash[key => value] else mix[key]=value end @content["mixMap"]=mix end |
#remove_mix(key) ⇒ Object
def add_mix(mixHash)
mix = @content["mixMap"]
if mix.nil? || mix.empty?
mix = mixHash
else
mix = mix.merge(mixHash)
end
end
33 34 35 |
# File 'lib/tuya/ci/core/config/odm_config_modules.rb', line 33 def remove_mix(key) @content["mixMap"].delete(key) end |
#save(target = @config_path) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/tuya/ci/core/config/odm_config_modules.rb', line 49 def save(target=@config_path) file_content = JSON.pretty_generate(@content) fh = File.new(target, "w") fh << file_content fh.close end |
#setup_modules ⇒ Object
根据 pod目录生成 modules
41 42 43 44 45 46 47 |
# File 'lib/tuya/ci/core/config/odm_config_modules.rb', line 41 def setup_modules # 根据 pod目录生成 modules puts "ODM Setup #{@config_path} at #{@pod_path}".green modules = modules_in_pods @content["modules"] = modules end |
#update_config(key, value) ⇒ Object
37 38 39 |
# File 'lib/tuya/ci/core/config/odm_config_modules.rb', line 37 def update_config(key, value) @content[key]=value end |