aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cask/lib
diff options
context:
space:
mode:
authorMarkus Reiter2017-03-08 02:43:03 +0100
committerGitHub2017-03-08 02:43:03 +0100
commit9a4538a3254297f7830afe16ea5a78fb3a9c0146 (patch)
tree85d190f70d7062d718ed977d5e7b3d99a702d3a8 /Library/Homebrew/cask/lib
parentec7530bcda24ae3039a73285adbbccdf88b5d4e2 (diff)
parente0acaeef816ae73566b2067608a6530b61a8037a (diff)
downloadbrew-9a4538a3254297f7830afe16ea5a78fb3a9c0146.tar.bz2
Merge pull request #2286 from reitermarkus/redundant-utils
Remove redundant `Utils`.
Diffstat (limited to 'Library/Homebrew/cask/lib')
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/cleanup.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/style.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/utils.rb34
3 files changed, 2 insertions, 36 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/cli/cleanup.rb b/Library/Homebrew/cask/lib/hbc/cli/cleanup.rb
index 2273280b9..0bb3c3694 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/cleanup.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/cleanup.rb
@@ -62,7 +62,7 @@ module Hbc
end
def disk_cleanup_size
- Utils.size_in_bytes(cache_files)
+ cache_files.map(&:disk_usage).inject(:+)
end
def remove_cache_files(*tokens)
diff --git a/Library/Homebrew/cask/lib/hbc/cli/style.rb b/Library/Homebrew/cask/lib/hbc/cli/style.rb
index a64a1dbe7..f38d785fc 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/style.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/style.rb
@@ -24,7 +24,7 @@ module Hbc
end
def install_rubocop
- Utils.capture_stderr do
+ capture_stderr do
begin
Homebrew.install_gem_setup_path! "rubocop-cask", HOMEBREW_RUBOCOP_CASK_VERSION, "rubocop"
rescue SystemExit
diff --git a/Library/Homebrew/cask/lib/hbc/utils.rb b/Library/Homebrew/cask/lib/hbc/utils.rb
index ef3e5eda3..7bfc4ea42 100644
--- a/Library/Homebrew/cask/lib/hbc/utils.rb
+++ b/Library/Homebrew/cask/lib/hbc/utils.rb
@@ -90,27 +90,6 @@ module Hbc
Etc.getpwuid(Process.euid).name
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)
File.exist?(path) || File.symlink?(path)
end
@@ -145,18 +124,5 @@ module Hbc
timestamp.concat(fraction)
container_path.join(timestamp)
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