Sha256: 655f97f46685607fbffcfa8f85113148434e5ed89d119f03de3b247214d6e0fd

Contents?: true

Size: 554 Bytes

Versions: 1

Compression:

Stored size: 554 Bytes

Contents

require "env_checker/version"
require "yaml"

module EnvChecker

  def self.check(file = nil)
    missing_variables = []
    variables(file).each do |env_v|
      missing_variables << "#{env_v[:name]} #{env_v[:desc]}" if ENV[env_v[:name]].nil?
    end
    send_error(missing_variables) if missing_variables.any?
  end

  private

  def self.send_error(missing_variables)
    # Do nothing, override this to send to anywhere you want
  end

  def self.variables(file)
    file ||= "lib/constants/env_variables.yml"
    YAML.load_file(file) || []
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
env_checker-0.0.1 lib/env_checker.rb