Module: Pruner::Branches
- Extended by:
- MessageFormatter
- Defined in:
- lib/pruner/branches.rb
Class Method Summary collapse
-
.branches ⇒ array
All branches.
-
.canceled_message ⇒ string
Canceled message.
-
.confirmation_message ⇒ string
Confirmation message that the branches were removed.
-
.confirmation_prompt ⇒ boolean
Prompt to confirm deletion of branches.
-
.confirmed_selections ⇒ array
Selected branches for deletion.
-
.delete(selections) ⇒ string
Loop to delete the selected branches.
-
.git ⇒ object
Initialize new Git object.
-
.no_selections ⇒ string
No selection message.
-
.prompt ⇒ object
Initialize new TTY Prompt.
Methods included from MessageFormatter
abort_message, body_message, title_message
Class Method Details
.branches ⇒ array
All branches
29 30 31 |
# File 'lib/pruner/branches.rb', line 29 def branches git.branches.local.to_a end |
.canceled_message ⇒ string
Canceled message
91 92 93 |
# File 'lib/pruner/branches.rb', line 91 def ("Operation canceled by user.") end |
.confirmation_message ⇒ string
Confirmation message that the branches were removed
73 74 75 |
# File 'lib/pruner/branches.rb', line 73 def ("Branches Deleted") end |
.confirmation_prompt ⇒ boolean
Prompt to confirm deletion of branches
63 64 65 66 |
# File 'lib/pruner/branches.rb', line 63 def confirmation_prompt ("Are you sure you want to delete these branches?") prompt.yes?("→") end |
.confirmed_selections ⇒ array
Selected branches for deletion
52 53 54 55 56 |
# File 'lib/pruner/branches.rb', line 52 def confirmed_selections selections = prompt.multi_select(("Select branches to delete"), branches) no_selections if selections.empty? confirmation_prompt ? selections : end |
.delete(selections) ⇒ string
Loop to delete the selected branches
38 39 40 41 42 43 44 45 |
# File 'lib/pruner/branches.rb', line 38 def delete(selections) ("Deleting Branches") selections.each do |s| s.delete puts "- #{s}" end end |
.git ⇒ object
Initialize new Git object
20 21 22 |
# File 'lib/pruner/branches.rb', line 20 def git @git ||= Git.open(`pwd`.strip) end |
.no_selections ⇒ string
No selection message
82 83 84 |
# File 'lib/pruner/branches.rb', line 82 def no_selections ("No selections were made.") end |
.prompt ⇒ object
Initialize new TTY Prompt
11 12 13 |
# File 'lib/pruner/branches.rb', line 11 def prompt @prompt ||= TTY::Prompt.new end |