Sha256: a2f1569a5a279e1cb9ac1a662e0984093561d4b48800ea801b30983a825c9b8b
Contents?: true
Size: 890 Bytes
Versions: 6
Compression:
Stored size: 890 Bytes
Contents
require 'yaml' require_relative 'environment' module Config module Factory module Environments DEFAULT_ENVIRONMENT = :production STANDARD_ENVIRONMENTS = [:defaults, :development, :test, :stage, :staging, :production].freeze STANDARD_ENVIRONMENTS_NOT_FOUND = "No standard environment tags (#{STANDARD_ENVIRONMENTS.join(', ')}) found; is this really a multiple-environment configuration?" def self.load_file(path) hash = YAML.load_file(path) fail IOError, "Unable to load YAML file #{path}" unless hash && hash.is_a?(Hash) load_hash(hash) end def self.load_hash(hash) warn STANDARD_ENVIRONMENTS_NOT_FOUND unless STANDARD_ENVIRONMENTS.any? { |k| hash.key?(k.to_s) } hash.map do |k, v| k2 = k.to_sym [k2, Environment.new(name: k2, configs: v)] end.to_h end end end end
Version data entries
6 entries across 6 versions & 1 rubygems