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.



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

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

Class Method Details

.currentObject



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

Returns:

  • (Boolean)


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

def release_branch?
  target != 'master'
end

#targetObject



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

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

#task_idObject



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

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

#to_sObject



31
32
33
# File 'lib/pt-flow/branch.rb', line 31

def to_s
  name
end