Class: Hbc::DSL::DependsOn

Inherits:
Hash
  • Object
show all
Defined in:
Library/Homebrew/cask/lib/hbc/dsl/depends_on.rb

Constant Summary collapse

VALID_KEYS =
Set.new [
  :formula,
  :cask,
  :macos,
  :arch,
  :x11,
  :java,
].freeze
VALID_ARCHES =
{
  intel:    { type: :intel, bits: 64 },
  # specific
  x86_64:   { type: :intel, bits: 64 },
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDependsOn

Returns a new instance of DependsOn



24
25
26
27
28
# File 'Library/Homebrew/cask/lib/hbc/dsl/depends_on.rb', line 24

def initialize
  super({})
  @cask ||= []
  @formula ||= []
end

Instance Attribute Details

#archObject

Returns the value of attribute arch



22
23
24
# File 'Library/Homebrew/cask/lib/hbc/dsl/depends_on.rb', line 22

def arch
  @arch
end

#caskObject

Returns the value of attribute cask



22
23
24
# File 'Library/Homebrew/cask/lib/hbc/dsl/depends_on.rb', line 22

def cask
  @cask
end

#formulaObject

Returns the value of attribute formula



22
23
24
# File 'Library/Homebrew/cask/lib/hbc/dsl/depends_on.rb', line 22

def formula
  @formula
end

#javaObject

Returns the value of attribute java



21
22
23
# File 'Library/Homebrew/cask/lib/hbc/dsl/depends_on.rb', line 21

def java
  @java
end

#macosObject

Returns the value of attribute macos



22
23
24
# File 'Library/Homebrew/cask/lib/hbc/dsl/depends_on.rb', line 22

def macos
  @macos
end

#x11Object

Returns the value of attribute x11



22
23
24
# File 'Library/Homebrew/cask/lib/hbc/dsl/depends_on.rb', line 22

def x11
  @x11
end

Class Method Details

.coerce_os_release(arg) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'Library/Homebrew/cask/lib/hbc/dsl/depends_on.rb', line 37

def self.coerce_os_release(arg)
  @macos_symbols ||= MacOS::Version::SYMBOLS
  @inverted_macos_symbols ||= @macos_symbols.invert

  begin
    if arg.is_a?(Symbol)
      Gem::Version.new(@macos_symbols.fetch(arg))
    elsif arg =~ /^\s*:?([a-z]\S+)\s*$/i
      Gem::Version.new(@macos_symbols.fetch(Regexp.last_match[1].downcase.to_sym))
    elsif @inverted_macos_symbols.key?(arg)
      Gem::Version.new(arg)
    else
      raise
    end
  rescue StandardError
    raise "invalid 'depends_on macos' value: #{arg.inspect}"
  end
end

Instance Method Details

#load(**pairs) ⇒ Object



30
31
32
33
34
35
# File 'Library/Homebrew/cask/lib/hbc/dsl/depends_on.rb', line 30

def load(**pairs)
  pairs.each do |key, value|
    raise "invalid depends_on key: '#{key.inspect}'" unless VALID_KEYS.include?(key)
    self[key] = send(:"#{key}=", *value)
  end
end