Refactor and document Cleanup.

This commit is contained in:
Markus Reiter 2020-08-17 03:52:17 +02:00
parent 7d78949479
commit 5402500635
2 changed files with 111 additions and 106 deletions

View File

@ -6,9 +6,16 @@ require "formula"
require "cask/cask_loader" require "cask/cask_loader"
require "set" require "set"
CLEANUP_DEFAULT_DAYS = 30 module Homebrew
# Helper class for cleaning up the Homebrew cache.
#
# @api private
class Cleanup
CLEANUP_DEFAULT_DAYS = 30
private_constant :CLEANUP_DEFAULT_DAYS
module CleanupRefinement # `Pathname` refinement with helper functions for cleaning up files.
module CleanupRefinement
refine Pathname do refine Pathname do
def incomplete? def incomplete?
extname.end_with?(".incomplete") extname.end_with?(".incomplete")
@ -120,12 +127,10 @@ module CleanupRefinement
false false
end end
end end
end end
using CleanupRefinement using CleanupRefinement
module Homebrew
class Cleanup
extend Predicable extend Predicable
PERIODIC_CLEAN_FILE = (HOMEBREW_CACHE/".cleaned").freeze PERIODIC_CLEAN_FILE = (HOMEBREW_CACHE/".cleaned").freeze

View File

@ -5,9 +5,9 @@ require "cleanup"
require "cask/cache" require "cask/cache"
require "fileutils" require "fileutils"
using CleanupRefinement using Homebrew::Cleanup::CleanupRefinement
describe CleanupRefinement do describe Homebrew::Cleanup::CleanupRefinement do
describe "::prune?" do describe "::prune?" do
alias_matcher :be_pruned, :be_prune alias_matcher :be_pruned, :be_prune