Class: Cask::Audit Private
- Includes:
- SystemCommand::Mixin, Utils::Curl, Utils::Output::Mixin
- Defined in:
- cask/audit.rb
Overview
This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.
Audit a cask for various problems.
Constant Summary collapse
- Error =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
T.type_alias do { message: T.nilable(String), location: T.nilable(Homebrew::SourceLocation), corrected: T::Boolean, } end
Instance Attribute Summary collapse
- #cask ⇒ Cask readonly private
- #download ⇒ Download? readonly private
Instance Method Summary collapse
- #add_error(message, location: nil, strict_only: false) ⇒ void private
- #errors ⇒ Array<Error> private
- #errors? ⇒ Boolean private
- #initialize(cask, download: false, quarantine: false, online: nil, strict: nil, signing: nil, new_cask: nil, only: [], except: []) ⇒ void constructor private
- #new_cask? ⇒ Boolean private
- #online? ⇒ Boolean private
- #result ⇒ String? private
- #run! ⇒ ::Cask::Audit private
- #signing? ⇒ Boolean private
- #strict? ⇒ Boolean private
- #success? ⇒ Boolean private
- #summary ⇒ 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
Methods included from Utils::Curl
clear_path_cache, curl, curl_args, curl_check_http_content, curl_download, curl_executable, curl_headers, curl_http_content_headers_and_checksum, curl_output, curl_path, curl_response_follow_redirections, curl_response_last_location, curl_supports_fail_with_body?, curl_supports_tls13?, curl_version, curl_with_workarounds, http_status_ok?, parse_curl_output, url_protected_by_cloudflare?, url_protected_by_incapsula?
Methods included from SystemCommand::Mixin
#system_command, #system_command!
Constructor Details
#initialize(cask, download: false, quarantine: false, online: nil, strict: nil, signing: nil, new_cask: nil, only: [], except: []) ⇒ 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.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'cask/audit.rb', line 47 def initialize( cask, download: false, quarantine: false, online: nil, strict: nil, signing: nil, new_cask: nil, only: [], except: [] ) # `new_cask` implies `online`, `strict` and `signing` online = new_cask if online.nil? strict = new_cask if strict.nil? signing = new_cask if signing.nil? # `online` and `signing` imply `download` download ||= online || signing @cask = cask @download = T.let(nil, T.nilable(Download)) @download = Download.new(cask, quarantine:) if download @online = online @strict = strict @signing = signing @new_cask = new_cask @only = only @except = except end |
Instance Attribute Details
#cask ⇒ Cask (readonly)
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.
35 36 37 |
# File 'cask/audit.rb', line 35 def cask @cask end |
#download ⇒ Download? (readonly)
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.
38 39 40 |
# File 'cask/audit.rb', line 38 def download @download end |
Instance Method Details
#add_error(message, location: nil, strict_only: false) ⇒ 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.
126 127 128 129 130 131 |
# File 'cask/audit.rb', line 126 def add_error(, location: nil, strict_only: false) # Only raise non-critical audits if the user specified `--strict`. return if strict_only && !@strict errors << { message:, location:, corrected: false } end |
#errors ⇒ Array<Error>
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.
105 106 107 |
# File 'cask/audit.rb', line 105 def errors @errors ||= T.let([], T.nilable(T::Array[Error])) end |
#errors? ⇒ 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.
110 111 112 |
# File 'cask/audit.rb', line 110 def errors? errors.any? end |
#new_cask? ⇒ 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.
73 |
# File 'cask/audit.rb', line 73 def new_cask? = !!@new_cask |
#online? ⇒ 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.
76 |
# File 'cask/audit.rb', line 76 def online? =!!@online |
#result ⇒ 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.
134 135 136 |
# File 'cask/audit.rb', line 134 def result Formatter.error("failed") if errors? end |
#run! ⇒ ::Cask::Audit
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 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'cask/audit.rb', line 85 def run! only_audits = @only except_audits = @except private_methods.map(&:to_s).grep(/^audit_/).each do |audit_method_name| name = audit_method_name.delete_prefix("audit_") next if !only_audits.empty? && only_audits.exclude?(name) next if except_audits.include?(name) send(audit_method_name) end self rescue => e odebug e, ::Utils::Backtrace.clean(e) add_error "exception while auditing #{cask}: #{e.}" self end |
#signing? ⇒ 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.
79 |
# File 'cask/audit.rb', line 79 def signing? = !!@signing |
#strict? ⇒ 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.
82 |
# File 'cask/audit.rb', line 82 def strict? = !!@strict |
#success? ⇒ 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.
115 116 117 |
# File 'cask/audit.rb', line 115 def success? !errors? end |
#summary ⇒ 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.
139 140 141 142 143 144 145 146 147 148 149 |
# File 'cask/audit.rb', line 139 def summary return if success? summary = ["audit for #{cask}: #{result}"] errors.each do |error| summary << " #{Formatter.error("-")} #{error[:message]}" end summary.join("\n") end |