class Bundler::EnvironmentPreserver

def backup

Returns:
  • (Hash) -
def backup
  env = @original.clone
  @keys.each do |key|
    value = env[key]
    original_value = env[@prefix + key]
    if !value.nil? && !value.empty? && original_value.nil?
      env[@prefix + key] = value
    end
  end
  env
end

def initialize(env, keys)

Parameters:
  • keys (Array) --
  • env (ENV) --
def initialize(env, keys)
  @original = env.to_hash
  @keys = keys
  @prefix = "BUNDLE_ORIG_"
end

def restore

Returns:
  • (Hash) -
def restore
  env = @original.clone
  @keys.each do |key|
    value_original = env[@prefix + key]
    unless value_original.nil? || value_original.empty?
      env[key] = value_original
      env.delete(@prefix + key)
    end
  end
  env
end