class Bundler::Dsl
def validate_keys(command, opts, valid_keys)
def validate_keys(command, opts, valid_keys) invalid_keys = opts.keys - valid_keys git_source = opts.keys & @git_sources.keys.map(&:to_s) if opts["branch"] && !(opts["git"] || opts["github"] || git_source.any?) raise GemfileError, %(The `branch` option for `#{command}` is not allowed. Only gems with a git source can specify a branch) end return true unless invalid_keys.any? message = String.new message << "You passed #{invalid_keys.map {|k| ":" + k }.join(", ")} " message << if invalid_keys.size > 1 "as options for #{command}, but they are invalid." else "as an option for #{command}, but it is invalid." end message << " Valid options are: #{valid_keys.join(", ")}." message << " You may be able to resolve this by upgrading Bundler to the newest version." raise InvalidOption, message end