Class: DoraBox::FileOperator
- Inherits:
-
Object
- Object
- DoraBox::FileOperator
- Defined in:
- lib/doraBox/util/file_operator.rb
Class Method Summary collapse
- .cache_modified_modules(module_names, branch_name) ⇒ Object
- .get_stdin_branch_name ⇒ Object
- .get_stdin_modified_modules ⇒ Object
- .load_cached_modules_config(file_path = $cache_path) ⇒ Object
Class Method Details
.cache_modified_modules(module_names, branch_name) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# 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 ⇒ Object
15 16 17 18 19 |
# 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 ⇒ Object
9 10 11 12 13 |
# 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) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# 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 |