Module: Facter::FilesystemHelper

Included in:
Resolvers::Macosx::Mountpoints, Resolvers::Mountpoints, Resolvers::Solaris::Mountpoints
Defined in:
lib/facter/resolvers/utils/filesystem_helper.rb

Constant Summary collapse

MOUNT_KEYS =
%i[device filesystem path options
available available_bytes size
size_bytes used used_bytes capacity].freeze

Class Method Summary collapse

Class Method Details

.compute_capacity(used, total) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/facter/resolvers/utils/filesystem_helper.rb', line 21

def compute_capacity(used, total)
  if used == total
    '100%'
  elsif used.positive?
    "#{format('%<value>.2f', value: (used / total.to_f * 100))}%"
  else
    '0%'
  end
end

.read_mountpoint_stats(path) ⇒ Object



16
17
18
19
# File 'lib/facter/resolvers/utils/filesystem_helper.rb', line 16

def read_mountpoint_stats(path)
  require 'sys/filesystem'
  Sys::Filesystem.stat(path)
end

.read_mountpointsObject



9
10
11
12
13
14
# File 'lib/facter/resolvers/utils/filesystem_helper.rb', line 9

def read_mountpoints
  # TODO: this require must be replaced with "require 'sys/filesystem'" when a new release of
  # djberg96/sys-filesystem gem is available
  require_relative '../../patches/sysfilesystem/sys/statvfs.rb'
  force_utf(Sys::Filesystem.mounts)
end