class Bundler::Settings::Validator::Rule
def fail!(key, value, *reasons)
def fail!(key, value, *reasons) reasons.unshift @description raise InvalidOption, "Setting `#{key}` to #{value.inspect} failed:\n#{reasons.map {|r| " - #{r}" }.join("\n")}" end
def initialize(keys, description, &validate)
def initialize(keys, description, &validate) @keys = keys @description = description @validate = validate end
def k(key)
def k(key) Bundler.settings.key_for(key) end
def set(settings, key, value, *reasons)
def set(settings, key, value, *reasons) hash_key = k(key) return if settings[hash_key] == value reasons.unshift @description Bundler.ui.info "Setting `#{key}` to #{value.inspect}, since #{reasons.join(", ")}" if value.nil? settings.delete(hash_key) else settings[hash_key] = value end end
def validate!(key, value, settings)
def validate!(key, value, settings) instance_exec(key, value, settings, &@validate) end