<commit_before>module RDBI
  class Driver
    class Mock < RDBI::Driver
      def initialize(*args)
        super(Mock::DBH, *args)
      end
    end

    # XXX STUB
    class Mock::STH < RDBI::Statement
      attr_accessor :result
      attr_accessor :rows
      attr_accessor :set_schema
      attr_accessor :input_type_map

      def initialize(query, dbh)
        super
      end

      # just to be abundantly clear, this is a mock method intended to
      # facilitate tests.
      def new_execution(*binds)
        this_data = if result
                      result
                    else
                      (0..4).to_a.collect do |x|
                        binds.collect do |bind|
                          case bind
                          when Integer
                            bind + x
                          else
                            bind.to_s + x.to_s
                          end
                        end
                      end
                    end

        if @rows
          return this_data, @set_schema || RDBI::Schema.new((0..9).to_a.map { |x| RDBI::Column.new(x) }), RDBI::Type.create_type_hash(RDBI::Type::Out), @rows
        else
          return this_data, @set_schema || RDBI::Schema.new((0..9).to_a.map { |x| RDBI::Column.new(x) }), RDBI::Type.create_type_hash(RDBI::Type::Out)
        end
      end
    end

    class Mock::DBH < RDBI::Database
      extend MethLab

      attr_accessor :next_action

      def new_statement(query)
        Mock::STH.new(query, self)
      end

      def ping<commit_msg>* affected_count is the number of affected items by the executed statement.<commit_after>module RDBI
  class Driver
    class Mock < RDBI::Driver
      def initialize(*args)
        super(Mock::DBH, *args)
      end
    end

    # XXX STUB
    class Mock::STH < RDBI::Statement
      attr_accessor :result
      attr_accessor :affected_count
      attr_accessor :set_schema
      attr_accessor :input_type_map

      def initialize(query, dbh)
        super
      end

      # just to be abundantly clear, this is a mock method intended to
      # facilitate tests.
      def new_execution(*binds)
        this_data = if result
                      result
                    else
                      (0..4).to_a.collect do |x|
                        binds.collect do |bind|
                          case bind
                          when Integer
                            bind + x
                          else
                            bind.to_s + x.to_s
                          end
                        end
                      end
                    end

        if @affected_count
          return this_data, @set_schema || RDBI::Schema.new((0..9).to_a.map { |x| RDBI::Column.new(x) }), RDBI::Type.create_type_hash(RDBI::Type::Out), @affected_count
        else
          return this_data, @set_schema || RDBI::Schema.new((0..9).to_a.map { |x| RDBI::Column.new(x) }), RDBI::Type.create_type_hash(RDBI::Type::Out)
        end
      end
    end

    class Mock::DBH < RDBI::Database
      extend MethLab

      attr_accessor :next_action

      def new_statement(query)
        Mock::STH.new(query, self)
      end

      def ping
{'fraction_non_alphanumeric': 0.08530510585305105, 'fraction_numerical': 0.0037359900373599006, 'mean_word_length': 1.378238341968912, 'pattern_counts': {'":': 0, '<': 9, '<?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': '82052', 'n_tokens_mistral': 960, 'n_tokens_neox': 895, 'n_words': 222}