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, #dependencies, #error, #finished_at, #id, #metadata, #name, #priority, #result, #retry_count, #retry_delay, #retry_mode, #started_at, #status, #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
任务类型.
Instance Method Summary collapse
-
#initialize(platform, mode, options = {}) ⇒ BuildTask
constructor
实例方法 ==========.
Methods inherited from PindoTask
#before_retry, #cancel, #cancelled?, #check_cancelled!, #do_task, #execution_time, #finished?, #on, #reset_for_retry, #retryable?, #running?, #should_retry?, #validate
Constructor Details
#initialize(platform, mode, options = {}) ⇒ BuildTask
实例方法 ==========
130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/pindo/module/task/model/build_task.rb', line 130 def initialize(platform, mode, = {}) @platform = platform @mode = mode @project_path = [:project_path] || Dir.pwd @output_path = nil # 构建任务名称 name = build_task_name 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 构建任务
101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/pindo/module/task/model/build_task.rb', line 101 def self.create_android_task(mode, ) require_relative 'build/android_dev_build_task' require_relative 'build/android_release_build_task' case mode when :dev, :debug AndroidDevBuildTask.new() when :release AndroidReleaseBuildTask.new() else raise ArgumentError, "不支持的 Android 构建模式: #{mode}" end end |
.create_ios_task(mode, options) ⇒ Object
创建 iOS 构建任务
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/pindo/module/task/model/build_task.rb', line 83 def self.create_ios_task(mode, ) require_relative 'build/ios_dev_build_task' require_relative 'build/ios_adhoc_build_task' require_relative 'build/ios_release_build_task' case mode when :dev IosDevBuildTask.new() when :adhoc IosAdhocBuildTask.new() when :release IosReleaseBuildTask.new() else raise ArgumentError, "不支持的 iOS 构建模式: #{mode}" end end |
.create_task(platform:, mode:, options: {}) ⇒ BuildTask
根据 platform 和 mode 创建对应的构建任务实例
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/pindo/module/task/model/build_task.rb', line 36 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 构建任务
116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/pindo/module/task/model/build_task.rb', line 116 def self.create_web_task(mode, ) require_relative 'build/web_dev_build_task' case mode when :dev, :debug, :release # Web 目前只有一个构建任务类 WebDevBuildTask.new() else raise ArgumentError, "不支持的 Web 构建模式: #{mode}" end end |
.default_retry_count ⇒ Object
21 22 23 |
# File 'lib/pindo/module/task/model/build_task.rb', line 21 def self.default_retry_count 0 end |
.default_retry_delay ⇒ Object
25 26 27 |
# File 'lib/pindo/module/task/model/build_task.rb', line 25 def self.default_retry_delay 10 end |
.default_retry_mode ⇒ Object
重试配置
17 18 19 |
# File 'lib/pindo/module/task/model/build_task.rb', line 17 def self.default_retry_mode RetryMode::DELAYED end |
.normalize_mode(mode) ⇒ Object
标准化构建模式
68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/pindo/module/task/model/build_task.rb', line 68 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
标准化平台名称
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/pindo/module/task/model/build_task.rb', line 53 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 |