Module: Homebrew::Trust::Store Private

Extended by:
T::Helpers
Included in:
Homebrew::Trust
Defined in:
trust/store.rb

Overview

This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.

Secure, locked persistence for trust decisions.

Instance Method Summary collapse

Instance Method Details

#trust_file(home: nil) ⇒ Pathname

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

Returns:



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'trust/store.rb', line 16

def trust_file(home: nil)
  user = ENV.fetch("USER")
  user_home = Pathname.new begin
    Dir.home(user)
  rescue ArgumentError
    fallback_home = Dir.home
    opoo "Could not determine home directory for `$USER` (#{user}); falling back to #{fallback_home}."
    fallback_home
  end
  home ||= user_home
  user_config_home = Pathname.new(ENV.fetch("HOMEBREW_USER_CONFIG_HOME"))
  if user_config_home == user_home/".homebrew"
    Pathname.new(home.to_s)/".homebrew/trust.json"
  else
    user_config_home/"trust.json"
  end
end