lib/envious.rb in envious-0.1.1 vs lib/envious.rb in envious-0.2.0

- old
+ new

@@ -1,12 +1,16 @@ require "envious/railtie" - +require "pp" module Envious extend self - def load_env(specific_environment = nil) - environment = (specific_environment || self.environment).to_s + def vars_for_heroku() + env_vars = default_vars.merge(environment_vars) + env_vars = env_vars.map { |k, v| "#{k}=#{v}"}.join(' ') + end + + def load_env() add_to_environment(default_vars.merge(environment_vars)) end def file @file ||= Rails.root.join('config/environment_vars.yml') @@ -15,11 +19,11 @@ def yaml @yaml ||= File.exist?(file) ? YAML.load(File.read(file)) : {} end def environment - Rails.env + Rails.env.to_s end def default_vars() yaml.reject { |_, v| Hash === v } end @@ -27,8 +31,8 @@ def environment_vars yaml.fetch(environment, {}) end def add_to_environment(hash) - hash.each { |key, value| ENV[key.to_s] = value.to_s } + hash.each { |key, value| ENV[key.to_s] = value.to_s unless ENV.key?(key.to_s) } end end