Class: Homebrew::Diagnostic::Volumes
- Inherits:
-
Object
- Object
- Homebrew::Diagnostic::Volumes
- Defined in:
- Library/Homebrew/diagnostic.rb
Instance Method Summary collapse
- #get_mounts(path = nil) ⇒ Object
-
#initialize ⇒ Volumes
constructor
A new instance of Volumes.
- #which(path) ⇒ Object
Constructor Details
#initialize ⇒ Volumes
24 25 26 |
# File 'Library/Homebrew/diagnostic.rb', line 24 def initialize @volumes = get_mounts end |
Instance Method Details
#get_mounts(path = nil) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'Library/Homebrew/diagnostic.rb', line 40 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 |
#which(path) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'Library/Homebrew/diagnostic.rb', line 28 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 |