Skip to content
Snippets Groups Projects
Unverified Commit 8cc4919d authored by Markus Reiter's avatar Markus Reiter Committed by GitHub
Browse files

Merge pull request #8348 from reitermarkus/doc-diagnostic

Refactor and document `Homebrew::Diagnostic`.
parents 958c5c7f d50dc2e1
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment