brew/Library/Homebrew/cask/dsl/conflicts_with.rb
Mike McQuaid d13aaf94db
Deprecate conflicts_with formula: in Cask DSL.
This is outside of our usual deprecation process but it's a no-op method
that does, and has always done, nothing so it doesn't make sense to wait
another 2.5 months before deprecating it.

While we're here, make `conflicts_with` `typed: strict` in Sorbet.
2025-08-18 19:25:54 +01:00

42 lines
977 B
Ruby

# typed: strict
# frozen_string_literal: true
require "delegate"
require "extend/hash/keys"
module Cask
class DSL
# Class corresponding to the `conflicts_with` stanza.
class ConflictsWith < SimpleDelegator
VALID_KEYS = [:cask].freeze
ODEPRECATED_KEYS = [
:formula,
:macos,
:arch,
:x11,
:java,
].freeze
sig { params(options: T.anything).void }
def initialize(**options)
options.assert_valid_keys(*VALID_KEYS, *ODEPRECATED_KEYS)
options.keys.intersection(ODEPRECATED_KEYS).each do |key|
odeprecated "conflicts_with #{key}:"
end
conflicts = options.transform_values { |v| Set.new(Kernel.Array(v)) }
conflicts.default = Set.new
super(conflicts)
end
sig { params(generator: T.anything).returns(String) }
def to_json(generator)
__getobj__.transform_values(&:to_a).to_json(generator)
end
end
end
end