Sha256: 5a0e9b37ca88a9e970e7874f1f333dcaf6434a3993b38f3189532969a072ff7c
Contents?: true
Size: 684 Bytes
Versions: 13
Compression:
Stored size: 684 Bytes
Contents
# frozen_string_literal: true module EacRubyUtils module Ruby class << self # Executes a block in an environment when the variables BUNDLE* and RUBY* are removed. 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.each_key { |k| ENV.delete(k) } 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
13 entries across 13 versions & 2 rubygems