Sha256: 7253c3b1735a3a155581c8cee9c7d4670cf78ec298a89b790dfcce12ca61ce17

Contents?: true

Size: 684 Bytes

Versions: 15

Compression:

Stored size: 684 Bytes

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/core_ext'

module Avm
  module Ruby
    require_sub __FILE__

    class << self
      def on_clean_environment
        on_clean_envvars('BUNDLE', 'RUBY') { yield }
      end

      private

      def on_clean_envvars(*start_with_vars)
        old_values = envvars_starting_with(start_with_vars)
        old_values.keys.each { |k| ENV.delete(k) } # rubocop:disable Style/HashEachMethods
        yield
      ensure
        old_values&.each { |k, v| ENV[k] = v }
      end

      def envvars_starting_with(start_with_vars)
        ENV.select { |k, _v| start_with_vars.any? { |var| k.start_with?(var) } }
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
avm-tools-0.47.0 lib/avm/ruby.rb
avm-tools-0.46.0 lib/avm/ruby.rb
avm-tools-0.45.0 lib/avm/ruby.rb
avm-tools-0.44.2 lib/avm/ruby.rb
avm-tools-0.44.1 lib/avm/ruby.rb
avm-tools-0.44.0 lib/avm/ruby.rb
avm-tools-0.43.0 lib/avm/ruby.rb
avm-tools-0.42.0 lib/avm/ruby.rb
avm-tools-0.41.0 lib/avm/ruby.rb
avm-tools-0.40.0 lib/avm/ruby.rb
avm-tools-0.39.0 lib/avm/ruby.rb
avm-tools-0.38.0 lib/avm/ruby.rb
avm-tools-0.37.1 lib/avm/ruby.rb
avm-tools-0.37.0 lib/avm/ruby.rb
avm-tools-0.36.0 lib/avm/ruby.rb