Module: Utils::InfoDisplay Private
- Extended by:
- Output::Mixin
- Defined in:
- utils/info_display.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.
Shared presentation helpers for formula and cask information.
Defined Under Namespace
Classes: InstalledVersion, Title
Class Method Summary collapse
- .binaries_section(binaries, additional_text: nil) ⇒ String private
- .collect_cask_dependency_names(cask, formula_dependencies, cask_dependencies, visited_casks) ⇒ void private
- .dependency_status_counts(installed_count, total_count, mark_uninstalled: true) ⇒ String private
- .formula_installs_from_source?(formula) ⇒ Boolean private
- .installation_reason(tab) ⇒ String private
- .installation_status(tab) ⇒ String private
- .installation_summary(version, tab) ⇒ String private
- .metadata_lines(formula_or_cask) ⇒ Array<String> private
- .package_summary(formula_or_cask:, name:, installation_status:, source_url:, installed_versions:, verbose:, tap: nil, license: nil, display_names: [], version: nil, installed_version: nil, installed: false, outdated: false, warning: false, removed: false, stable: false, bottled: false, head: false, keg_only: false, auto_updates: false, shadowed_by: nil, aliases: [], old_names: [], conflicts: []) ⇒ String private
- .package_title(title, deprecated: false, disabled: false, can_install: true) ⇒ String private
- .recursive_runtime_line(installed_count, total_count, mark_uninstalled: true) ⇒ String private
- .requirement_for_other_os?(requirement) ⇒ Boolean private
- .requirements_section(requirements, omit_macos_linux: false, mark_uninstalled: true, bold: nil) ⇒ String? private
- .section(title, lines) ⇒ String private
Methods included from Output::Mixin
issue_reporting_message, odebug, odeprecated, odie, odisabled, ofail, oh1, oh1_title, ohai, ohai_title, onoe, opoo, opoo_once, opoo_outside_github_actions, opoo_without_github_actions_annotation, pretty_cannot_install, pretty_deprecated, pretty_disabled, pretty_duration, pretty_install_status, pretty_installed, pretty_removed, pretty_uninstalled, pretty_unmarked, pretty_upgradable, pretty_warning
Class Method Details
.binaries_section(binaries, additional_text: nil) ⇒ 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.
252 253 254 255 256 257 258 |
# File 'utils/info_display.rb', line 252 def self.binaries_section(binaries, additional_text: nil) formatted = [ (Formatter.columns(binaries.sort.uniq) if binaries.present?), additional_text, ].compact.join("\n") section("Binaries", formatted.empty? ? [] : [formatted]) end |
.collect_cask_dependency_names(cask, formula_dependencies, cask_dependencies, visited_casks) ⇒ 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.
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 |
# File 'utils/info_display.rb', line 327 def self.collect_cask_dependency_names(cask, formula_dependencies, cask_dependencies, visited_casks) cask.depends_on.formula.each do |name| dep_name = name.to_s formula_dependencies << dep_name rack = HOMEBREW_CELLAR/Utils.name_from_full_name(dep_name) next unless rack.directory? keg = Keg.from_rack(rack) next unless keg tab_deps = Tab.for_keg(keg).runtime_dependencies tab_deps&.each do |runtime_dep| dep_full_name = T.cast(runtime_dep, T::Hash[String, T.untyped])["full_name"] formula_dependencies << dep_full_name if dep_full_name end end cask.depends_on.cask.each do |name| token = name.to_s next if visited_casks.include?(token) cask_dependencies << token visited_casks << token begin dependency = Cask::CaskLoader.load(token) collect_cask_dependency_names(dependency, formula_dependencies, cask_dependencies, visited_casks) rescue Cask::CaskUnavailableError next end end end |
.dependency_status_counts(installed_count, total_count, mark_uninstalled: true) ⇒ 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.
266 267 268 269 270 271 272 273 |
# File 'utils/info_display.rb', line 266 def self.dependency_status_counts(installed_count, total_count, mark_uninstalled: true) missing_count = total_count - installed_count return "all installed #{Formatter.success("✔")}" if missing_count.zero? missing_status = mark_uninstalled ? "missing #{Formatter.error("✘")}" : "not installed" "#{installed_count} installed #{Formatter.success("✔")}, " \ "#{missing_count} #{missing_status}" end |
.formula_installs_from_source?(formula) ⇒ Boolean
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.
313 314 315 316 317 318 319 320 321 |
# File 'utils/info_display.rb', line 313 def self.formula_installs_from_source?(formula) return false if formula.requirements.any? { |requirement| requirement_for_other_os?(requirement) } stable = formula.stable return true if stable.blank? && formula.head.present? return false if stable.blank? !stable.bottled? || !formula.pour_bottle? end |
.installation_reason(tab) ⇒ 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.
90 91 92 93 94 |
# File 'utils/info_display.rb', line 90 def self.installation_reason(tab) return "-" unless tab.installed_on_request_present? tab.installed_on_request ? "on request" : "dependency" end |
.installation_status(tab) ⇒ 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.
85 86 87 |
# File 'utils/info_display.rb', line 85 def self.installation_status(tab) tab.installed_on_request ? "Installed (on request)" : "Installed (as dependency)" end |
.installation_summary(version, tab) ⇒ 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.
97 98 99 100 101 |
# File 'utils/info_display.rb', line 97 def self.installation_summary(version, tab) reason = installation_reason(tab) "Installed: #{version}#{" (#{reason})" if reason != "-"}" end |
.metadata_lines(formula_or_cask) ⇒ Array<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.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'utils/info_display.rb', line 63 def self.(formula_or_cask) return [] unless $stdout.tty? case formula_or_cask when Formula (formula_or_cask) when Cask::Cask if formula_or_cask.pinned? pinned = "Pinned: #{formula_or_cask.pinned_version}" if (pinned_time = pin_path_mtime(formula_or_cask.pin_path)) pinned << " on #{formatted_time(pinned_time)}" end [pinned] else [] end else T.absurd(formula_or_cask) end end |
.package_summary(formula_or_cask:, name:, installation_status:, source_url:, installed_versions:, verbose:, tap: nil, license: nil, display_names: [], version: nil, installed_version: nil, installed: false, outdated: false, warning: false, removed: false, stable: false, bottled: false, head: false, keg_only: false, auto_updates: false, shadowed_by: nil, aliases: [], old_names: [], conflicts: []) ⇒ 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.
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'utils/info_display.rb', line 131 def self.package_summary( formula_or_cask:, name:, installation_status:, source_url:, installed_versions:, verbose:, tap: nil, license: nil, display_names: [], version: nil, installed_version: nil, installed: false, outdated: false, warning: false, removed: false, stable: false, bottled: false, head: false, keg_only: false, auto_updates: false, shadowed_by: nil, aliases: [], old_names: [], conflicts: [] ) title = Title.new( name:, display_names:, version:, installed_version:, installed:, outdated:, warning:, removed:, stable:, bottled:, head:, keg_only:, auto_updates: ) deprecation = DeprecateDisable.(formula_or_cask) deprecation = deprecation.chomp.sub(/\A./, &:upcase) if deprecation.present? installed_title = if verbose && formula_or_cask.is_a?(Formula) "Installed Kegs and Versions" else "Installed Versions" end [ package_title(title, deprecated: formula_or_cask.deprecated?, disabled: formula_or_cask.disabled?, can_install: formula_or_cask.valid_platform? && !formula_or_cask.disabled?), (if shadowed_by && formula_or_cask.is_a?(Formula) Formatter.warning("`#{formula_or_cask.name}` shadows `#{shadowed_by}/#{formula_or_cask.name}`.", label: "Warning") end), formula_or_cask.desc, (Formatter.url(formula_or_cask.homepage) if formula_or_cask.homepage), deprecation, ("Aliases: #{aliases.join(", ")}" if aliases.any?), ("Old Names: #{old_names.join(", ")}" if old_names.any?), ("Conflicts with:\n #{conflicts.join("\n ")}" if conflicts.any?), *installation_status, ("From: #{Formatter.url(source_url)}" if source_url), ("Tap: #{tap.name}" if tap && !tap.official?), ("License: #{SPDX.license_expression_to_string(license)}" if license.present?), *(formula_or_cask), installed_versions_section(installed_versions, title: installed_title, show_details: verbose), ].compact.join("\n") end |
.package_title(title, deprecated: false, disabled: false, can_install: true) ⇒ 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.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'utils/info_display.rb', line 39 def self.package_title(title, deprecated: false, disabled: false, can_install: true) name = pretty_install_status( title.name, installed: title.installed, outdated: title.outdated, warning: title.warning, removed: title.removed, deprecated:, disabled:, can_install:, bold: true ) heading = oh1_title(name).to_s heading += " (#{title.display_names.join(", ")})" if title.display_names.any? versions = [] if (title_version = title.version) version = title.stable ? "stable #{title_version}" : title_version version += " (bottled)" if title.bottled versions << version end versions << "HEAD" if title.head if title.outdated && title.installed_version && versions.any? versions[0] = "#{title.installed_version} → #{versions[0]}" end heading += ": #{versions.join(", ")}" heading += " [keg-only]" if title.keg_only heading += " (auto_updates)" if title.auto_updates heading end |
.recursive_runtime_line(installed_count, total_count, mark_uninstalled: true) ⇒ 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.
276 277 278 279 |
# File 'utils/info_display.rb', line 276 def self.recursive_runtime_line(installed_count, total_count, mark_uninstalled: true) "Recursive Runtime (#{total_count}): " \ "#{dependency_status_counts(installed_count, total_count, mark_uninstalled:)}" end |
.requirement_for_other_os?(requirement) ⇒ Boolean
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.
261 262 263 |
# File 'utils/info_display.rb', line 261 def self.requirement_for_other_os?(requirement) requirement.instance_of?(MacOSRequirement) || requirement.instance_of?(LinuxRequirement) end |
.requirements_section(requirements, omit_macos_linux: false, mark_uninstalled: true, bold: nil) ⇒ 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.
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
# File 'utils/info_display.rb', line 234 def self.requirements_section(requirements, omit_macos_linux: false, mark_uninstalled: true, bold: nil) return if requirements.empty? lines = %w[build required recommended optional].filter_map do |type| reqs = requirements.select { |requirement| requirement.public_send(:"#{type}?") } next if reqs.empty? formatted = reqs.map do |requirement| text = requirement.display_s text = text.delete_suffix(" (or Linux)") if omit_macos_linux && requirement.is_a?(MacOSRequirement) pretty_install_status(text, installed: requirement.satisfied?, mark_uninstalled:, bold:) end "#{type.capitalize}: #{formatted.join(", ")}" end section("Requirements", lines) end |
.section(title, lines) ⇒ 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.
222 223 224 |
# File 'utils/info_display.rb', line 222 def self.section(title, lines) [ohai_title(title), *lines].join("\n") end |