Sha256: 8fcd9dbe4081b38a4e5940d96d6a72bc6bc44eba71db92d9a2387bb2d4b3a624

Contents?: true

Size: 811 Bytes

Versions: 3

Compression:

Stored size: 811 Bytes

Contents

# frozen_string_literal: true

module Qonfig
  module Loaders
    # @api private
    # @since 0.2.0
    module YAML
      class << self
        # @param data [String]
        # @return [Object]
        #
        # @api private
        # @since 0.2.0
        def load(data)
          ::YAML.load(ERB.new(data).result)
        end

        # @param file_path [String]
        # @option fail_on_unexist [Boolean]
        # @return [Object]
        #
        # @raise [Qonfig::FileNotFoundError]
        #
        # @api private
        # @since 0.2.0
        def load_file(file_path, fail_on_unexist: true)
          load(::File.read(file_path))
        rescue Errno::ENOENT => error
          fail_on_unexist ? (raise Qonfig::FileNotFoundError, error.message) : load('{}')
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
qonfig-0.4.0 lib/qonfig/loaders/yaml.rb
qonfig-0.3.0 lib/qonfig/loaders/yaml.rb
qonfig-0.2.0 lib/qonfig/loaders/yaml.rb