Module: SystemConfig Private
- Extended by:
- SystemCommand::Mixin
- Defined in:
- system_config.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.
Helper module for querying information about the system configuration.
Class Method Summary collapse
- .branch ⇒ String private
- .clang ⇒ Version private
- .clang_build ⇒ Version private
- .core_tap_config(out = $stdout) ⇒ void private
- .describe_clang ⇒ String private
- .describe_curl ⇒ String private
- .describe_git ⇒ String private
- .describe_homebrew_ruby ⇒ String private
- .describe_path(path) ⇒ String private
- .dump_tap_config(tap, out = $stdout) ⇒ void private
- .dump_verbose_config(out = $stdout) ⇒ void private
- .hardware ⇒ String? private
- .head ⇒ String private
- .homebrew_config(out = $stdout) ⇒ void private
- .homebrew_env_config(out = $stdout) ⇒ void private
- .homebrew_repo ⇒ GitRepository private
- .host_software_config(out = $stdout) ⇒ void private
- .initialize ⇒ void private
- .kernel ⇒ String private
- .last_commit ⇒ String private
- .origin ⇒ String private
Methods included from SystemCommand::Mixin
system_command, system_command!
Class Method Details
.branch ⇒ String
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.
46 47 48 |
# File 'system_config.rb', line 46 def branch homebrew_repo.branch_name || "(none)" end |
.clang ⇒ Version
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.
23 24 25 26 27 28 29 |
# File 'system_config.rb', line 23 def clang @clang ||= if DevelopmentTools.installed? DevelopmentTools.clang_version else Version::NULL end end |
.clang_build ⇒ Version
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.
32 33 34 35 36 37 38 |
# File 'system_config.rb', line 32 def clang_build @clang_build ||= if DevelopmentTools.installed? DevelopmentTools.clang_build_version else Version::NULL end end |
.core_tap_config(out = $stdout) ⇒ void
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.
This method returns an undefined value.
154 155 156 |
# File 'system_config.rb', line 154 def core_tap_config(out = $stdout) dump_tap_config(CoreTap.instance, out) end |
.describe_clang ⇒ String
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.
66 67 68 69 70 71 72 73 74 |
# File 'system_config.rb', line 66 def describe_clang return "N/A" if clang.null? if clang_build.null? clang.to_s else "#{clang} build #{clang_build}" end end |
.describe_curl ⇒ String
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.
113 114 115 116 117 118 119 120 121 122 |
# File 'system_config.rb', line 113 def describe_curl out = system_command(Utils::Curl.curl_executable, args: ["--version"], verbose: false).stdout match_data = /^curl (?<curl_version>[\d.]+)/.match(out) if match_data "#{match_data[:curl_version]} => #{Utils::Curl.curl_path}" else "N/A" end end |
.describe_git ⇒ String
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.
106 107 108 109 110 |
# File 'system_config.rb', line 106 def describe_git return "N/A" unless Utils::Git.available? "#{Utils::Git.version} => #{Utils::Git.path}" end |
.describe_homebrew_ruby ⇒ String
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.
89 90 91 |
# File 'system_config.rb', line 89 def describe_homebrew_ruby "#{RUBY_VERSION} => #{RUBY_PATH}" end |
.describe_path(path) ⇒ String
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.
77 78 79 80 81 82 83 84 85 86 |
# File 'system_config.rb', line 77 def describe_path(path) return "N/A" if path.nil? realpath = path.realpath if realpath == path path.to_s else "#{path} => #{realpath}" end end |
.dump_tap_config(tap, out = $stdout) ⇒ void
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.
This method returns an undefined value.
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'system_config.rb', line 125 def dump_tap_config(tap, out = $stdout) case tap when CoreTap tap_name = "Core tap" json_file_name = "formula.jws.json" when CoreCaskTap tap_name = "Core cask tap" json_file_name = "cask.jws.json" else raise ArgumentError, "Unknown tap: #{tap}" end if tap.installed? out.puts "#{tap_name} origin: #{tap.remote}" if tap.remote != tap.default_remote out.puts "#{tap_name} HEAD: #{tap.git_head || "(none)"}" out.puts "#{tap_name} last commit: #{tap.git_last_commit || "never"}" default_branches = %w[main master].freeze out.puts "#{tap_name} branch: #{tap.git_branch || "(none)"}" if default_branches.exclude?(tap.git_branch) end json_file = Homebrew::API::HOMEBREW_CACHE_API/json_file_name if json_file.exist? out.puts "#{tap_name} JSON: #{json_file.mtime.utc.strftime("%d %b %H:%M UTC")}" elsif !tap.installed? out.puts "#{tap_name}: N/A" end end |
.dump_verbose_config(out = $stdout) ⇒ void
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.
This method returns an undefined value.
207 208 209 210 211 212 213 |
# File 'system_config.rb', line 207 def dump_verbose_config(out = $stdout) homebrew_config(out) core_tap_config(out) homebrew_env_config(out) out.puts hardware if hardware host_software_config(out) end |
.hardware ⇒ String?
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.
94 95 96 97 98 |
# File 'system_config.rb', line 94 def hardware return if Hardware::CPU.type == :dunno "CPU: #{Hardware.cores_as_words}-core #{Hardware::CPU.bits}-bit #{Hardware::CPU.family}" end |
.head ⇒ String
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.
51 52 53 |
# File 'system_config.rb', line 51 def head homebrew_repo.head_ref || "(none)" end |
.homebrew_config(out = $stdout) ⇒ void
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.
This method returns an undefined value.
159 160 161 162 163 164 165 |
# File 'system_config.rb', line 159 def homebrew_config(out = $stdout) out.puts "HOMEBREW_VERSION: #{HOMEBREW_VERSION}" out.puts "ORIGIN: #{origin}" out.puts "HEAD: #{head}" out.puts "Last commit: #{last_commit}" out.puts "Branch: #{branch}" end |
.homebrew_env_config(out = $stdout) ⇒ void
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.
This method returns an undefined value.
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'system_config.rb', line 168 def homebrew_env_config(out = $stdout) out.puts "HOMEBREW_PREFIX: #{HOMEBREW_PREFIX}" { HOMEBREW_REPOSITORY: Homebrew::DEFAULT_REPOSITORY, HOMEBREW_CELLAR: Homebrew::DEFAULT_CELLAR, }.freeze.each do |key, default| value = Object.const_get(key) out.puts "#{key}: #{value}" if value.to_s != default.to_s end Homebrew::EnvConfig::ENVS.each do |env, hash| method_name = Homebrew::EnvConfig.env_method_name(env, hash) if hash[:boolean] out.puts "#{env}: set" if Homebrew::EnvConfig.send(method_name) next end value = Homebrew::EnvConfig.send(method_name) next unless value next if (default = hash[:default].presence) && value.to_s == default.to_s if ENV.sensitive?(env) out.puts "#{env}: set" else out.puts "#{env}: #{value}" end end out.puts "Homebrew Ruby: #{describe_homebrew_ruby}" end |
.homebrew_repo ⇒ GitRepository
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.
41 42 43 |
# File 'system_config.rb', line 41 def homebrew_repo GitRepository.new(HOMEBREW_REPOSITORY) end |
.host_software_config(out = $stdout) ⇒ void
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.
This method returns an undefined value.
200 201 202 203 204 |
# File 'system_config.rb', line 200 def host_software_config(out = $stdout) out.puts "Clang: #{describe_clang}" out.puts "Git: #{describe_git}" out.puts "Curl: #{describe_curl}" end |
.initialize ⇒ void
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.
This method returns an undefined value.
17 18 19 20 |
# File 'system_config.rb', line 17 def initialize @clang = T.let(nil, T.nilable(Version)) @clang_build = T.let(nil, T.nilable(Version)) end |
.kernel ⇒ String
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.
101 102 103 |
# File 'system_config.rb', line 101 def kernel `uname -m`.chomp end |
.last_commit ⇒ String
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.
56 57 58 |
# File 'system_config.rb', line 56 def last_commit homebrew_repo.last_committed || "never" end |
.origin ⇒ String
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.
61 62 63 |
# File 'system_config.rb', line 61 def origin homebrew_repo.origin_url || "(none)" end |