Class: DATAPatch Private

Inherits:
EmbeddedPatch show all
Defined in:
data_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 at the __END__ of a formula file.

Instance Attribute Summary collapse

Attributes inherited from EmbeddedPatch

#owner, #strip

Instance Method Summary collapse

Methods inherited from EmbeddedPatch

#apply, #external?

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



12
13
14
15
# File 'data_patch.rb', line 12

def initialize(strip)
  super
  @path = T.let(nil, T.nilable(Pathname))
end

Instance Attribute Details

#pathPathname?

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:



9
10
11
# File 'data_patch.rb', line 9

def path
  @path
end

Instance Method Details

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

Returns:

Raises:

  • (ArgumentError)


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'data_patch.rb', line 18

def contents
  path = self.path
  raise ArgumentError, "DATAPatch#contents called before path was set!" unless path

  data = +""
  path.open("rb") do |f|
    loop do
      line = f.gets
      break if line.nil? || /^__END__$/.match?(line)
    end
    while (line = f.gets)
      data << line
    end
  end
  data.freeze
end