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:) ⇒ String private
- .deps_info(cask) ⇒ String? private
- .desc_info(cask) ⇒ String private
- .get_info(cask) ⇒ String private
- .info(cask, args:) ⇒ void private
- .installation_info(cask, installed:) ⇒ String private
- .language_info(cask) ⇒ String? private
- .name_info(cask) ⇒ String private
- .repo_info(cask) ⇒ String? private
- .title_info(cask, installed:) ⇒ String private
Methods included from Utils::Output::Mixin
odebug, odeprecated, odie, odisabled, ofail, oh1, oh1_title, ohai, ohai_title, onoe, opoo, opoo_outside_github_actions, pretty_duration, pretty_installed, pretty_outdated, pretty_uninstalled
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.
158 159 160 161 162 163 164 165 166 167 |
# File 'cask/info.rb', line 158 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:) ⇒ 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.
130 131 132 |
# File 'cask/info.rb', line 130 def self.decorate_dependency(dep, installed:) installed ? pretty_installed(dep) : pretty_uninstalled(dep) end |
.deps_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.
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 |
# File 'cask/info.rb', line 97 def self.deps_info(cask) depends_on = cask.depends_on formula_deps = Array(depends_on[:formula]).map do |dep| name = dep.to_s installed = begin Formula[name].any_version_installed? rescue FormulaUnavailableError false end decorate_dependency(name, installed:) end cask_deps = Array(depends_on[:cask]).map do |dep| name = dep.to_s installed = begin CaskLoader.load(name).installed? rescue CaskUnavailableError false end decorate_dependency("#{name} (cask)", installed:) end all_deps = formula_deps + cask_deps return if all_deps.empty? <<~EOS #{ohai_title("Dependencies")} #{all_deps.join(", ")} EOS end |
.desc_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.
89 90 91 92 93 94 |
# File 'cask/info.rb', line 89 def self.desc_info(cask) <<~EOS #{ohai_title("Description")} #{cask.desc.nil? ? Formatter.error("None") : cask.desc} EOS 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 |
# File 'cask/info.rb', line 13 def self.get_info(cask) require "cask/installer" installed = cask.installed? output = "#{title_info(cask, installed:)}\n" 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" repo = repo_info(cask) output << "#{repo}\n" if repo output << name_info(cask) output << desc_info(cask) deps = deps_info(cask) output << deps if deps 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.
40 41 42 43 44 45 46 47 |
# File 'cask/info.rb', line 40 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.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'cask/info.rb', line 62 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) return "Installed\n#{versioned_staged_path} (#{Formatter.error("does not exist")})\n" unless versioned_staged_path.exist? path_details = versioned_staged_path.children.sum(&:disk_usage) tab = Tab.for_cask(cask) info = ["Installed"] 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.
135 136 137 138 139 140 141 142 |
# File 'cask/info.rb', line 135 def self.language_info(cask) return if cask.languages.empty? <<~EOS #{ohai_title("Languages")} #{cask.languages.join(", ")} EOS end |
.name_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.
81 82 83 84 85 86 |
# File 'cask/info.rb', line 81 def self.name_info(cask) <<~EOS #{ohai_title((cask.name.size > 1) ? "Names" : "Name")} #{cask.name.empty? ? Formatter.error("None") : cask.name.join("\n")} 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.
145 146 147 148 149 150 151 152 153 154 155 |
# File 'cask/info.rb', line 145 def self.repo_info(cask) return if cask.tap.nil? url = if cask.tap.custom_remote? && !cask.tap.remote.nil? cask.tap.remote else "#{cask.tap.default_remote}/blob/HEAD/#{cask.tap.relative_cask_path(cask.token)}" end "From: #{Formatter.url(url)}" 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.
50 51 52 53 54 55 56 57 58 59 |
# File 'cask/info.rb', line 50 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)}: #{cask.version}" title += " (auto_updates)" if cask.auto_updates title end |