Class: MGit::OperationProgressContext
- Inherits:
-
Object
- Object
- MGit::OperationProgressContext
- Defined in:
- lib/m-git/foundation/operation_progress_manager.rb
Overview
本类用于缓存/加载操作中间态
Constant Summary collapse
- CONTEXT_CMD =
现场信息关键字段
'cmd'
- CONTEXT_OPTS =
'opts'
- CONTEXT_BRANCH =
'branch'
- CONTEXT_REPOS =
'repos'
- CONTEXT_OTHER =
'other'
Instance Attribute Summary collapse
-
#branch ⇒ Object
String: 仓库当前分支.
-
#cmd ⇒ Object
String: 本次执行指令,如‘merge’,‘checkout’等.
-
#opts ⇒ Object
String: 本次执行参数,如‘–no-ff’,‘–ff’等.
-
#other ⇒ Object
Object: 其他信息,可自定义.
-
#repos ⇒ Object
[String]: 本次执行哪些仓库的名称数组.
-
#type ⇒ Object
String: 本次进入中间态的操作类型,可自定义,如‘merge_in_progress’,‘rebase_in_progress’等。该字段用于索引缓存的中间态信息,需要唯一。.
Instance Method Summary collapse
-
#deserialize(dict) ⇒ Object
反序列化.
-
#initialize(type) ⇒ OperationProgressContext
constructor
A new instance of OperationProgressContext.
-
#serialize ⇒ Object
将中间态对象序列化为Hash.
-
#validate? ⇒ Boolean
校验中间态是否合法,仓库可缺省,若缺省则表示所有仓库.
Constructor Details
#initialize(type) ⇒ OperationProgressContext
Returns a new instance of OperationProgressContext.
21 22 23 24 |
# File 'lib/m-git/foundation/operation_progress_manager.rb', line 21 def initialize(type) self.type = type self.other = {} end |
Instance Attribute Details
#branch ⇒ Object
String: 仓库当前分支
17 18 19 |
# File 'lib/m-git/foundation/operation_progress_manager.rb', line 17 def branch @branch end |
#cmd ⇒ Object
String: 本次执行指令,如‘merge’,‘checkout’等
15 16 17 |
# File 'lib/m-git/foundation/operation_progress_manager.rb', line 15 def cmd @cmd end |
#opts ⇒ Object
String: 本次执行参数,如‘–no-ff’,‘–ff’等
16 17 18 |
# File 'lib/m-git/foundation/operation_progress_manager.rb', line 16 def opts @opts end |
#other ⇒ Object
Object: 其他信息,可自定义
19 20 21 |
# File 'lib/m-git/foundation/operation_progress_manager.rb', line 19 def other @other end |
#repos ⇒ Object
[String]: 本次执行哪些仓库的名称数组
18 19 20 |
# File 'lib/m-git/foundation/operation_progress_manager.rb', line 18 def repos @repos end |
#type ⇒ Object
String: 本次进入中间态的操作类型,可自定义,如‘merge_in_progress’,‘rebase_in_progress’等。该字段用于索引缓存的中间态信息,需要唯一。
14 15 16 |
# File 'lib/m-git/foundation/operation_progress_manager.rb', line 14 def type @type end |
Instance Method Details
#deserialize(dict) ⇒ Object
反序列化
41 42 43 44 45 46 47 |
# File 'lib/m-git/foundation/operation_progress_manager.rb', line 41 def deserialize(dict) self.cmd = dict[CONTEXT_CMD] self.opts = dict[CONTEXT_OPTS] self.branch = dict[CONTEXT_BRANCH] self.repos = dict[CONTEXT_REPOS] self.other = dict[CONTEXT_OTHER] end |
#serialize ⇒ Object
将中间态对象序列化为Hash
27 28 29 30 31 32 33 34 35 |
# File 'lib/m-git/foundation/operation_progress_manager.rb', line 27 def serialize return { CONTEXT_CMD => self.cmd, CONTEXT_OPTS => self.opts, CONTEXT_BRANCH => self.branch, CONTEXT_REPOS => self.repos, CONTEXT_OTHER => self.other } end |
#validate? ⇒ Boolean
校验中间态是否合法,仓库可缺省,若缺省则表示所有仓库
53 54 55 |
# File 'lib/m-git/foundation/operation_progress_manager.rb', line 53 def validate? return !self.cmd.nil? && !self.opts.nil? && !self.branch.nil? end |