Module: Patch Private

Defined in:
Library/Homebrew/patch.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Helper module for creating patches.

Class Method Summary collapse

Class Method Details

.create(strip, src, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'Library/Homebrew/patch.rb', line 10

def self.create(strip, src, &block)
  case strip
  when :DATA
    DATAPatch.new(:p1)
  when String
    StringPatch.new(:p1, strip)
  when Symbol
    case src
    when :DATA
      DATAPatch.new(strip)
    when String
      StringPatch.new(strip, src)
    else
      ExternalPatch.new(strip, &block)
    end
  when nil
    raise ArgumentError, "nil value for strip"
  else
    raise ArgumentError, "unexpected value #{strip.inspect} for strip"
  end
end

.normalize_legacy_patches(list) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'Library/Homebrew/patch.rb', line 32

def self.normalize_legacy_patches(list)
  patches = []

  case list
  when Hash
    list
  when Array, String, :DATA
    { p1: list }
  else
    {}
  end.each_pair do |strip, urls|
    Array(urls).each do |url|
      patch = case url
      when :DATA
        DATAPatch.new(strip)
      else
        LegacyPatch.new(strip, url)
      end
      patches << patch
    end
  end

  patches
end