class Redis::Client

def _parse_options(options)

def _parse_options(options)
  defaults = DEFAULTS.dup
  url = options[:url] || ENV["REDIS_URL"]
  # Override defaults from URL if given
  if url
    require "uri"
    uri = URI(url)
    if uri.scheme == "unix"
      defaults[:path]   = uri.path
    else
      # Require the URL to have at least a host
      raise ArgumentError, "invalid url" unless uri.host
      defaults[:scheme]   = uri.scheme
      defaults[:host]     = uri.host
      defaults[:port]     = uri.port if uri.port
      defaults[:password] = uri.password if uri.password
      defaults[:db]       = uri.path[1..-1].to_i if uri.path
    end
  end
  options = defaults.merge(options)
  if options[:path]
    options[:scheme] = "unix"
    options.delete(:host)
    options.delete(:port)
  else
    options[:host] = options[:host].to_s
    options[:port] = options[:port].to_i
  end
  options[:timeout] = options[:timeout].to_f
  options[:db] = options[:db].to_i
  options[:driver] = _parse_driver(options[:driver]) || Connection.drivers.last
  options
end