Class: Cask::CaskLoader::FromNameLoader Private
- Inherits:
-
FromTapLoader
- Object
- AbstractContentLoader
- FromPathLoader
- FromTapLoader
- Cask::CaskLoader::FromNameLoader
- 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.
Loader which tries loading casks from tap paths, failing if the same token exists in multiple taps.
Instance Attribute Summary
Attributes inherited from FromTapLoader
Attributes inherited from FromPathLoader
Attributes inherited from AbstractContentLoader
Class Method Summary collapse
Methods inherited from FromTapLoader
Methods inherited from FromPathLoader
#initialize, invalid_path?, #load
Methods inherited from AbstractContentLoader
Methods included from ILoader
Methods included from Utils::Output::Mixin
#odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_installed, #pretty_outdated, #pretty_uninstalled
Constructor Details
This class inherits a constructor from Cask::CaskLoader::FromTapLoader
Class Method Details
.try_new(ref, warn: false) ⇒ T.attached_class, ...
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.
557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 |
# File 'cask/cask_loader.rb', line 557 def self.try_new(ref, warn: false) return unless ref.is_a?(String) return unless ref.match?(/\A#{HOMEBREW_TAP_CASK_TOKEN_REGEX}\Z/o) token = ref # If it exists in the default tap, never treat it as ambiguous with another tap. if (core_cask_tap = CoreCaskTap.instance).installed? && (core_cask_loader = super("#{core_cask_tap}/#{token}", warn:))&.path&.exist? return core_cask_loader end loaders = Tap.select { |tap| tap.installed? && !tap.core_cask_tap? } .filter_map { |tap| super("#{tap}/#{token}", warn:) } .uniq(&:path) .select { |loader| loader.is_a?(FromAPILoader) || loader.path.exist? } case loaders.count when 1 loaders.first when 2..Float::INFINITY raise TapCaskAmbiguityError.new(token, loaders) end end |