class Facter::Util::FileHelper
Constants
- DEBUG_MESSAGE
Public Class Methods
dir_children(path)
click to toggle source
This previously acted as a helper method for versions of Ruby older than 2.5, before Dir.children was added. As it isn’t a private method, we can’t remove it entirely until the next major Facter
release (presumably Facter
5).
# File lib/facter/util/file_helper.rb, line 29 def dir_children(path) Dir.children(path) end
safe_read(path, default_return = '')
click to toggle source
# File lib/facter/util/file_helper.rb, line 11 def safe_read(path, default_return = '') return File.read(path, encoding: Encoding::UTF_8) if File.readable?(path) log_failed_to_read(path) default_return end
safe_readlines(path, default_return = [])
click to toggle source
# File lib/facter/util/file_helper.rb, line 18 def safe_readlines(path, default_return = []) return File.readlines(path, encoding: Encoding::UTF_8) if File.readable?(path) log_failed_to_read(path) default_return end
Private Class Methods
log_failed_to_read(path)
click to toggle source
# File lib/facter/util/file_helper.rb, line 35 def log_failed_to_read(path) @log.debug(DEBUG_MESSAGE % path) end