Class: Facter::Util::FileHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/facter/util/file_helper.rb

Constant Summary collapse

DEBUG_MESSAGE =
'File at: %s is not accessible.'

Class Method Summary collapse

Class Method Details

.safe_read(path, default_return = '') ⇒ Object



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

def safe_read(path, default_return = '')
  return File.read(path) if File.readable?(path)

  log_failed_to_read(path)
  default_return
end

.safe_readlines(path, default_return = []) ⇒ Object



18
19
20
21
22
23
# File 'lib/facter/util/file_helper.rb', line 18

def safe_readlines(path, default_return = [])
  return File.readlines(path) if File.readable?(path)

  log_failed_to_read(path)
  default_return
end