Class: Pindo::TaskSystem::BuildTask
- Defined in:
- lib/pindo/module/task/model/build_task.rb
Overview
BuildTask 抽象基类提供构建任务的通用框架和工厂方法
Direct Known Subclasses
Instance Attribute Summary collapse
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#output_path ⇒ Object
readonly
Returns the value of attribute output_path.
-
#platform ⇒ Object
readonly
Returns the value of attribute platform.
-
#project_path ⇒ Object
readonly
Returns the value of attribute project_path.
Attributes inherited from PindoTask
#callbacks_setup, #context, #created_at, #data_dependencies, #dependencies, #error, #finished_at, #id, #max_retry_count, #metadata, #name, #priority, #result, #retry_count, #retry_delay, #retry_mode, #started_at, #status, #task_key, #task_manager, #type
Class Method Summary collapse
-
.create_android_task(mode, options) ⇒ Object
创建 Android 构建任务.
-
.create_ios_task(mode, options) ⇒ Object
创建 iOS 构建任务.
-
.create_task(platform:, mode:, options: {}) ⇒ BuildTask
根据 platform 和 mode 创建对应的构建任务实例.
-
.create_web_task(mode, options) ⇒ Object
创建 Web 构建任务.
- .default_retry_count ⇒ Object
- .default_retry_delay ⇒ Object
-
.default_retry_mode ⇒ Object
重试配置.
-
.normalize_mode(mode) ⇒ Object
标准化构建模式.
-
.normalize_platform(platform) ⇒ Object
标准化平台名称.
-
.task_type ⇒ Object
任务类型.
-
.task_type_name ⇒ Object
任务类型显示名称.
Instance Method Summary collapse
-
#initialize(name, options = {}) ⇒ BuildTask
constructor
实例方法 ==========.
Methods inherited from PindoTask
#before_retry, #cancel, #cancelled?, #check_cancelled!, #data_param, #do_task, #execution_time, #finished?, #get_all_data_params, #get_all_data_params_by_key, #get_all_dependencies_results, #get_data_param, #get_data_param_by_key, #get_dependency_result, #get_dependency_task, #on, #primary_data_param, #reset_for_retry, #retryable?, #running?, #should_retry?, task_key, #validate
Constructor Details
#initialize(name, options = {}) ⇒ BuildTask
实例方法 ==========
138 139 140 141 142 143 144 145 |
# File 'lib/pindo/module/task/model/build_task.rb', line 138 def initialize(name, = {}) @platform = [:platform] @mode = [:mode] @project_path = [:project_path] || Dir.pwd @output_path = nil super(name, ) end |
Instance Attribute Details
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
9 10 11 |
# File 'lib/pindo/module/task/model/build_task.rb', line 9 def mode @mode end |
#output_path ⇒ Object (readonly)
Returns the value of attribute output_path.
9 10 11 |
# File 'lib/pindo/module/task/model/build_task.rb', line 9 def output_path @output_path end |
#platform ⇒ Object (readonly)
Returns the value of attribute platform.
9 10 11 |
# File 'lib/pindo/module/task/model/build_task.rb', line 9 def platform @platform end |
#project_path ⇒ Object (readonly)
Returns the value of attribute project_path.
9 10 11 |
# File 'lib/pindo/module/task/model/build_task.rb', line 9 def project_path @project_path end |
Class Method Details
.create_android_task(mode, options) ⇒ Object
创建 Android 构建任务
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/pindo/module/task/model/build_task.rb', line 106 def self.create_android_task(mode, ) require_relative 'build/android_build_dev_task' require_relative 'build/android_build_adhoc_task' require_relative 'build/android_build_gplay_task' case mode when :dev, :debug AndroidBuildDevTask.new() when :adhoc AndroidBuildAdhocTask.new() when :release AndroidBuildGPlayTask.new() else raise ArgumentError, "不支持的 Android 构建模式: #{mode}" end end |
.create_ios_task(mode, options) ⇒ Object
创建 iOS 构建任务
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/pindo/module/task/model/build_task.rb', line 88 def self.create_ios_task(mode, ) require_relative 'build/ios_build_dev_task' require_relative 'build/ios_build_adhoc_task' require_relative 'build/ios_build_appstore_task' case mode when :dev IosBuildDevTask.new() when :adhoc IosBuildAdhocTask.new() when :release IosBuildAppStoreTask.new() else raise ArgumentError, "不支持的 iOS 构建模式: #{mode}" end end |
.create_task(platform:, mode:, options: {}) ⇒ BuildTask
根据 platform 和 mode 创建对应的构建任务实例
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/pindo/module/task/model/build_task.rb', line 41 def self.create_task(platform:, mode:, options: {}) normalized_platform = normalize_platform(platform) normalized_mode = normalize_mode(mode) case normalized_platform when :ios create_ios_task(normalized_mode, ) when :android create_android_task(normalized_mode, ) when :web create_web_task(normalized_mode, ) else raise ArgumentError, "不支持的平台: #{platform}" end end |
.create_web_task(mode, options) ⇒ Object
创建 Web 构建任务
124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/pindo/module/task/model/build_task.rb', line 124 def self.create_web_task(mode, ) require_relative 'build/web_build_dev_task' case mode when :dev, :debug, :release # Web 目前只有一个构建任务类 WebBuildDevTask.new() else raise ArgumentError, "不支持的 Web 构建模式: #{mode}" end end |
.default_retry_count ⇒ Object
26 27 28 |
# File 'lib/pindo/module/task/model/build_task.rb', line 26 def self.default_retry_count 0 end |
.default_retry_delay ⇒ Object
30 31 32 |
# File 'lib/pindo/module/task/model/build_task.rb', line 30 def self.default_retry_delay 10 end |
.default_retry_mode ⇒ Object
重试配置
22 23 24 |
# File 'lib/pindo/module/task/model/build_task.rb', line 22 def self.default_retry_mode RetryMode::DELAYED end |
.normalize_mode(mode) ⇒ Object
标准化构建模式
73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/pindo/module/task/model/build_task.rb', line 73 def self.normalize_mode(mode) mode_str = mode.to_s.downcase case mode_str when 'dev', 'debug', 'development' :dev when 'adhoc', 'ad-hoc' :adhoc when 'release', 'production', 'deploy' :release else raise ArgumentError, "未知构建模式: #{mode}" end end |
.normalize_platform(platform) ⇒ Object
标准化平台名称
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/pindo/module/task/model/build_task.rb', line 58 def self.normalize_platform(platform) platform_str = platform.to_s.downcase case platform_str when 'ios', 'ipa' :ios when 'android', 'apk', 'aab' :android when 'web', 'html', 'webgl' :web else raise ArgumentError, "未知平台: #{platform}" end end |
.task_type ⇒ Object
任务类型
12 13 14 |
# File 'lib/pindo/module/task/model/build_task.rb', line 12 def self.task_type :build end |
.task_type_name ⇒ Object
任务类型显示名称
17 18 19 |
# File 'lib/pindo/module/task/model/build_task.rb', line 17 def self.task_type_name "编译构建" end |