Sha256: 667f33bf8cbeb1c116ba022d4dbb5c9909ce7b7c2fc054576461b4373fe24801
Contents?: true
Size: 1.44 KB
Versions: 2
Compression:
Stored size: 1.44 KB
Contents
class ENVied class Configuration attr_reader :current_group, :coercer def initialize(**options, &block) @coercer = options.fetch(:coercer, Coercer.new) @key_alias = options[:key_alias] instance_eval(&block) if block_given? end def key_alias!(value = false, &block) @key_alias = block_given? ? block.call : value end def key_alias @key_alias && @key_alias.to_s.upcase end def enable_defaults!(*args) raise "Defaults are no longer supported. See https://gitlab.com/envied/envied/tree/master#what-happened-to-default-values for the recommended upgrade-path, or pin the gem to 0.9-release (e.g. `gem 'envied', '~> 0.9.2'`) to keep using defaults." end def self.load(**options) envfile = File.expand_path('Envfile') new(options).tap do |v| v.instance_eval(File.read(envfile), envfile) end end def variable(name, type = :string, **options) unless coercer.supported_type?(type) raise ArgumentError, "#{type.inspect} is not a supported type. Should be one of #{coercer.supported_types}" end options[:group] = current_group if current_group variables << ENVied::Variable.new(name, type, options) end def group(*names, &block) names.each do |name| @current_group = name.to_sym yield end ensure @current_group = nil end def variables @variables ||= [] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
envied-0.10.0.alpha3 | lib/envied/configuration.rb |
envied-0.10.0.alpha1 | lib/envied/configuration.rb |