class DoraBox::FileOperator

Public Class Methods

cache_modified_modules(module_names, branch_name) click to toggle source
# File lib/doraBox/util/file_operator.rb, line 21
def self.cache_modified_modules(module_names, branch_name)
  if File.exist?($cache_path)
    cached_config = load_cached_modules_config
    cached_branch_name = cached_config["branchName"]
    cached_modules = cached_config["modules"]
    new_modules = cached_modules + module_names
    modules_config = {'branchName' => cached_branch_name, 'modules' => new_modules.uniq}
    file = File.new($cache_path, 'w')
    file.write(modules_config.to_yaml)
    file.close
  else
    file = File.new($cache_path, 'w')
    modules_config = {'branchName' => branch_name, 'modules' => module_names}
    file.write(modules_config.to_yaml)
    file.close
  end
end
get_stdin_branch_name() click to toggle source
# File lib/doraBox/util/file_operator.rb, line 15
def self.get_stdin_branch_name
  puts "请输入要创建的开发分支,如 ka/xxx_1.0.0_3.11.0"
  branch_name = $stdin.gets.chomp
  return branch_name
end
get_stdin_modified_modules() click to toggle source
# File lib/doraBox/util/file_operator.rb, line 9
def self.get_stdin_modified_modules
  puts "请输入需要修改的模块名称,用 [,] 分隔"
  module_names = $stdin.gets.chomp.split(",")
  return module_names
end
load_cached_modules_config(file_path = $cache_path) click to toggle source
# File lib/doraBox/util/file_operator.rb, line 39
def self.load_cached_modules_config(file_path = $cache_path)
  if File.exist?(file_path)
    # File.open(file_path, 'r') do |file|
    #   content = file.read()
    # end
    cache_modules_config = YAML.load_file(file_path)
    return cache_modules_config
  end
  return nil
end