Sha256: cb0e4ae2fe491f128602c9d48f45bdd69dd997bbf6b4c136809ca432f3bcc01b

Contents?: true

Size: 643 Bytes

Versions: 6

Compression:

Stored size: 643 Bytes

Contents

# frozen_string_literal: true

require 'erb'
require 'yaml'
require 'active_support/hash_with_indifferent_access'

module BlueprintConfig
  module Backend
    class YAML < Base
      def initialize(path = 'config/app.yml')
        @path = path
      end

      def load_keys
        if File.exist?(path)
          parsed = ::YAML.load(File.read(path), aliases: true).deep_symbolize_keys
          parsed.fetch(:default, {}).deep_merge(parsed.fetch(BlueprintConfig.env&.to_sym, {}))
        else
          {}
        end
      end

      private

      def path
        File.expand_path(@path, BlueprintConfig.root)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
blueprint_config-1.4.0 lib/blueprint_config/backend/yaml.rb
blueprint_config-1.3.1 lib/blueprint_config/backend/yaml.rb
blueprint_config-1.3.0 lib/blueprint_config/backend/yaml.rb
blueprint_config-1.2.0 lib/blueprint_config/backend/yaml.rb
blueprint_config-1.1.0 lib/blueprint_config/backend/yaml.rb
blueprint_config-1.0.0 lib/blueprint_config/backend/yaml.rb