class Bundler::Dsl

def _normalize_options(name, version, opts)

def _normalize_options(name, version, opts)
  _normalize_hash(opts)
  valid_keys = %w(group groups git gist github path name branch ref tag require submodules platform platforms type)
  invalid_keys = opts.keys - valid_keys
  if invalid_keys.any?
    plural = invalid_keys.size > 1
    message = "You passed #{invalid_keys.map{|k| ':'+k }.join(", ")} "
    if plural
      message << "as options for gem '#{name}', but they are invalid."
    else
      message << "as an option for gem '#{name}', but it is invalid."
    end
    message << " Valid options are: #{valid_keys.join(", ")}"
    raise InvalidOption, message
  end
  groups = @groups.dup
  opts["group"] = opts.delete("groups") || opts["group"]
  groups.concat Array(opts.delete("group"))
  groups = [:default] if groups.empty?
  platforms = @platforms.dup
  opts["platforms"] = opts["platform"] || opts["platforms"]
  platforms.concat Array(opts.delete("platforms"))
  platforms.map! { |p| p.to_sym }
  platforms.each do |p|
    next if VALID_PLATFORMS.include?(p)
    raise GemfileError, "`#{p}` is not a valid platform. The available options are: #{VALID_PLATFORMS.inspect}"
  end
  if github = opts.delete("github")
    github = "#{github}/#{github}" unless github.include?("/")
    opts["git"] = "git://github.com/#{github}.git"
  end
  if gist = opts.delete("gist")
    opts["git"] = "https://gist.github.com/#{gist}.git"
  end
  ["git", "path"].each do |type|
    if param = opts[type]
      if version.first && version.first =~ /^\s*=?\s*(\d[^\s]*)\s*$/
        options = opts.merge("name" => name, "version" => $1)
      else
        options = opts.dup
      end
      source = send(type, param, options, :prepend => true) {}
      opts["source"] = source
    end
  end
  opts["source"]  ||= @source
  opts["env"]     ||= @env
  opts["platforms"] = platforms.dup
  opts["group"]     = groups
end