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) ⇒ 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, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_install_status, #pretty_installed, #pretty_outdated, #pretty_uninstalled, #pretty_upgradable
Constructor Details
#initialize(strip, file) ⇒ 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.
25 26 27 28 |
# File 'local_patch.rb', line 25 def initialize(strip, file) super(strip) @file = file 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.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'local_patch.rb', line 31 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) repository_path = repository_path(formula) 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) 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 |