<commit_before>defmodule Redix.Auth do
  @moduledoc false

  alias Redix.Protocol

  @doc """
  Authenticates and selects the right database based on the state `state`.

  This function checks the state `state` to see if in the options a password
  and/or a database are specified. If a password is specified, then this
  function will send the appropriate `AUTH` command to the Redis connection in
  `state.socket`. If a database is specified, then the appropriate `SELECT`
  command will be issued.

  The socket is expected to be in passive mode, and will be returned in passive
  mode to the caller.
  """
  @spec auth_and_select_db(:gen_tcp.socket, Keyword.t) :: {:ok, binary} | {:error, term}
  def auth_and_select_db(socket, opts) do
    # TODO: this *begs* for `with` once we depend on ~> 1.2.
    case auth(socket, opts[:password]) do
      {:ok, tail} ->
        select_db(socket, opts[:database], tail)<commit_msg>Update some docs in Redix.Auth<commit_after>defmodule Redix.Auth do
  @moduledoc false

  alias Redix.Protocol

  @doc """
  Authenticates and selects the right database based on the state `state`.

  This function checks the given options to see if a password and/or a database
  are specified. If a password is specified, then this function will send the
  appropriate `AUTH` command to the Redis connection in `state.socket`. If a
  database is specified, then the appropriate `SELECT` command will be issued.

  The socket is expected to be in passive mode, and will be returned in passive
  mode to the caller.
  """
  @spec auth_and_select_db(:gen_tcp.socket, Keyword.t) :: {:ok, binary} | {:error, term}
  def auth_and_select_db(socket, opts) do
    # TODO: this *begs* for `with` once we depend on ~> 1.2.
    case auth(socket, opts[:password]) do
      {:ok, tail} ->
        select_db(socket, opts[:database], tail)
{'fraction_non_alphanumeric': 0.0891891891891892, 'fraction_numerical': 0.002162162162162162, 'mean_word_length': 3.7583547557840618, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1953142', 'n_tokens_mistral': 558, 'n_tokens_neox': 535, 'n_words': 240}