Class: LocalPatch Private
- Inherits:
-
EmbeddedPatch
- Object
- EmbeddedPatch
- LocalPatch
- Defined in:
- local_patch.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.
A patch file stored locally within a formula repository.
Instance Attribute Summary collapse
- #file ⇒ String, Pathname readonly private
- #owner ⇒ Resource::Owner? readonly private
Attributes inherited from EmbeddedPatch
Class Method Summary collapse
Instance Method Summary collapse
- #contents ⇒ String private
- #initialize(strip, file, directory = nil) ⇒ void constructor private
Methods inherited from EmbeddedPatch
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_upgradable
Constructor Details
#initialize(strip, file, directory = 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.
31 32 33 34 35 |
# File 'local_patch.rb', line 31 def initialize(strip, file, directory = nil) super(strip) @file = file self.directory = directory end |
Instance Attribute Details
#file ⇒ String, Pathname (readonly)
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.
9 10 11 |
# File 'local_patch.rb', line 9 def file @file end |
#owner ⇒ Resource::Owner? (readonly)
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.
12 13 14 |
# File 'local_patch.rb', line 12 def owner @owner end |
Class Method Details
.valid_path?(path_string) ⇒ Boolean
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.
15 16 17 18 19 20 21 22 |
# File 'local_patch.rb', line 15 def self.valid_path?(path_string) path = Pathname(path_string).cleanpath path_string.present? && !path_string.end_with?("/") && !path.absolute? && %w[. ..].exclude?(path.to_s) && !path.to_s.start_with?("../") end |
Instance Method Details
#contents ⇒ String
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.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'local_patch.rb', line 38 def contents owner = self.owner raise ArgumentError, "LocalPatch#contents called before owner was set!" unless owner formula = T.cast(owner, SoftwareSpec).owner raise ArgumentError, "LocalPatch#contents requires a formula owner!" unless formula.is_a?(::Formula) formula_path = formula.specified_path || formula.path api_repository_path = api_source_repository_path(formula_path) repository_path = api_repository_path || formula.tap&.path || formula_path.dirname file_path = repository_path/Pathname(file) repository_realpath = repository_path.realpath file_realpath = begin file_path.realpath rescue Errno::ENOENT raise ArgumentError, "Patch file does not exist: #{file}" end if file_realpath.ascend.none?(repository_realpath) && !(api_repository_path && begin file_path..ascend.any?(api_repository_path.) && file_realpath.ascend.any?((HOMEBREW_CACHE/"downloads").realpath) rescue Errno::ENOENT false end) raise ArgumentError, "Patch file must be within the formula repository." end raise ArgumentError, "Patch file must be a file: #{file}" unless file_realpath.file? file_realpath.read end |