Sha256: 2ca275229b8f7c9e960cd07ff4d24b9c63b9d8ea7d7a9af99be34ae7d2af2cd9

Contents?: true

Size: 1.03 KB

Versions: 15

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

# @api private
# @since 0.17.0
class Qonfig::Loaders::Dynamic < Qonfig::Loaders::Basic
  class << self
    # @param data [String]
    # @return [Object]
    #
    # @raise [Qonfig::DynamicLoaderParseError]
    #
    # @api private
    # @since 0.17.0
    def load(data)
      try_to_load_json_data(data)
    rescue Qonfig::JSONLoaderParseError
      begin
        try_to_load_yaml_data(data)
      rescue Qonfig::YAMLLoaderParseError
        raise Qonfig::DynamicLoaderParseError, 'File data has unknown format'
      end
    end

    # @return [Hash]
    #
    # @api private
    # @since 0.17.0
    def load_empty_data
      {}
    end

    private

    # @param data [String]
    # @return [Object]
    #
    # @api private
    # @since 0.17.0
    def try_to_load_yaml_data(data)
      Qonfig::Loaders::YAML.load(data)
    end

    # @param data [String]
    # @return [Object]
    #
    # @api private
    # @since 0.17.0
    def try_to_load_json_data(data)
      Qonfig::Loaders::JSON.load(data)
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
qonfig-0.28.0 lib/qonfig/loaders/dynamic.rb
qonfig-0.27.0 lib/qonfig/loaders/dynamic.rb
qonfig-0.26.0 lib/qonfig/loaders/dynamic.rb
qonfig-0.25.0 lib/qonfig/loaders/dynamic.rb
qonfig-0.24.1 lib/qonfig/loaders/dynamic.rb
qonfig-0.24.0 lib/qonfig/loaders/dynamic.rb
qonfig-0.23.0 lib/qonfig/loaders/dynamic.rb
qonfig-0.22.0 lib/qonfig/loaders/dynamic.rb
qonfig-0.21.0 lib/qonfig/loaders/dynamic.rb
qonfig-0.20.0 lib/qonfig/loaders/dynamic.rb
qonfig-0.19.1 lib/qonfig/loaders/dynamic.rb
qonfig-0.19.0 lib/qonfig/loaders/dynamic.rb
qonfig-0.18.1 lib/qonfig/loaders/dynamic.rb
qonfig-0.18.0 lib/qonfig/loaders/dynamic.rb
qonfig-0.17.0 lib/qonfig/loaders/dynamic.rb