module Pruner::Branches
Public Class Methods
branches()
click to toggle source
All branches
@return [array] all branches
# File lib/pruner/branches.rb, line 29 def branches git.branches.local.to_a end
canceled_message()
click to toggle source
Canceled message
@return [string] message indicating the operation was canceled
# File lib/pruner/branches.rb, line 91 def canceled_message abort_message("Operation canceled by user.") end
confirmation_message()
click to toggle source
Confirmation message that the branches were removed
@return [string] Branches
deleted message
# File lib/pruner/branches.rb, line 73 def confirmation_message title_message("Branches Deleted") end
confirmation_prompt()
click to toggle source
Prompt to confirm deletion of branches
@return [boolean] T:F depending on selection
# File lib/pruner/branches.rb, line 63 def confirmation_prompt title_message("Are you sure you want to delete these branches?") prompt.yes?("→") end
confirmed_selections()
click to toggle source
Selected branches for deletion
@return [array] array of branch names
# File lib/pruner/branches.rb, line 52 def confirmed_selections selections = prompt.multi_select(title_message("Select branches to delete"), branches) no_selections if selections.empty? confirmation_prompt ? selections : canceled_message end
delete(selections)
click to toggle source
Loop to delete the selected branches
@return [string] confirmation_message
# File lib/pruner/branches.rb, line 38 def delete(selections) title_message("Deleting Branches") selections.each do |s| s.delete puts "- #{s}" end confirmation_message end
git()
click to toggle source
Initialize new Git object
@return [object] Git
# File lib/pruner/branches.rb, line 20 def git @git ||= Git.open(`pwd`.strip) end
no_selections()
click to toggle source
No selection message
@return [string] message indicating no selections were made
# File lib/pruner/branches.rb, line 82 def no_selections abort_message("No selections were made.") end
prompt()
click to toggle source
Initialize new TTY Prompt
@return [object] TTY::Prompt
# File lib/pruner/branches.rb, line 11 def prompt @prompt ||= TTY::Prompt.new end