Sha256: 24089bcf9bd18b43728c55e9c102084450766733fb7f1b4d14f3d8402d344449
Contents?: true
Size: 1020 Bytes
Versions: 2
Compression:
Stored size: 1020 Bytes
Contents
# frozen_string_literal: true module Facter module FilesystemHelper MOUNT_KEYS = %i[device filesystem path options available available_bytes size size_bytes used used_bytes capacity].freeze class << self def read_mountpoints require 'sys/filesystem' force_utf(Sys::Filesystem.mounts) end def read_mountpoint_stats(path) require 'sys/filesystem' Sys::Filesystem.stat(path) end def compute_capacity(used, total) if used == total '100%' elsif used.positive? "#{format('%.2f', 100.0 * used.to_f / total.to_f)}%" else '0%' end end private def force_utf(mounts) mounts.each do |mount| mount.name.force_encoding('UTF-8') mount.mount_type.force_encoding('UTF-8') mount.mount_point.force_encoding('UTF-8') mount.options.force_encoding('UTF-8') end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
facter-4.0.20 | lib/resolvers/utils/filesystem_helper.rb |
facter-4.0.19 | lib/resolvers/utils/filesystem_helper.rb |