Remove redundant Utils.
This commit is contained in:
parent
1959cc3f2d
commit
e0acaeef81
@ -62,7 +62,7 @@ module Hbc
|
|||||||
end
|
end
|
||||||
|
|
||||||
def disk_cleanup_size
|
def disk_cleanup_size
|
||||||
Utils.size_in_bytes(cache_files)
|
cache_files.map(&:disk_usage).inject(:+)
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_cache_files(*tokens)
|
def remove_cache_files(*tokens)
|
||||||
|
|||||||
@ -24,7 +24,7 @@ module Hbc
|
|||||||
end
|
end
|
||||||
|
|
||||||
def install_rubocop
|
def install_rubocop
|
||||||
Utils.capture_stderr do
|
capture_stderr do
|
||||||
begin
|
begin
|
||||||
Homebrew.install_gem_setup_path! "rubocop-cask", HOMEBREW_RUBOCOP_CASK_VERSION, "rubocop"
|
Homebrew.install_gem_setup_path! "rubocop-cask", HOMEBREW_RUBOCOP_CASK_VERSION, "rubocop"
|
||||||
rescue SystemExit
|
rescue SystemExit
|
||||||
|
|||||||
@ -90,27 +90,6 @@ module Hbc
|
|||||||
Etc.getpwuid(Process.euid).name
|
Etc.getpwuid(Process.euid).name
|
||||||
end
|
end
|
||||||
|
|
||||||
# paths that "look" descendant (textually) will still
|
|
||||||
# return false unless both the given paths exist
|
|
||||||
def self.file_is_descendant(file, dir)
|
|
||||||
file = Pathname.new(file)
|
|
||||||
dir = Pathname.new(dir)
|
|
||||||
return false unless file.exist? && dir.exist?
|
|
||||||
unless dir.directory?
|
|
||||||
onoe "Argument must be a directory: '#{dir}'"
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
unless file.absolute? && dir.absolute?
|
|
||||||
onoe "Both arguments must be absolute: '#{file}', '#{dir}'"
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
while file.parent != file
|
|
||||||
return true if File.identical?(file, dir)
|
|
||||||
file = file.parent
|
|
||||||
end
|
|
||||||
false
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.path_occupied?(path)
|
def self.path_occupied?(path)
|
||||||
File.exist?(path) || File.symlink?(path)
|
File.exist?(path) || File.symlink?(path)
|
||||||
end
|
end
|
||||||
@ -145,18 +124,5 @@ module Hbc
|
|||||||
timestamp.concat(fraction)
|
timestamp.concat(fraction)
|
||||||
container_path.join(timestamp)
|
container_path.join(timestamp)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.size_in_bytes(files)
|
|
||||||
Array(files).reduce(0) { |acc, elem| acc + (File.size?(elem) || 0) }
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.capture_stderr
|
|
||||||
previous_stderr = $stderr
|
|
||||||
$stderr = StringIO.new
|
|
||||||
yield
|
|
||||||
$stderr.string
|
|
||||||
ensure
|
|
||||||
$stderr = previous_stderr
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -19,7 +19,7 @@ describe Hbc::CLI::Cleanup, :cask do
|
|||||||
|
|
||||||
cached_downloads.each(&FileUtils.method(:touch))
|
cached_downloads.each(&FileUtils.method(:touch))
|
||||||
|
|
||||||
cleanup_size = Hbc::Utils.size_in_bytes(cached_downloads[0])
|
cleanup_size = cached_downloads[0].disk_usage
|
||||||
|
|
||||||
expect {
|
expect {
|
||||||
subject.cleanup(cleaned_up_cached_download)
|
subject.cleanup(cleaned_up_cached_download)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user