diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index 82a511d19305427ac289195c5ad49e25f07f45ff..e8309f30d115e7353284d0a2073db3f0430d9b5f 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -12,6 +12,9 @@ require "cask/caskroom" require "cask/quarantine" module Homebrew + # Module containing diagnostic checks. + # + # @api private module Diagnostic def self.missing_deps(ff, hide = nil) missing = {} @@ -25,44 +28,7 @@ module Homebrew missing end - class Volumes - def initialize - @volumes = get_mounts - end - - def which(path) - vols = get_mounts path - - # no volume found - return -1 if vols.empty? - - vol_index = @volumes.index(vols[0]) - # volume not found in volume list - return -1 if vol_index.nil? - - vol_index - end - - def get_mounts(path = nil) - vols = [] - # get the volume of path, if path is nil returns all volumes - - args = %w[/bin/df -P] - args << path if path - - Utils.popen_read(*args) do |io| - io.each_line do |line| - case line.chomp - # regex matches: /dev/disk0s2 489562928 440803616 48247312 91% / - when /^.+\s+[0-9]+\s+[0-9]+\s+[0-9]+\s+[0-9]{1,3}%\s+(.+)/ - vols << Regexp.last_match(1) - end - end - end - vols - end - end - + # Diagnostic checks. class Checks def initialize(verbose = true) @verbose = verbose diff --git a/Library/Homebrew/extend/os/mac/diagnostic.rb b/Library/Homebrew/extend/os/mac/diagnostic.rb index d9b9cadf324d3160bdb6ca99b61989dac91397f1..21cd0faee4ea0b44b38330d7f2defaf1c454d00b 100644 --- a/Library/Homebrew/extend/os/mac/diagnostic.rb +++ b/Library/Homebrew/extend/os/mac/diagnostic.rb @@ -2,6 +2,44 @@ module Homebrew module Diagnostic + class Volumes + def initialize + @volumes = get_mounts + end + + def which(path) + vols = get_mounts path + + # no volume found + return -1 if vols.empty? + + vol_index = @volumes.index(vols[0]) + # volume not found in volume list + return -1 if vol_index.nil? + + vol_index + end + + def get_mounts(path = nil) + vols = [] + # get the volume of path, if path is nil returns all volumes + + args = %w[/bin/df -P] + args << path if path + + Utils.popen_read(*args) do |io| + io.each_line do |line| + case line.chomp + # regex matches: /dev/disk0s2 489562928 440803616 48247312 91% / + when /^.+\s+[0-9]+\s+[0-9]+\s+[0-9]+\s+[0-9]{1,3}%\s+(.+)/ + vols << Regexp.last_match(1) + end + end + end + vols + end + end + class Checks undef fatal_build_from_source_checks, supported_configuration_checks, build_from_source_checks