Class: Pindo::Command::Jps::Media
- Inherits:
-
Pindo::Command::Jps
- Object
- CLAide::Command
- Pindo::Command
- Pindo::Command::Jps
- Pindo::Command::Jps::Media
- Defined in:
- lib/pindo/command/jps/media.rb
Constant Summary
Constants inherited from Pindo::Command
DEFAULT_OPTIONS, DEFAULT_ROOT_OPTIONS
Instance Attribute Summary
Attributes inherited from Pindo::Command
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Media
constructor
A new instance of Media.
- #run ⇒ Object
- #validate! ⇒ Object
Methods inherited from Pindo::Command
command_name, #initialize_options, run, use_cache?
Methods included from Funlog::Mixin
Methods included from Pindoconfig::Mixin
Constructor Details
#initialize(argv) ⇒ Media
Returns a new instance of Media.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/pindo/command/jps/media.rb', line 53 def initialize(argv) # 收集所有文件参数 @file_paths = [] while (arg = argv.shift_argument) @file_paths << arg.strip.gsub(/\"/, '') end @args_commit_id = argv.option('commit_id') @args_workflow_id = argv.option('workflow_id') @args_proj_name = argv.option('proj') @args_login_flag = argv.flag?('login', false) # 转换 workflow_id 为整数 if @args_workflow_id @args_workflow_id = @args_workflow_id.to_i end super(argv) end |
Class Method Details
.options ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/pindo/command/jps/media.rb', line 44 def self. [ ['--commit_id', '指定 git commit id(默认使用 HEAD)'], ['--workflow_id', '指定工作流ID(用于查找 commit_log)'], ['--proj', '指定项目代号名称'], ['--login', '强制再次登录jps网站'], ].concat(super) end |
Instance Method Details
#run ⇒ Object
78 79 80 81 82 83 84 85 86 87 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 |
# File 'lib/pindo/command/jps/media.rb', line 78 def run project_path = Dir.pwd # 展开文件路径(支持通配符) = (@file_paths) # 设置 PgyerHelper 登录选项 PgyerHelper.share_instace.setForeLogin(beforeLogin: @args_login_flag) # 创建并执行任务 # 所有逻辑都在 Task 中处理: # - 自动查找 git 仓库和 HEAD 信息 # - 自动查找 JPSMedia/ 目录 # - 匹配 git_commit_id 到 JPS commit_log task = Pindo::TaskSystem::JPSUploadMediaTask.new( , git_commit_id: @args_commit_id, workflow_id: @args_workflow_id, project_name: @args_proj_name, project_path: project_path ) task_manager = Pindo::TaskSystem::TaskManager.instance task_manager.clear_all task_manager.add_task(task) task_manager.start # 输出结果 report = task_manager.execution_report if report[:success] > 0 puts "\n上传完成!" else raise Informative, "上传失败" end end |
#validate! ⇒ Object
73 74 75 76 |
# File 'lib/pindo/command/jps/media.rb', line 73 def validate! super # 不再强制要求参数,Task 会自动从 git 获取 end |