Class: BrewCaskTools::Tasks::Cleanup
- Defined in:
- lib/bct/tasks/cleanup.rb
Overview
Cleanup task
Instance Method Summary collapse
- #clean ⇒ Object
- #clean_block ⇒ Object
- #compile ⇒ Object
-
#initialize(casks) ⇒ Cleanup
constructor
A new instance of Cleanup.
Methods inherited from Caskroom
Constructor Details
#initialize(casks) ⇒ Cleanup
Returns a new instance of Cleanup.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/bct/tasks/cleanup.rb', line 10 def initialize(casks) super() @cleaned = [] if casks.empty? .total = caskroom.casks.length .log "\nLooking for casks to cleanup..." @cleaned = compile else @cleaned = casks.map { |c| caskroom.get(c) } return say 'Invalid cask specified', :red if @cleaned.compact.empty? end clean end |
Instance Method Details
#clean ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/bct/tasks/cleanup.rb', line 37 def clean return say "\nNo cleanup operations are necessary", :green if @cleaned.empty? @cleaned.each do |cask| cask.cleanup(&clean_block) end end |
#clean_block ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/bct/tasks/cleanup.rb', line 45 def clean_block proc do |cask, versions| name = cask.name say "Cleaning up #{name}", :yellow if cask.deprecated? && no?("#{name} has been deprecated. Ok to remove all versions?", :red) say 'No action taken.', :red next end say "Removed #{versions.length} old version(s)", :yellow end end |
#compile ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/bct/tasks/cleanup.rb', line 27 def compile cleaned = [] caskroom.enumerate do |cask| increment(cask) cleaned << cask if cask.can_cleanup? end cleaned end |