Class: PT::Flow::Branch
- Inherits:
-
Object
- Object
- PT::Flow::Branch
- Defined in:
- lib/pt-flow/branch.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name) ⇒ Branch
constructor
A new instance of Branch.
- #release_branch? ⇒ Boolean
- #target ⇒ Object
- #task_id ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name) ⇒ Branch
Returns a new instance of Branch.
15 16 17 |
# File 'lib/pt-flow/branch.rb', line 15 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/pt-flow/branch.rb', line 5 def name @name end |
Class Method Details
.current ⇒ Object
7 8 9 |
# File 'lib/pt-flow/branch.rb', line 7 def self.current new(`git rev-parse --abbrev-ref HEAD`.strip) end |
.from_task(task) ⇒ Object
11 12 13 |
# File 'lib/pt-flow/branch.rb', line 11 def self.from_task(task) new("#{current.target}.#{task.name.parameterize[0..50]}.#{task.id}") end |
Instance Method Details
#release_branch? ⇒ Boolean
23 24 25 |
# File 'lib/pt-flow/branch.rb', line 23 def release_branch? target != 'master' end |
#target ⇒ Object
19 20 21 |
# File 'lib/pt-flow/branch.rb', line 19 def target name.split('.').first end |
#task_id ⇒ Object
27 28 29 |
# File 'lib/pt-flow/branch.rb', line 27 def task_id name[/\d+$/] || '' end |
#to_s ⇒ Object
31 32 33 |
# File 'lib/pt-flow/branch.rb', line 31 def to_s name end |