Sha256: d78edf955986ebcd1dbfd1d1ac8b608248c52e2503d4cf9af83e5c4339760325

Contents?: true

Size: 886 Bytes

Versions: 2

Compression:

Stored size: 886 Bytes

Contents

# frozen_string_literal: true

# @api private
# @since 0.2.0
class Qonfig::Loaders::YAML < Qonfig::Loaders::Basic
  class << self
    # @param data [String]
    # @return [Object]
    #
    # @raise [Qonfig::YAMLLoaderParseError]
    #
    # @api private
    # @since 0.2.0
    # @version 0.27.0
    def load(data)
      yaml = ERB.new(data).result
      ::YAML.respond_to?(:unsafe_load) ? ::YAML.unsafe_load(yaml) : ::YAML.load(yaml)
    rescue ::Psych::SyntaxError => error
      raise(
        Qonfig::YAMLLoaderParseError.new(
          error.file,
          error.line,
          error.column,
          error.offset,
          error.problem,
          error.context
        ).tap { |exception| exception.set_backtrace(error.backtrace) }
      )
    end

    # @return [Object]
    #
    # @api private
    # @since 0.5.0
    def load_empty_data
      load('{}')
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
qonfig-0.28.0 lib/qonfig/loaders/yaml.rb
qonfig-0.27.0 lib/qonfig/loaders/yaml.rb