module EnvLoader

Constants

VERSION

Public Class Methods

read(config_file = File.join('config', 'env_variables.yml')) click to toggle source

DEPRECATED (<= 0.2.0): Legacy setup which will be replaced by the above

# File lib/env_loader.rb, line 21
def self.read(config_file = File.join('config', 'env_variables.yml'))
  config(config_file: config_file)
end
setup_microservice() click to toggle source

A .microservices-config.yml file must be placed at the parent directory of the microservice

# File lib/env_loader.rb, line 13
def self.setup_microservice
  subtree_key = environment
  subtree_key += ".#{Rails.application.class.parent_name.underscore}" if defined?(Rails)
  config(config_file: File.join('..', '.microservices-config.yml'), config_subtree_key: subtree_key)
end
setup_monolith() click to toggle source

A .monolith-config.yml file must be placed at the root of the monolith

# File lib/env_loader.rb, line 8
def self.setup_monolith
  config(config_file: File.join('.monolith-config.yml'), config_subtree_key: environment)
end

Private Class Methods

config(config_file: nil, config_content: nil, config_subtree_key: nil) click to toggle source
# File lib/env_loader.rb, line 31
def self.config(config_file: nil, config_content: nil, config_subtree_key: nil)
  configurator = Configurator.new(config_file: config_file, config_content: config_content, config_subtree_key: config_subtree_key)
  configurator.expose_values_as_environment_variables if configurator
end
environment() click to toggle source
# File lib/env_loader.rb, line 27
def self.environment
  Rails.env if defined?(Rails)
end