Module: Facter::Util::Resolvers::FilesystemHelper

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

Overview

Since:

  • 2.0.0

Constant Summary collapse

MOUNT_KEYS =

Since:

  • 2.0.0

%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

Since:

  • 2.0.0



23
24
25
26
27
28
29
30
31
# File 'lib/facter/util/resolvers/filesystem_helper.rb', line 23

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

Since:

  • 2.0.0



18
19
20
21
# File 'lib/facter/util/resolvers/filesystem_helper.rb', line 18

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

.read_mountpointsObject

Since:

  • 2.0.0



11
12
13
14
15
16
# File 'lib/facter/util/resolvers/filesystem_helper.rb', line 11

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