brew/Library/Homebrew/cask/dsl/conflicts_with.rb

35 lines
697 B
Ruby
Raw Normal View History

2023-03-18 16:03:10 -07:00
# typed: true
# frozen_string_literal: true
require "delegate"
2024-01-12 09:38:49 -08:00
require "extend/hash/keys"
2018-09-06 08:29:14 +02:00
module Cask
2016-09-24 13:52:43 +02:00
class DSL
2020-08-24 23:09:43 +02:00
# Class corresponding to the `conflicts_with` stanza.
class ConflictsWith < SimpleDelegator
VALID_KEYS = [
2016-10-14 20:33:16 +02:00
:formula,
:cask,
:macos,
:arch,
:x11,
:java,
].freeze
2017-08-05 15:56:34 +02:00
def initialize(**options)
options.assert_valid_keys(*VALID_KEYS)
2017-08-05 15:56:34 +02:00
2023-03-18 16:03:10 -07:00
conflicts = options.transform_values { |v| Set.new(Kernel.Array(v)) }
conflicts.default = Set.new
2018-09-17 02:45:00 +02:00
super(conflicts)
2016-09-24 13:52:43 +02:00
end
def to_json(generator)
2023-03-18 16:03:10 -07:00
__getobj__.transform_values(&:to_a).to_json(generator)
end
2016-09-24 13:52:43 +02:00
end
2016-08-18 22:11:42 +03:00
end
end