<commit_before>require 'ransack_query/version'
require 'grouping'
require 'condition'
require 'json'
require 'securerandom'

module RansackQuery

  def self.build(options = {})
    grouping = Grouping.new do |new_grouping|
      yield new_grouping
    end
    ransack_hash = {'g' => grouping.ransackify}
    ransack_hash = {options[:prefix] => ransack_hash} if options[:prefix]
    ransack_hash = ransack_hash.to_json if options[:format] == :json
    ransack_hash
  end

  def self.generate_id
    SecureRandom.hex
  end

  def self.sample
    build do |grouping|
      grouping.combinator = :or
      grouping.add_grouping do |new_grouping|
        new_grouping.add_condition(Condition.new(attribute: 'document_number', value: '111'))
        new_grouping.add_condition(Condition.new(attribute: 'driver_name', value: '222'))
      end
      grouping.add_grouping do |new_grouping|
        new_grouping.add_condition(Condition.new(attribute: 'document_number', value: '333'))
        new_grouping.add_condition(Condition.new(attribute: 'driver_name', value: '444'))
      end
    end
  end

end<commit_msg>Removed sample code that was used for testing<commit_after>require 'ransack_query/version'
require 'grouping'
require 'condition'
require 'json'
require 'securerandom'

module RansackQuery

  def self.build(options = {})
    grouping = Grouping.new do |new_grouping|
      yield new_grouping
    end
    ransack_hash = {'g' => grouping.ransackify}
    ransack_hash = {options[:prefix] => ransack_hash} if options[:prefix]
    ransack_hash = ransack_hash.to_json if options[:format] == :json
    ransack_hash
  end

  def self.generate_id
    SecureRandom.hex
  end

end
{'fraction_non_alphanumeric': 0.10149253731343283, 'fraction_numerical': 0.007164179104477612, 'mean_word_length': 4.033033033033033, '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': '5407727', 'n_tokens_mistral': 571, 'n_tokens_neox': 542, 'n_words': 121}