Sha256: b7eb217633a1ac613ea79195524027ebe0c23a505dc8b0c374828580c198db47

Contents?: true

Size: 664 Bytes

Versions: 1

Compression:

Stored size: 664 Bytes

Contents

require "envious/railtie"

module Envious
  extend self

  def load_env(specific_environment = nil)
    environment = (specific_environment || self.environment).to_s
    add_to_environment(default_vars.merge(environment_vars))
  end

  def file 
    @file ||= Rails.root.join('config/environment_vars.yml')
  end

  def yaml
    @yaml ||= File.exist?(file) ? YAML.load(File.read(file)) : {}
  end

  def environment
    Rails.env
  end

  def default_vars()
    yaml.reject { |_, v| Hash === v }
  end

  def environment_vars
    yaml.fetch(environment, {})
  end

  def add_to_environment(hash)
    hash.each { |key, value| ENV[key.to_s] = value.to_s }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
envious-0.1.1 lib/envious.rb