Module: Patch

Defined in:
Library/Homebrew/patch.rb

Class Method Summary collapse

Class Method Details

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



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'Library/Homebrew/patch.rb', line 5

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
  else
    raise ArgumentError, "unexpected value #{strip.inspect} for strip"
  end
end

.normalize_legacy_patches(list) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'Library/Homebrew/patch.rb', line 25

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|
      case url
      when :DATA
        patch = DATAPatch.new(strip)
      else
        patch = LegacyPatch.new(strip, url)
      end
      patches << patch
    end
  end

  patches
end