Class: Semaph::Model::Workflow
- Inherits:
-
Object
- Object
- Semaph::Model::Workflow
- Defined in:
- lib/semaph/model/workflow.rb
Instance Attribute Summary collapse
-
#branch ⇒ Object
readonly
Returns the value of attribute branch.
-
#branch_id ⇒ Object
readonly
Returns the value of attribute branch_id.
-
#commit ⇒ Object
readonly
Returns the value of attribute commit.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#sha ⇒ Object
readonly
Returns the value of attribute sha.
Instance Method Summary collapse
- #created ⇒ Object
- #description ⇒ Object
- #extract_git_details ⇒ Object
-
#initialize(project, raw) ⇒ Workflow
constructor
A new instance of Workflow.
- #pipeline_collection ⇒ Object
- #rerun ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(project, raw) ⇒ Workflow
Returns a new instance of Workflow.
9 10 11 12 13 14 15 16 17 |
# File 'lib/semaph/model/workflow.rb', line 9 def initialize(project, raw) @project = project @raw = raw @id = raw["wf_id"] @created_at = Time.at(raw["created_at"]["seconds"].to_i) @branch = raw["branch_name"] @branch_id = raw["branch_id"] extract_git_details end |
Instance Attribute Details
#branch ⇒ Object (readonly)
Returns the value of attribute branch.
7 8 9 |
# File 'lib/semaph/model/workflow.rb', line 7 def branch @branch end |
#branch_id ⇒ Object (readonly)
Returns the value of attribute branch_id.
7 8 9 |
# File 'lib/semaph/model/workflow.rb', line 7 def branch_id @branch_id end |
#commit ⇒ Object (readonly)
Returns the value of attribute commit.
7 8 9 |
# File 'lib/semaph/model/workflow.rb', line 7 def commit @commit end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
7 8 9 |
# File 'lib/semaph/model/workflow.rb', line 7 def created_at @created_at end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/semaph/model/workflow.rb', line 7 def id @id end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
7 8 9 |
# File 'lib/semaph/model/workflow.rb', line 7 def project @project end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
7 8 9 |
# File 'lib/semaph/model/workflow.rb', line 7 def raw @raw end |
#sha ⇒ Object (readonly)
Returns the value of attribute sha.
7 8 9 |
# File 'lib/semaph/model/workflow.rb', line 7 def sha @sha end |
Instance Method Details
#created ⇒ Object
35 36 37 |
# File 'lib/semaph/model/workflow.rb', line 35 def created Semaph::Formatting.time(created_at) end |
#description ⇒ Object
39 40 41 |
# File 'lib/semaph/model/workflow.rb', line 39 def description [created, branch, commit].join(" ") end |
#extract_git_details ⇒ Object
19 20 21 22 23 |
# File 'lib/semaph/model/workflow.rb', line 19 def extract_git_details @sha = raw["commit_sha"] @commit = @sha.slice(0..10) @commit = `git log -n 1 --format="%h %an %s" #{sha}`.chomp if `git cat-file -t #{sha} 2>&1`.chomp == "commit" end |
#pipeline_collection ⇒ Object
25 26 27 |
# File 'lib/semaph/model/workflow.rb', line 25 def pipeline_collection @pipeline_collection ||= PipelineCollection.new(self) end |
#rerun ⇒ Object
29 30 31 32 33 |
# File 'lib/semaph/model/workflow.rb', line 29 def rerun rerun_response = project.client.rerun_workflow(@id) workflow_response = project.client.workflow(rerun_response["wf_id"]) Workflow.new(project, workflow_response["workflow"]) end |
#stop ⇒ Object
43 44 45 |
# File 'lib/semaph/model/workflow.rb', line 43 def stop project.client.stop_workflow(@id) end |