Class: Cask::CaskLoader::FromAPILoader Private
- Includes:
- ILoader
- Defined in:
- cask/cask_loader.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.
Loads a cask from the JSON API.
Instance Attribute Summary collapse
- #from_json ⇒ Hash{String => T.untyped}? readonly private
- #path ⇒ Pathname readonly private
- #token ⇒ String readonly private
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(token, from_json: T.unsafe(nil), path: nil, from_installed_caskfile: false, from_internal_json: false, api_fallback: true) ⇒ void constructor private
-
#load(config:) ⇒ Cask
private
This is a false positive incompatibililty warning, due to Kernel#load being overridden.
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_uninstalled, #pretty_unmarked, #pretty_upgradable, #pretty_warning
Constructor Details
#initialize(token, from_json: T.unsafe(nil), path: nil, from_installed_caskfile: false, from_internal_json: false, api_fallback: true) ⇒ 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.
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 |
# File 'cask/cask_loader.rb', line 420 def initialize(token, from_json: T.unsafe(nil), path: nil, from_installed_caskfile: false, from_internal_json: false, api_fallback: true) @token = T.let(token.sub(%r{^homebrew/(?:homebrew-)?cask/}i, ""), String) @sourcefile_path = T.let( if path path elsif from_json from_internal_json ? Homebrew::API::Internal.cached_packages_json_file_path : Homebrew::API::Cask.cached_json_file_path else Homebrew::API.cached_cask_json_file_path end, Pathname, ) @path = T.let(path || CaskLoader.default_path(@token), Pathname) @from_json = from_json @from_installed_caskfile = from_installed_caskfile @from_internal_json = from_internal_json @api_fallback = api_fallback end |
Instance Attribute Details
#from_json ⇒ Hash{String => T.untyped}? (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.
389 390 391 |
# File 'cask/cask_loader.rb', line 389 def from_json @from_json end |
#path ⇒ Pathname (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.
386 387 388 |
# File 'cask/cask_loader.rb', line 386 def path @path end |
#token ⇒ String (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.
383 384 385 |
# File 'cask/cask_loader.rb', line 383 def token @token end |
Class Method Details
.try_new(ref, warn: false) ⇒ FromAPILoader?
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.
395 396 397 398 399 400 401 402 403 404 405 406 407 408 |
# File 'cask/cask_loader.rb', line 395 def self.try_new(ref, warn: false) return if Homebrew::EnvConfig.no_install_from_api? return unless ref.is_a?(String) return unless (token = ref[HOMEBREW_DEFAULT_TAP_CASK_REGEX, :token]) if !Homebrew::API.cask_token?(token) && !Homebrew::API.cask_renames.key?(token) return end ref = "#{CoreCaskTap.instance}/#{token}" token, tap, = CaskLoader.tap_cask_token_type(ref, warn:) new("#{tap}/#{token}") end |
Instance Method Details
#load(config:) ⇒ Cask
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 is a false positive incompatibililty warning, due to Kernel#load being overridden.
442 443 444 445 446 447 448 449 450 451 452 |
# File 'cask/cask_loader.rb', line 442 def load(config:) if (api_source = from_json) if @from_internal_json load_from_internal_json(config:, api_source:) else load_from_json(config:, api_source:) end else load_from_internal_api(config:) end end |