Class: EmbeddedPatch Abstract Private

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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) ⇒ 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:



24
25
26
27
28
# File 'embedded_patch.rb', line 24

def initialize(strip)
  @strip = strip
  @owner = T.let(nil, T.nilable(Resource::Owner))
  @directory = T.let(nil, T.nilable(T.any(String, Pathname)))
end

Instance Attribute Details

#directoryString, ...

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:



21
22
23
# File 'embedded_patch.rb', line 21

def directory
  @directory
end

#owner=(value) ⇒ Resource::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:



15
16
17
# File 'embedded_patch.rb', line 15

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:



18
19
20
# File 'embedded_patch.rb', line 18

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.



39
40
41
42
43
44
45
46
47
48
49
# File 'embedded_patch.rb', line 39

def apply
  data = contents.gsub("@@HOMEBREW_PREFIX@@", HOMEBREW_PREFIX)
  args = %W[-g 0 -f -#{strip}]
  dir = Pathname.pwd
  if (subdirectory = directory.presence)
    dir /= subdirectory
  end
  dir.cd do
    Utils.safe_popen_write("patch", *args) { |p| p.write(data) }
  end
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:



36
# File 'embedded_patch.rb', line 36

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)


31
32
33
# File 'embedded_patch.rb', line 31

def external?
  false
end