Class: Formulary::FromPathLoader Private
- Inherits:
-
FormulaLoader
- Object
- FormulaLoader
- Formulary::FromPathLoader
- 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 formulae from disk using a path.
Instance Attribute Summary
Attributes inherited from FormulaLoader
#alias_path, #name, #path, #tap
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(path, alias_path: nil, tap: nil) ⇒ void constructor private
Methods inherited from FormulaLoader
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
Methods included from Context
current, current=, #debug?, #quiet?, #verbose?, #with_context
Constructor Details
#initialize(path, alias_path: nil, tap: nil) ⇒ 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.
757 758 759 760 761 762 763 764 765 766 |
# File 'formulary.rb', line 757 def initialize(path, alias_path: nil, tap: nil) path = Pathname(path). name = path.basename(".rb").to_s alias_path = alias_path&. alias_dir = alias_path&.dirname alias_path = nil if alias_dir != tap&.alias_dir super(name, path, alias_path:, tap:) end |
Class Method Details
.try_new(ref, from: nil, 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.
705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 |
# File 'formulary.rb', line 705 def self.try_new(ref, from: nil, warn: false) path = case ref when String Pathname(ref) when Pathname ref else return end return unless path..exist? if Homebrew::EnvConfig.forbid_packages_from_paths? path_realpath = path.realpath.to_s path_string = path.to_s if (path_realpath.end_with?(".rb") || path_string.end_with?(".rb")) && !path_realpath.start_with?("#{HOMEBREW_CELLAR}/", "#{HOMEBREW_LIBRARY}/Taps/") && !path_string.start_with?("#{HOMEBREW_CELLAR}/", "#{HOMEBREW_LIBRARY}/Taps/") if path_string.include?("./") || path_string.end_with?(".rb") || path_string.count("/") != 2 raise <<~WARNING Homebrew requires formulae to be in a tap, rejecting: #{path_string} (#{path_realpath}) To create a tap, run e.g. brew tap-new <user|org>/<repository> To create a formula in a tap run e.g. brew create <url> --tap=<user|org>/<repository> WARNING elsif path_string.count("/") == 2 # Looks like a tap, let's quietly return but not error. return end end end if (tap = Tap.from_path(path)) # Only treat symlinks in taps as aliases. if path.symlink? alias_path = path path = alias_path.resolved_path end else # Don't treat cache symlinks as aliases. tap = Homebrew::API.tap_from_source_download(path) end return if path.extname != ".rb" new(path, alias_path:, tap:) end |