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(title:, formula_or_cask:, installation_status:, source_url:, installed_versions:, verbose:, tap: nil, license: nil, shadowed_by: nil, aliases: [], old_names: [], conflicts: []) ⇒ String private
- .package_title(title, deprecated: false, disabled: false, incompatible: false, can_install: true) ⇒ String private
- .recursive_runtime_line(installed_count, total_count, mark_uninstalled: true) ⇒ String 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_incompatible, 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.
231 232 233 234 235 236 237 |
# File 'utils/info_display.rb', line 231 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.
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
# File 'utils/info_display.rb', line 301 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.
240 241 242 243 244 245 246 247 |
# File 'utils/info_display.rb', line 240 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.
287 288 289 290 291 292 293 294 295 |
# File 'utils/info_display.rb', line 287 def self.formula_installs_from_source?(formula) return false if formula.disabled? || formula.incompatible? || !formula.valid_platform? 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.
92 93 94 95 96 |
# File 'utils/info_display.rb', line 92 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.
87 88 89 |
# File 'utils/info_display.rb', line 87 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.
99 100 101 102 103 104 |
# File 'utils/info_display.rb', line 99 def self.installation_summary(version, tab) reason = installation_reason(tab) reason_note = " (#{reason})" if reason != "-" "Installed: #{version}#{reason_note}" 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.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'utils/info_display.rb', line 65 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(title:, formula_or_cask:, installation_status:, source_url:, installed_versions:, verbose:, tap: nil, license: nil, 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.
122 123 124 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 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'utils/info_display.rb', line 122 def self.package_summary( title:, formula_or_cask:, installation_status:, source_url:, installed_versions:, verbose:, tap: nil, license: nil, shadowed_by: nil, aliases: [], old_names: [], conflicts: [] ) 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 incompatible = formula_or_cask.incompatible? [ package_title(title, deprecated: formula_or_cask.deprecated?, disabled: formula_or_cask.disabled?, incompatible:, can_install: formula_or_cask.valid_platform? && !formula_or_cask.disabled? && !incompatible), (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, incompatible: 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.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'utils/info_display.rb', line 41 def self.package_title(title, deprecated: false, disabled: false, incompatible: false, can_install: true) name = pretty_install_status( title.name, installed: title.installed, outdated: title.outdated, warning: title.warning, removed: title.removed, deprecated:, disabled:, incompatible:, 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.
250 251 252 253 |
# File 'utils/info_display.rb', line 250 def self.recursive_runtime_line(installed_count, total_count, mark_uninstalled: true) status_counts = dependency_status_counts(installed_count, total_count, mark_uninstalled:) "Recursive Runtime (#{total_count}): #{status_counts}" 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.
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'utils/info_display.rb', line 213 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.
201 202 203 |
# File 'utils/info_display.rb', line 201 def self.section(title, lines) [ohai_title(title), *lines].join("\n") end |