Class: Git::Managed::Branch
- Inherits:
-
Object
- Object
- Git::Managed::Branch
- Defined in:
- lib/managed.rb,
lib/managed/branch.rb
Instance Attribute Summary collapse
-
#branches ⇒ Object
Returns the value of attribute branches.
-
#branches_to_delete ⇒ Object
Returns the value of attribute branches_to_delete.
-
#current_branch ⇒ Object
Returns the value of attribute current_branch.
Instance Method Summary collapse
- #delete_branch(branch) ⇒ Object
- #delete_branches ⇒ Object
-
#initialize ⇒ Branch
constructor
A new instance of Branch.
- #partition_branches ⇒ Object
Constructor Details
#initialize ⇒ Branch
Returns a new instance of Branch.
4 5 6 7 |
# File 'lib/managed/branch.rb', line 4 def initialize @branches = `git branch`.split /\n/ partition_branches end |
Instance Attribute Details
#branches ⇒ Object
Returns the value of attribute branches.
2 3 4 |
# File 'lib/managed/branch.rb', line 2 def branches @branches end |
#branches_to_delete ⇒ Object
Returns the value of attribute branches_to_delete.
2 3 4 |
# File 'lib/managed/branch.rb', line 2 def branches_to_delete @branches_to_delete end |
#current_branch ⇒ Object
Returns the value of attribute current_branch.
2 3 4 |
# File 'lib/managed/branch.rb', line 2 def current_branch @current_branch end |
Instance Method Details
#delete_branch(branch) ⇒ Object
23 24 25 |
# File 'lib/managed/branch.rb', line 23 def delete_branch branch `git branch -D #{branch}` end |
#delete_branches ⇒ Object
16 17 18 19 20 21 |
# File 'lib/managed/branch.rb', line 16 def delete_branches return false if @branches_to_delete.length == 0 @branches_to_delete.each do |branch| delete_branch( branch.gsub /\s/, '' ) end end |
#partition_branches ⇒ Object
9 10 11 12 13 14 |
# File 'lib/managed/branch.rb', line 9 def partition_branches @current_branch = @branches.select {|branch| branch.match /^\*/}.first @branches_to_delete = @branches.select {|branch| branch != @current_branch } @current_branch.chomp! @current_branch.gsub! /\s|\*/, '' end |