Class: Formulary::FromNameLoader Private
- Inherits:
-
FromTapLoader
- Object
- FormulaLoader
- FromTapLoader
- Formulary::FromNameLoader
- Extended by:
- Utils::Output::Mixin
- Defined in:
- formulary.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 formula from a name, as long as it exists only in a single tap.
Instance Attribute Summary
Attributes inherited from FromTapLoader
Attributes inherited from FormulaLoader
#alias_path, #name, #path, #tap
Class Method Summary collapse
Methods included from Utils::Output::Mixin
issue_reporting_message, odebug, odeprecated, odie, odisabled, ofail, oh1, oh1_title, ohai, ohai_title, onoe, opoo, opoo_once, opoo_outside_github_actions, opoo_without_github_actions_annotation, pretty_cannot_install, pretty_deprecated, pretty_disabled, pretty_duration, pretty_incompatible, pretty_install_status, pretty_installed, pretty_removed, pretty_uninstalled, pretty_unmarked, pretty_upgradable, pretty_warning
Methods inherited from FromTapLoader
#get_formula, #initialize, #load_file, loader_from_name_tap_type
Methods inherited from FormulaLoader
#get_formula, #initialize, #klass
Methods included from Context
current, current=, #debug?, #deferred_environment_expansion?, #quiet?, #verbose?, #with_context
Constructor Details
This class inherits a constructor from Formulary::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.
589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 |
# File 'formulary.rb', line 589 def self.try_new(ref, warn: false) return unless ref.is_a?(String) return unless ref.match?(/\A#{HOMEBREW_TAP_FORMULA_NAME_REGEX}\Z/o) name = ref.downcase # If it exists in the default tap, never treat it as ambiguous with another tap. if (core_tap = CoreTap.instance).installed? && (name_tap_type = Formulary.tap_formula_name_type( "#{core_tap}/#{name}", warn: false )) migrated_name, migrated_tap, type = name_tap_type if warn && [:rename, :migration].include?(type) && !(type == :migration && migrated_tap.core_cask_tap?) new_full_name = migrated_tap.core_tap? ? migrated_name : "#{migrated_tap}/#{migrated_name}" opoo "Formula #{name} was renamed to #{new_full_name}." end if (core_loader = loader_from_name_tap_type(name_tap_type))&.path&.exist? return core_loader end end loaders = Tap.select { |tap| tap.installed? && !tap.core_tap? } .filter_map { |tap| super("#{tap}/#{name}", warn:) } .uniq(&:path) .select { |loader| loader.is_a?(FromAPILoader) || loader.path.exist? } case loaders.count when 1 loaders.first when 2..Float::INFINITY raise TapFormulaAmbiguityError.new(name, loaders) end end |