class Envyous::Context
Attributes
confickle_opts[R]
Options that will be passed to confickle. Note: Envyous
will override the :root option.
env_var[R]
Name of the environment variable that will be used as the environment switch.
Default value: 'ENV'
root[R]
The root config folder. Contains the config folders for all environments.
Public Class Methods
new(options)
click to toggle source
# File lib/envyous/core.rb, line 45 def initialize(options) if options.is_a? String options = {root: options} end @root = options.fetch(:root) @env_var = options.fetch(:env_var, 'ENV').to_s @confickle_opts = options.fetch(:confickle_opts, {}) end
Public Instance Methods
confickle()
click to toggle source
# File lib/envyous/core.rb, line 86 def confickle opts = confickle_opts.merge( root: confickle_root ) Confickle.new(opts) end
confickle_root()
click to toggle source
# File lib/envyous/core.rb, line 82 def confickle_root @confickle_root ||= File.join(root, "environments", env_name) end
env_name()
click to toggle source
# File lib/envyous/core.rb, line 65 def env_name @env_name ||= begin name = ENV.fetch(env_var) do envyous_opts.fetch(:env) do raise EnvironmentNotSpecified end end if name.empty? raise EnvironmentNameIsEmpty end name end end
envyous_opts()
click to toggle source
# File lib/envyous/core.rb, line 55 def envyous_opts @envyous_opts ||= begin File.open(File.join(root, "envyous.json")) do |fin| JSON.parse(fin.read, symbolize_names: true) end end end