<commit_before>def format(connection, value, type)
  return escape(connection, value) if type == 'string'
  value
end

def escape(connection, value)
  "#{strip_quotes(connection.escape(value))}"
end
<commit_msg>Add utilities to convert permissions hash to string and vice versa<commit_after>def format(connection, value, type)
  return escape(connection, value) if type == 'string'
  value
end

def escape(connection, value)
  "#{strip_quotes(connection.escape(value))}"
end

def permissions_hash_to_string(permissions_hash)
  permissions_string = ''

  permissions_hash.each do |name, permission|
    permissions_string += "#{name}=#{permission};"
  end

  permissions_string
end

def permissions_string_to_hash(permissions_string)
  permissions_hash = {}

  permissions_string.split(';').each do |permission|
    permission_literals = permission.split('=')
    permissions_hash[param_to_sym(permission_literals.first)] = permission_literals.last
  end

  permissions_hash
end

{'fraction_non_alphanumeric': 0.10531697341513292, 'fraction_numerical': 0.0, 'mean_word_length': 6.2518518518518515, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7180086', 'n_tokens_mistral': 294, 'n_tokens_neox': 298, 'n_words': 69}