aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cask/lib
diff options
context:
space:
mode:
authorMarkus Reiter2017-05-19 20:27:25 +0200
committerMarkus Reiter2017-05-22 02:51:16 +0200
commitb7347dcc445fe1b3a61a79152c09c0d52fc4ea28 (patch)
tree6e97b2d7df2baa15f1b18b50219fd4acf8acc31d /Library/Homebrew/cask/lib
parent58db95c1d23b8269dffd654afb0b8b12b46a51ce (diff)
downloadbrew-b7347dcc445fe1b3a61a79152c09c0d52fc4ea28.tar.bz2
Refactor `CLI::Cleanup`.
Diffstat (limited to 'Library/Homebrew/cask/lib')
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/cleanup.rb22
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/doctor.rb2
2 files changed, 7 insertions, 17 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/cli/cleanup.rb b/Library/Homebrew/cask/lib/hbc/cli/cleanup.rb
index 9ebccabd0..a62b8d069 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/cleanup.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/cleanup.rb
@@ -13,29 +13,19 @@ module Hbc
end
def self.run(*args)
- if args.empty?
- default.cleanup!
- else
- default.cleanup(args)
- end
- end
-
- def self.default
- @default ||= new(Hbc.cache, CLI.outdated?)
+ new(*args).run
end
attr_reader :cache_location, :outdated_only
- def initialize(cache_location, outdated_only)
+
+ def initialize(*args, cache_location: Hbc.cache, outdated_only: CLI.outdated?)
+ @args = args
@cache_location = Pathname.new(cache_location)
@outdated_only = outdated_only
end
- def cleanup!
- remove_cache_files
- end
-
- def cleanup(tokens)
- remove_cache_files(*tokens)
+ def run
+ remove_cache_files(*@args)
end
def cache_files
diff --git a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb
index 031f78824..11917ae6b 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb
@@ -107,7 +107,7 @@ module Hbc
end
def self.render_cached_downloads
- cleanup = CLI::Cleanup.default
+ cleanup = CLI::Cleanup.new
count = cleanup.cache_files.count
size = cleanup.disk_cleanup_size
msg = user_tilde(Hbc.cache.to_s)