Method: MGit::MGitConfig.update
- Defined in:
- lib/m-git/foundation/mgit_config.rb
.update(root) {|config| ... } ⇒ Object
更新配置
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/m-git/foundation/mgit_config.rb', line 88 def update(root) # 加载配置 config, error = __load_file(root) if !error.nil? raise Error.new(error) return end # 如果文件存在但无内容,此时读取到的数据类型是FalseClass,此处统一规范化 config = {} if !config.is_a?(Hash) # 更新 yield(config) if block_given? # 更新完后校验格式 if !config.is_a?(Hash) raise Error.new("工具配置更新数据格式错误,更新失败!") return end # 写回配置 error = write_to_file(root, config) if !error.nil? raise Error.new(error) return end end |