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) ⇒ Object private
- .find_cask_in_tap(token, tap) ⇒ Object private
- .for(ref, need_path: false, warn: true) ⇒ Object private
- .load(ref, config: nil, warn: true) ⇒ Object private
- .load_from_installed_caskfile(path, config: nil, warn: true) ⇒ Cask private
- .load_prefer_installed(ref, config: nil, warn: true) ⇒ Cask private
- .path(ref) ⇒ Object private
- .tap_cask_token_type(tapped_token, warn:) ⇒ Array<(String, Tap, [Symbol, nil])>? private
Methods included from Context
current, current=, debug?, quiet?, verbose?, with_context
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
Class Method Details
.default_path(token) ⇒ Object
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.
668 669 670 |
# File 'cask/cask_loader.rb', line 668 def self.default_path(token) find_cask_in_tap(token.to_s.downcase, CoreCaskTap.instance) end |
.find_cask_in_tap(token, tap) ⇒ Object
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.
672 673 674 675 676 |
# File 'cask/cask_loader.rb', line 672 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) ⇒ Object
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.
623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 |
# File 'cask/cask_loader.rb', line 623 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 end |
.load(ref, config: nil, warn: true) ⇒ Object
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.
584 585 586 |
# File 'cask/cask_loader.rb', line 584 def self.load(ref, config: nil, warn: true) self.for(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.
661 662 663 664 665 666 |
# File 'cask/cask_loader.rb', line 661 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.
643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 |
# File 'cask/cask_loader.rb', line 643 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) ⇒ Object
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.
580 581 582 |
# File 'cask/cask_loader.rb', line 580 def self.path(ref) self.for(ref, need_path: true).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.
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 |
# File 'cask/cask_loader.rb', line 589 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) || [Tap.fetch(new_tap_name), token] new_tap.ensure_installed! new_tapped_token = "#{new_tap}/#{new_token}" if tapped_token == new_tapped_token opoo "Tap migration for #{tapped_token} points to itself, stopping recursion." else 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 opoo "Cask #{old_token} was renamed to #{new_token}." if warn && old_token && new_token [token, tap, type] end |