Class: Cask::Info
- Extended by:
- Utils::Output::Mixin
- Defined in:
- cask/info.rb
Class Method Summary collapse
- .artifact_info(cask) ⇒ String private
- .decorate_dependency(dep, installed:, mark_uninstalled: true) ⇒ String private
- .deps_info(cask, mark_uninstalled: true) ⇒ String? private
- .get_info(cask) ⇒ String private
- .info(cask, args:) ⇒ void private
- .installation_info(cask, installed:) ⇒ String private
- .language_info(cask) ⇒ String? private
- .repo_info(cask) ⇒ String? private
- .requirements_info(cask, mark_uninstalled: true) ⇒ String? private
- .title_info(cask, installed:) ⇒ String private
Methods included from Utils::Output::Mixin
issue_reporting_message, odebug, odeprecated, odie, odisabled, ofail, oh1, oh1_title, ohai, ohai_title, onoe, opoo, opoo_outside_github_actions, opoo_without_github_actions_annotation, pretty_deprecated, pretty_disabled, pretty_duration, pretty_install_status, pretty_installed, pretty_outdated, pretty_uninstalled, pretty_upgradable
Class Method Details
.artifact_info(cask) ⇒ 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.
205 206 207 208 209 210 211 212 213 214 |
# File 'cask/info.rb', line 205 def self.artifact_info(cask) artifact_output = ohai_title("Artifacts").dup cask.artifacts.each do |artifact| next unless artifact.respond_to?(:install_phase) next unless DSL::ORDINARY_ARTIFACT_CLASSES.include?(artifact.class) artifact_output << "\n" << artifact.to_s end artifact_output.freeze end |
.decorate_dependency(dep, installed:, 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.
137 138 139 |
# File 'cask/info.rb', line 137 def self.decorate_dependency(dep, installed:, mark_uninstalled: true) pretty_install_status(dep, installed:, mark_uninstalled:) end |
.deps_info(cask, 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.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'cask/info.rb', line 88 def self.deps_info(cask, mark_uninstalled: true) depends_on = cask.depends_on formula_deps = Array(depends_on[:formula]).map do |dep| name = dep.to_s rack = HOMEBREW_CELLAR/::Utils.name_from_full_name(name) decorate_dependency( name, installed: rack.directory? && !rack.subdirs.empty?, mark_uninstalled:, ) end cask_deps = Array(depends_on[:cask]).map do |dep| name = dep.to_s decorate_dependency( "#{name} (cask)", installed: (Caskroom.path/name).directory?, mark_uninstalled:, ) end all_deps = formula_deps + cask_deps return if all_deps.empty? formula_dependencies = T.let(Set.new, T::Set[String]) cask_dependencies = T.let(Set.new, T::Set[String]) Homebrew::Cmd::Info.collect_cask_dependency_names(cask, formula_dependencies, cask_dependencies, Set[cask.token]) recursive_count = formula_dependencies.count + cask_dependencies.count lines = T.let( [ohai_title("Dependencies").to_s, "Required (#{all_deps.count}): #{all_deps.join(", ")}"], T::Array[String], ) unless recursive_count.zero? installed_count = formula_dependencies.count do |name| rack = HOMEBREW_CELLAR/::Utils.name_from_full_name(name) rack.directory? && !rack.subdirs.empty? end + cask_dependencies.count do |name| (Caskroom.path/name).directory? end lines << "Recursive Runtime (#{recursive_count}): " \ "#{Homebrew::Cmd::Info.dependency_status_counts(installed_count, recursive_count)}" end "#{lines.join("\n")}\n" end |
.get_info(cask) ⇒ 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.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'cask/info.rb', line 13 def self.get_info(cask) require "cask/installer" installed = cask.installed? output = "#{title_info(cask, installed:)}\n" output << "#{cask.desc}\n" if cask.desc output << "#{Formatter.url(cask.homepage)}\n" if cask.homepage deprecate_disable = DeprecateDisable.(cask) if deprecate_disable.present? deprecate_disable.tap { || [0] = [0].upcase } output << "#{deprecate_disable}\n" end output << "#{installation_info(cask, installed:)}\n" = Homebrew::Cmd::Info.(cask) output << "#{.join("\n")}\n" if .present? repo = repo_info(cask) output << "#{repo}\n" if repo deps = deps_info(cask, mark_uninstalled: installed) output << deps if deps requirements = requirements_info(cask, mark_uninstalled: installed) output << requirements if requirements language = language_info(cask) output << language if language output << "#{artifact_info(cask)}\n" caveats = Installer.caveats(cask) output << caveats if caveats output end |
.info(cask, args:) ⇒ 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.
43 44 45 46 47 48 49 50 |
# File 'cask/info.rb', line 43 def self.info(cask, args:) puts get_info(cask) return unless cask.tap&.core_cask_tap? require "utils/analytics" ::Utils::Analytics.cask_output(cask, args:) end |
.installation_info(cask, installed:) ⇒ 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.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'cask/info.rb', line 67 def self.installation_info(cask, installed:) return "Not installed" unless installed return "No installed version" unless (installed_version = cask.installed_version).present? versioned_staged_path = cask.caskroom_path.join(installed_version) tab = Tab.for_cask(cask) unless versioned_staged_path.exist? return "#{Homebrew::Cmd::Info.installation_status(tab)}\n" \ "#{versioned_staged_path} (#{Formatter.error("does not exist")})\n" end path_details = versioned_staged_path.children.sum(&:disk_usage) info = [Homebrew::Cmd::Info.installation_status(tab)] info << "#{versioned_staged_path} (#{Formatter.disk_usage_readable(path_details)})" info << " #{tab}" if tab.tabfile&.exist? info.join("\n") end |
.language_info(cask) ⇒ 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.
182 183 184 185 186 187 188 189 |
# File 'cask/info.rb', line 182 def self.language_info(cask) return if cask.languages.empty? <<~EOS #{ohai_title("Languages")} #{cask.languages.join(", ")} EOS end |
.repo_info(cask) ⇒ 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.
192 193 194 195 196 197 198 199 200 201 202 |
# File 'cask/info.rb', line 192 def self.repo_info(cask) return unless (tap = cask.tap) url = if tap.custom_remote? && !tap.remote.nil? tap.remote else "#{tap.default_remote}/blob/HEAD/#{tap.relative_cask_path(cask.token)}" end "From: #{Formatter.url(url)}" end |
.requirements_info(cask, 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.
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 |
# File 'cask/info.rb', line 142 def self.requirements_info(cask, mark_uninstalled: true) require "cask_dependent" requirements = CaskDependent.new(cask).requirements.grep_v(CaskDependent::Requirement) return if requirements.empty? supports_linux = cask.supports_linux? output = "#{ohai_title("Requirements")}\n" %w[build required recommended optional].each do |type| reqs = case type when "build" requirements.select(&:build?) when "required" requirements.select(&:required?) when "recommended" requirements.select(&:recommended?) when "optional" requirements.select(&:optional?) else [] end next if reqs.empty? output << "#{type.capitalize}: #{reqs.map do |requirement| requirement_s = if requirement.is_a?(MacOSRequirement) && !supports_linux requirement.display_s.delete_suffix(" (or Linux)") else requirement.display_s end pretty_install_status( requirement_s, installed: requirement.satisfied?, mark_uninstalled:, ) end.join(", ")}\n" end output end |
.title_info(cask, installed:) ⇒ 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.
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'cask/info.rb', line 53 def self.title_info(cask, installed:) name_with_status = if installed pretty_installed(cask.token) else pretty_uninstalled(cask.token) end title = oh1_title(name_with_status).to_s title += " (#{cask.name.join(", ")})" unless cask.name.empty? title += ": #{cask.version}" title += " (auto_updates)" if cask.auto_updates title end |