File: bundler.rb

package info (click to toggle)
ruby-aruba 2.3.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 968 kB
  • sloc: javascript: 6,850; ruby: 4,010; makefile: 5
file content (34 lines) | stat: -rw-r--r-- 798 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# frozen_string_literal: true

require 'aruba/api/environment'
require 'bundler'

module Aruba
  module Api
    module Bundler
      include Environment

      # Unset variables used by bundler
      def unset_bundler_env_vars
        empty_env = with_environment { with_unbundled_env { ENV.to_h } }
        aruba_env = aruba.environment.to_h
        (aruba_env.keys - empty_env.keys).each do |key|
          delete_environment_variable key
        end
        empty_env.each do |k, v|
          set_environment_variable k, v
        end
      end

      private

      def with_unbundled_env(&block)
        if ::Bundler.respond_to?(:with_unbundled_env)
          ::Bundler.with_unbundled_env(&block)
        else
          ::Bundler.with_clean_env(&block)
        end
      end
    end
  end
end