Class: EmbeddedPatch Abstract Private

Inherits:
Object show all
Extended by:
T::Helpers
Includes:
Utils::Output::Mixin
Defined in:
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.

This class is abstract.

It cannot be directly instantiated. Subclasses must implement the abstract methods below.

An abstract class representing a patch embedded into a formula.

Direct Known Subclasses

DATAPatch, StringPatch

Instance Attribute Summary collapse

Instance Method Summary collapse

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

Constructor Details

#initialize(strip) ⇒ 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.

Parameters:



52
53
54
55
# File 'patch.rb', line 52

def initialize(strip)
  @strip = T.let(strip, T.any(String, Symbol))
  @owner = T.let(nil, T.nilable(Owner))
end

Instance Attribute Details

#owner=(value) ⇒ Owner? (writeonly)

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.

Returns:



46
47
48
# File 'patch.rb', line 46

def owner=(value)
  @owner = value
end

#stripString, Symbol (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.

Returns:



49
50
51
# File 'patch.rb', line 49

def strip
  @strip
end

Instance Method Details

#applyvoid

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.

This method returns an undefined value.



66
67
68
69
70
71
72
73
74
# File 'patch.rb', line 66

def apply
  data = contents.gsub("@@HOMEBREW_PREFIX@@", HOMEBREW_PREFIX)
  if data.gsub!("HOMEBREW_PREFIX", HOMEBREW_PREFIX)
    odeprecated "patch with HOMEBREW_PREFIX placeholder",
                "patch with @@HOMEBREW_PREFIX@@ placeholder"
  end
  args = %W[-g 0 -f -#{strip}]
  Utils.safe_popen_write("patch", *args) { |p| p.write(data) }
end

#contentsString

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.

This method is abstract.

Returns:



63
# File 'patch.rb', line 63

def contents; end

#external?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.

Returns:

  • (Boolean)


58
59
60
# File 'patch.rb', line 58

def external?
  false
end