Sha256: d2c14f4b967eb65f4d72cf0f195862893937f3156889fe32d8baa588b4356f47

Contents?: true

Size: 693 Bytes

Versions: 41

Compression:

Stored size: 693 Bytes

Contents

# frozen_string_literal: true

module Facter
  module Util
    class FileHelper
      @log = Log.new(self)

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

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

          log_failed_to_read(path)
          default_return
        end

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

          log_failed_to_read(path)
          default_return
        end

        private

        def log_failed_to_read(path)
          @log.debug(DEBUG_MESSAGE % path)
        end
      end
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
facter-4.2.5 lib/facter/util/file_helper.rb
facter-4.2.4 lib/facter/util/file_helper.rb
facter-4.2.3 lib/facter/util/file_helper.rb
facter-4.2.2 lib/facter/util/file_helper.rb
facter-4.2.1 lib/facter/util/file_helper.rb
facter-4.2.0 lib/facter/util/file_helper.rb
facter-4.1.1 lib/facter/util/file_helper.rb
facter-4.1.0 lib/facter/util/file_helper.rb
facter-4.0.52 lib/facter/util/file_helper.rb
facter-4.0.51 lib/facter/util/file_helper.rb
facter-4.0.50 lib/facter/util/file_helper.rb
facter-4.0.49 lib/facter/util/file_helper.rb
facter-4.0.48 lib/facter/util/file_helper.rb
facter-4.0.47 lib/facter/util/file_helper.rb
facter-4.0.46 lib/facter/util/file_helper.rb
facter-4.0.44 lib/facter/util/file_helper.rb
facter-4.0.43 lib/facter/util/file_helper.rb
facter-4.0.42 lib/facter/util/file_helper.rb
facter-4.0.41 lib/facter/util/file_helper.rb
facter-4.0.40 lib/facter/util/file_helper.rb