Module: EnvActivation

Defined in:
Library/Homebrew/extend/ENV.rb

Instance Method Summary collapse

Instance Method Details

#activate_extensions!(env: nil) ⇒ Object


15
16
17
18
19
20
21
# File 'Library/Homebrew/extend/ENV.rb', line 15

def activate_extensions!(env: nil)
  if superenv?(env)
    extend(Superenv)
  else
    extend(Stdenv)
  end
end

#clear_sensitive_environment!Object


42
43
44
# File 'Library/Homebrew/extend/ENV.rb', line 42

def clear_sensitive_environment!
  each_key { |key| delete key if sensitive?(key) }
end

#sensitive?(key) ⇒ Boolean

Returns:

  • (Boolean)

34
35
36
# File 'Library/Homebrew/extend/ENV.rb', line 34

def sensitive?(key)
  /(cookie|key|token|password)/i =~ key
end

#sensitive_environmentObject


38
39
40
# File 'Library/Homebrew/extend/ENV.rb', line 38

def sensitive_environment
  select { |key, _| sensitive?(key) }
end

#with_build_environment(env: nil, cc: nil, build_bottle: false, bottle_arch: nil) ⇒ Object


23
24
25
26
27
28
29
30
31
32
# File 'Library/Homebrew/extend/ENV.rb', line 23

def with_build_environment(env: nil, cc: nil, build_bottle: false, bottle_arch: nil)
  old_env = to_hash.dup
  tmp_env = to_hash.dup.extend(EnvActivation)
  tmp_env.activate_extensions!(env: env)
  tmp_env.setup_build_environment(cc: cc, build_bottle: build_bottle, bottle_arch: bottle_arch)
  replace(tmp_env)
  yield
ensure
  replace(old_env)
end