Class: Augit::Inspector
- Inherits:
-
Object
- Object
- Augit::Inspector
- Includes:
- ActionView::Helpers::DateHelper, ActionView::Helpers::TextHelper
- Defined in:
- lib/augit/inspector.rb
Instance Attribute Summary collapse
-
#branches ⇒ Object
readonly
Returns the value of attribute branches.
-
#merged ⇒ Object
readonly
Returns the value of attribute merged.
-
#origin ⇒ Object
readonly
Returns the value of attribute origin.
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
-
#term ⇒ Object
readonly
Returns the value of attribute term.
-
#unmerged ⇒ Object
readonly
Returns the value of attribute unmerged.
Instance Method Summary collapse
- #delete(name) ⇒ Object
-
#initialize(options = {}) ⇒ Inspector
constructor
A new instance of Inspector.
- #list ⇒ Object
- #merged_actions ⇒ Object
- #presenter(branch, origin) ⇒ Object
- #prompt(message) ⇒ Object
- #section_message(type, data, filter) ⇒ Object
- #status ⇒ Object
- #unmerged_actions ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Inspector
Returns a new instance of Inspector.
11 12 13 14 15 16 17 18 |
# File 'lib/augit/inspector.rb', line 11 def initialize( = {}) @repo = Augit::Repo.new() @origin = repo.origin @branches = repo.branch_names @merged = repo.merged_branches @unmerged = branches - merged @regexp = [:regexp] end |
Instance Attribute Details
#branches ⇒ Object (readonly)
Returns the value of attribute branches.
9 10 11 |
# File 'lib/augit/inspector.rb', line 9 def branches @branches end |
#merged ⇒ Object (readonly)
Returns the value of attribute merged.
9 10 11 |
# File 'lib/augit/inspector.rb', line 9 def merged @merged end |
#origin ⇒ Object (readonly)
Returns the value of attribute origin.
9 10 11 |
# File 'lib/augit/inspector.rb', line 9 def origin @origin end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
9 10 11 |
# File 'lib/augit/inspector.rb', line 9 def repo @repo end |
#term ⇒ Object (readonly)
Returns the value of attribute term.
9 10 11 |
# File 'lib/augit/inspector.rb', line 9 def term @term end |
#unmerged ⇒ Object (readonly)
Returns the value of attribute unmerged.
9 10 11 |
# File 'lib/augit/inspector.rb', line 9 def unmerged @unmerged end |
Instance Method Details
#delete(name) ⇒ Object
81 82 83 84 85 86 |
# File 'lib/augit/inspector.rb', line 81 def delete(name) print '!'.red puts " Deleting: #{name}" `git push origin :#{name}` puts "Success!".green end |
#list ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/augit/inspector.rb', line 20 def list print "Searching remote branches:" if merged.any? merged_actions else puts "\n> All remote branches that are merged have been deleted".green end if unmerged.any? print_key unmerged_actions else puts "\n> All unmerged remote branches have been deleted".green end end |
#merged_actions ⇒ Object
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/augit/inspector.rb', line 58 def merged_actions puts "#{pluralize(merged.length, 'branch')} merged into master:".green puts " #{merged.join("\n ")}" case prompt("Delete #{pluralize(merged.length, 'branch')}?") when :y; merged.each{|branch| delete(branch) } when :n; when :q; exit end end |
#presenter(branch, origin) ⇒ Object
88 89 90 |
# File 'lib/augit/inspector.rb', line 88 def presenter(branch, origin) Augit::Presenter.new(branch, origin) end |
#prompt(message) ⇒ Object
53 54 55 56 |
# File 'lib/augit/inspector.rb', line 53 def prompt() choice = ask("#{} |(y)es, (N)o, (q)uit|".cyan) choice.strip.downcase.to_sym end |
#section_message(type, data, filter) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/augit/inspector.rb', line 37 def (type, data, filter) filter = @regexp ? "matching /#{@regexp}/ " : '' branches = pluralize(data.length, 'branch') body = "#{type} into master" = "#{branches} #{filter}#{body}" data.any? ? "#{}:" : end |
#status ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/augit/inspector.rb', line 45 def status puts ('merged', merged, @regexp).green puts " #{merged.join("\n ")}" puts ('not merged', unmerged, @regexp).red puts " #{unmerged.join("\n ")}" end |
#unmerged_actions ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/augit/inspector.rb', line 69 def unmerged_actions unmerged.each do |branch| presenter(branch, origin).print case prompt("Delete #{branch}?") when :y; delete(branch) when :n; when :q; exit end end end |