Module: EnvActivation

Extended by:
T::Sig
Defined in:
extend/ENV.rb

Instance Method Summary collapse

Instance Method Details

#activate_extensions!(env: nil) ⇒ void

This method returns an undefined value.

Parameters:

  • env (String, nil) (defaults to: nil)


26
27
28
29
30
31
32
# File 'extend/ENV.rb', line 26

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

#clear_sensitive_environment!void

This method returns an undefined value.



69
70
71
# File 'extend/ENV.rb', line 69

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

#sensitive?(key) ⇒ Boolean

Parameters:

Returns:

  • (Boolean)


59
60
61
# File 'extend/ENV.rb', line 59

def sensitive?(key)
  key.match?(/(cookie|key|token|password|passphrase)/i)
end

#sensitive_environmentHash{String => String}

Returns:



64
65
66
# File 'extend/ENV.rb', line 64

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

#with_build_environment(env: nil, cc: nil, build_bottle: false, bottle_arch: nil, &_block) ⇒ T.untyped

Parameters:

  • env (String, nil) (defaults to: nil)
  • cc (String, nil) (defaults to: nil)
  • build_bottle (Boolean) (defaults to: false)
  • bottle_arch (String, nil) (defaults to: nil)
  • _block (T.proc.returns(T.untyped))

Returns:

  • (T.untyped)


43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'extend/ENV.rb', line 43

def with_build_environment(env: nil, cc: nil, build_bottle: false, bottle_arch: nil, &_block)
  old_env = to_hash.dup
  tmp_env = to_hash.dup.extend(EnvActivation)
  T.cast(tmp_env, EnvActivation).activate_extensions!(env: env)
  T.cast(tmp_env, T.any(Superenv, Stdenv))
   .setup_build_environment(cc: cc, build_bottle: build_bottle, bottle_arch: bottle_arch)
  replace(tmp_env)

  begin
    yield
  ensure
    replace(old_env)
  end
end