Module: Cask::CaskLoader Private
- Extended by:
- Context, Utils::Output::Mixin
- Defined in:
- cask/cask_loader.rb
Overview
This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.
Loads a cask from various sources.
Defined Under Namespace
Modules: ILoader Classes: AbstractContentLoader, FromAPILoader, FromContentLoader, FromInstalledPathLoader, FromInstanceLoader, FromNameLoader, FromPathLoader, FromTapLoader, FromURILoader, NullLoader
Class Method Summary collapse
- .default_path(token) ⇒ Pathname private
- .find_cask_in_tap(token, tap) ⇒ Pathname private
-
.for(ref, need_path: false, warn: true) ⇒ ILoader
private
which would interfere with RSpec mocking of this class method.
-
.load(ref, config: nil, warn: true) ⇒ Cask
private
which would interfere with RSpec mocking of this class method.
- .load_from_installed_caskfile(path, config: nil, warn: true) ⇒ Cask private
- .load_prefer_installed(ref, config: nil, warn: true) ⇒ Cask private
-
.path(ref) ⇒ Pathname
private
which would interfere with RSpec mocking of this class method.
- .tap_cask_token_type(tapped_token, warn:) ⇒ Array<(String, Tap, [Symbol, nil])>? private
Methods included from Context
current, current=, debug?, deferred_environment_expansion?, quiet?, verbose?, with_context
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
Class Method Details
.default_path(token) ⇒ Pathname
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.
782 783 784 |
# File 'cask/cask_loader.rb', line 782 def self.default_path(token) find_cask_in_tap(token.to_s.downcase, CoreCaskTap.instance) end |
.find_cask_in_tap(token, tap) ⇒ Pathname
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.
787 788 789 790 791 |
# File 'cask/cask_loader.rb', line 787 def self.find_cask_in_tap(token, tap) filename = "#{token}.rb" tap.cask_files_by_name.fetch(token, tap.cask_dir/filename) end |
.for(ref, need_path: false, warn: true) ⇒ ILoader
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.
Using WithoutRuntime to avoid Sorbet wrapping this method,
which would interfere with RSpec mocking of this class method.
734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 |
# File 'cask/cask_loader.rb', line 734 def self.for(ref, need_path: false, warn: true) [ FromInstanceLoader, FromContentLoader, FromURILoader, FromAPILoader, FromTapLoader, FromNameLoader, FromPathLoader, FromInstalledPathLoader, NullLoader, ].each do |loader_class| if (loader = loader_class.try_new(ref, warn:)) $stderr.puts "#{$PROGRAM_NAME} (#{loader.class}): loading #{ref}" if verbose? && debug? return loader end end raise CaskError, "No cask loader found for #{ref.inspect}" end |
.load(ref, config: nil, warn: true) ⇒ 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.
Using WithoutRuntime to avoid Sorbet wrapping this method,
which would interfere with RSpec mocking of this class method.
677 678 679 680 |
# File 'cask/cask_loader.rb', line 677 def self.load(ref, config: nil, warn: true) normalized_ref = ref.is_a?(Symbol) ? ref.to_s : ref self.for(normalized_ref, warn:).load(config:) end |
.load_from_installed_caskfile(path, config: nil, warn: true) ⇒ 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.
774 775 776 777 778 779 |
# File 'cask/cask_loader.rb', line 774 def self.load_from_installed_caskfile(path, config: nil, warn: true) loader = FromInstalledPathLoader.try_new(path, warn:) loader ||= NullLoader.new(path) loader.load(config:) end |
.load_prefer_installed(ref, config: nil, warn: true) ⇒ 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.
756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 |
# File 'cask/cask_loader.rb', line 756 def self.load_prefer_installed(ref, config: nil, warn: true) tap, token = Tap.with_cask_token(ref) token ||= ref tap ||= Cask.new(ref).tab.tap if tap.nil? self.load(token, config:, warn:) else begin self.load("#{tap}/#{token}", config:, warn:) rescue CaskUnavailableError # cask may be migrated to different tap. Try to search in all taps. self.load(token, config:, warn:) end end end |
.path(ref) ⇒ Pathname
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.
Using WithoutRuntime to avoid Sorbet wrapping this method,
which would interfere with RSpec mocking of this class method.
667 668 669 |
# File 'cask/cask_loader.rb', line 667 def self.path(ref) T.cast(self.for(ref, need_path: true), T.any(FromAPILoader, FromPathLoader)).path end |
.tap_cask_token_type(tapped_token, warn:) ⇒ Array<(String, Tap, [Symbol, nil])>?
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.
683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 |
# File 'cask/cask_loader.rb', line 683 def self.tap_cask_token_type(tapped_token, warn:) return unless (tap_with_token = Tap.with_cask_token(tapped_token)) tap, token = tap_with_token type = nil if (new_token = tap.cask_renames[token].presence) old_token = tap.core_cask_tap? ? token : tapped_token token = new_token new_token = tap.core_cask_tap? ? token : "#{tap}/#{token}" type = :rename elsif (new_tap_name = tap.tap_migrations[token].presence) new_tap, new_token = Tap.with_cask_token(new_tap_name) unless new_tap if new_tap_name.include?("/") new_tap = Tap.fetch(new_tap_name) new_token = token else new_tap = tap new_token = new_tap_name end end new_tapped_token = "#{new_tap}/#{new_token}" if tapped_token != new_tapped_token old_token = tap.core_cask_tap? ? token : tapped_token return unless (token_tap_type = tap_cask_token_type(new_tapped_token, warn: false)) token, tap, = token_tap_type new_token = new_tap.core_cask_tap? ? token : "#{tap}/#{token}" type = :migration end end if warn && old_token && new_token destination_exists = find_cask_in_tap(token, tap).exist? || (tap.core_cask_tap? && !Homebrew::EnvConfig.no_install_from_api? && Homebrew::API.cask_token?(token)) opoo "Cask #{old_token} was renamed to #{new_token}." if destination_exists end [token, tap, type] end |