Class: PT::Flow::Branch

Inherits:
Object
  • Object
show all
Defined in:
lib/pt-flow/branch.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Branch

Returns a new instance of Branch.



16
17
18
# File 'lib/pt-flow/branch.rb', line 16

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/pt-flow/branch.rb', line 6

def name
  @name
end

Class Method Details

.currentObject



8
9
10
# File 'lib/pt-flow/branch.rb', line 8

def self.current
  new(`git rev-parse --abbrev-ref HEAD`.strip)
end

.from_task(task) ⇒ Object



12
13
14
# File 'lib/pt-flow/branch.rb', line 12

def self.from_task(task)
  new("#{current.target}.#{task.name.parameterize[0..50]}.#{task.id}")
end

Instance Method Details

#targetObject



20
21
22
# File 'lib/pt-flow/branch.rb', line 20

def target
  name.split('.').first
end

#task_idObject



24
25
26
# File 'lib/pt-flow/branch.rb', line 24

def task_id
  name[/\d+$/] || ''
end

#to_sObject



28
29
30
# File 'lib/pt-flow/branch.rb', line 28

def to_s
  name
end