Sha256: 44c9bee0beb656ec103d516a0e947cf087088bfa9007da29d1831a37de40ade6

Contents?: true

Size: 777 Bytes

Versions: 2

Compression:

Stored size: 777 Bytes

Contents

# Restores Bundler ENV vars that were moved when spawning the Ansible process.
# 
# See `//lib/qb/util/bundler.rb` for documentation on how and why we do this.
# 

# Keep track of the ENV vars we overwrite so we can swap them back in
# later when we need to do things like shell out.
#       
$qb_replaced_env_vars = {}


def qb_rebundle!
  ENV.each do |k, v|
    if k.start_with? 'QB_BUNDLER_ENV_'
      key = k.sub 'QB_BUNDLER_ENV_', ''
      $qb_replaced_env_vars[key] = [ENV[key], v]
      ENV[key] = v
    end
  end
end


def qb_unbundle! &block
  $qb_replaced_env_vars.each do |key, (original, replacement)|
    ENV[key] = original
  end
  
  $qb_replaced_env_vars = {}
  
  if block
    block.call.tap { qb_rebundle! }
  end
end


qb_rebundle!


require 'bundler/setup'

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
qb-0.4.1 load/rebundle.rb
qb-0.4.0 load/rebundle.rb