<commit_before>module Slack
  module Web
    module Api
      module Pagination
        class Cursor
          include Enumerable

          attr_reader :client
          attr_reader :verb
          attr_reader :sleep_interval
          attr_reader :max_retries
          attr_reader :params

          def initialize(client, verb, params = {})
            @client = client
            @verb = verb
            @sleep_interval = params[:sleep_interval]
            @max_retries = params[:max_retries] || client.default_max_retries
            @params = params.reject { |k, _| [:sleep_interval, :max_retries].include?(k) }
          end

          def each
            next_cursor = nil
            retry_count = 0
            loop do
              query = { limit: client.default_page_size }.merge(params).merge(cursor: next_cursor)
              begin
                response = client.send(verb, query)
              rescue Slack::Web::Api::Errors::TooManyRequestsError => e
                raise e if retry_count >= max_retries
                client.logger.debug("#{self.class}##{__method__}") { e.to_s }
                retry_count += 1
                sleep(e.retry_after.seconds)
                next
              end
              yield response
              break unless response.response_metadata
              next_cursor = response.response_metadata.next_cursor
              break if next_cursor.blank?
              retry_count = 0
              sleep(sleep_interval) if sleep_interval
            end
          end
        end
      end
    end
  end<commit_msg>Dup params and use delete.<commit_after>module Slack
  module Web
    module Api
      module Pagination
        class Cursor
          include Enumerable

          attr_reader :client
          attr_reader :verb
          attr_reader :sleep_interval
          attr_reader :max_retries
          attr_reader :params

          def initialize(client, verb, params = {})
            @client = client
            @verb = verb
            @params = params.dup
            @sleep_interval = @params.delete(:sleep_interval)
            @max_retries = @params.delete(:max_retries) || client.default_max_retries
          end

          def each
            next_cursor = nil
            retry_count = 0
            loop do
              query = { limit: client.default_page_size }.merge(params).merge(cursor: next_cursor)
              begin
                response = client.send(verb, query)
              rescue Slack::Web::Api::Errors::TooManyRequestsError => e
                raise e if retry_count >= max_retries
                client.logger.debug("#{self.class}##{__method__}") { e.to_s }
                retry_count += 1
                sleep(e.retry_after.seconds)
                next
              end
              yield response
              break unless response.response_metadata
              next_cursor = response.response_metadata.next_cursor
              break if next_cursor.blank?
              retry_count = 0
              sleep(sleep_interval) if sleep_interval
            end
          end
        end
      end
    end
  end
{'fraction_non_alphanumeric': 0.06871204857782039, 'fraction_numerical': 0.0019175455417066154, 'mean_word_length': 1.5221595487510073, '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': '228202', 'n_tokens_mistral': 799, 'n_tokens_neox': 789, 'n_words': 188}