Sha256: 4098b4b1e5495b906f180823dea3b1d64fc781f0ed60e386104995d4da30795b
Contents?: true
Size: 854 Bytes
Versions: 48
Compression:
Stored size: 854 Bytes
Contents
module Fig; end; # Abstract manager of a set of environment variables. module Fig::EnvironmentVariables def initialize(variables_override = nil) @variables = variables_override || get_system_environment_variables end def empty? return @variables.empty? end def keys return @variables.keys end def with_environment original_environment = {} original_environment.merge!(ENV.to_hash) begin set_system_environment_variables(@variables) yield ensure ENV.clear set_system_environment_variables(original_environment) end return end private def get_system_environment_variables vars = {} ENV.each { |key,value| vars[key]=value } return vars end def set_system_environment_variables(variables) variables.each { |key, value| ENV[key] = value } end end
Version data entries
48 entries across 48 versions & 1 rubygems