Class: Pindo::TaskSystem::UnityExportTask

Inherits:
PindoTask
  • Object
show all
Defined in:
lib/pindo/module/task/model/unity_export_task.rb

Instance Attribute Summary collapse

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

Instance Method Summary collapse

Methods inherited from PindoTask

#before_retry, #cancel, #cancelled?, #check_cancelled!, #do_task, #execution_time, #finished?, #on, #reset_for_retry, #retryable?, #running?, #should_retry?

Constructor Details

#initialize(platform, options = {}) ⇒ UnityExportTask

Returns a new instance of UnityExportTask.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/pindo/module/task/model/unity_export_task.rb', line 26

def initialize(platform, options = {})
  @platform = platform
  @unity_project_path = options[:project_path] || Dir.pwd
  @unity_exe_path = nil  # 将在 do_work 中自动查找
  @unity_helper = nil    # 将在 do_work 中自动初始化
  @is_library_mode = false  # 不再支持库模式
  @index_count = options[:context] ? options[:context][:index_count] : nil
  @export_path = options[:export_path]  # 可由参数传入,nil 表示自动检测

  name = case platform
         when 'ios', 'ipa'
           "Unity 导出 iOS"
         when 'android', 'apk'
           "Unity 导出 Android"
         when 'web', 'html'
           "Unity 导出 WebGL"
         else
           "Unity 导出 #{platform.upcase}"
         end

  super(name, options)
end

Instance Attribute Details

#export_pathObject (readonly)

Returns the value of attribute export_path.



7
8
9
# File 'lib/pindo/module/task/model/unity_export_task.rb', line 7

def export_path
  @export_path
end

#platformObject (readonly)

Returns the value of attribute platform.



7
8
9
# File 'lib/pindo/module/task/model/unity_export_task.rb', line 7

def platform
  @platform
end

#unity_project_pathObject (readonly)

Returns the value of attribute unity_project_path.



7
8
9
# File 'lib/pindo/module/task/model/unity_export_task.rb', line 7

def unity_project_path
  @unity_project_path
end

Class Method Details

.default_retry_countObject



18
19
20
# File 'lib/pindo/module/task/model/unity_export_task.rb', line 18

def self.default_retry_count
  2  # 可以重试 2 次
end

.default_retry_delayObject



22
23
24
# File 'lib/pindo/module/task/model/unity_export_task.rb', line 22

def self.default_retry_delay
  10  # 延迟 10 秒
end

.default_retry_modeObject

重试配置



14
15
16
# File 'lib/pindo/module/task/model/unity_export_task.rb', line 14

def self.default_retry_mode
  RetryMode::DELAYED 
end

.task_typeObject



9
10
11
# File 'lib/pindo/module/task/model/unity_export_task.rb', line 9

def self.task_type
  :unity_export
end

Instance Method Details

#validateObject



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/pindo/module/task/model/unity_export_task.rb', line 49

def validate
  # 验证 Unity 工程是否存在
  unless @unity_helper
    @unity_helper = Pindo::Client::UnityHelper.share_instance
  end

  unless @unity_helper.unity_project?(@unity_project_path)
    @error = "当前目录不是 Unity 工程:#{@unity_project_path}"
    return false
  end

  true
end