<commit_before>require 'websocket-client-simple'

module WebSocket::Client::Simple
  # Patch to the WSCS class to allow reading the internal thread
  class Client
    # @return [Thread] the internal thread this client is using for the event loop.
    attr_reader :thread
  end
end

module Discordrb
  # Utility wrapper class that abstracts an instance of WSCS. Useful should we decide that WSCS isn't good either -
  # in that case we can just switch to something else
  class WebSocket
    attr_reader :open_handler, :message_handler, :close_handler, :error_handler

    def initialize(endpoint, open_handler, message_handler, close_handler, error_handler)
      @open_handler = open_handler
      @message_handler = message_handler
      @close_handler = close_handler
      @error_handler = error_handler

      instance = self # to work around WSCS's weird way of handling blocks

      @client = WebSocket::Client::Simple.connect(endpoint) do |ws|
        ws.on(:open) { instance.open_handler.call }
        ws.on(:message) { |msg| instance.message_handler.call(msg) }
        ws.on(:close) { |err| instance.close_handler.call(err) }
        ws.on(:error) { |err| instance.error_handler.call(err) }
      end
    end

    # Send data over this WebSocket
    # @param data [String] What to send
    def send(data)
      @client.send(data)
    end

    # Close the WebSocket connection
    def close<commit_msg>Fix the WebSocket wrapper trying to access the WSCS module wrong<commit_after>require 'websocket-client-simple'

puts "Using WSCS version: #{WebSocket::Client::Simple::VERSION}"
module WebSocket::Client::Simple
  # Patch to the WSCS class to allow reading the internal thread
  class Client
    # @return [Thread] the internal thread this client is using for the event loop.
    attr_reader :thread
  end
end

module Discordrb
  # Utility wrapper class that abstracts an instance of WSCS. Useful should we decide that WSCS isn't good either -
  # in that case we can just switch to something else
  class WebSocket
    attr_reader :open_handler, :message_handler, :close_handler, :error_handler

    def initialize(endpoint, open_handler, message_handler, close_handler, error_handler)
      @open_handler = open_handler
      @message_handler = message_handler
      @close_handler = close_handler
      @error_handler = error_handler

      instance = self # to work around WSCS's weird way of handling blocks

      @client = ::WebSocket::Client::Simple.connect(endpoint) do |ws|
        ws.on(:open) { instance.open_handler.call }
        ws.on(:message) { |msg| instance.message_handler.call(msg) }
        ws.on(:close) { |err| instance.close_handler.call(err) }
        ws.on(:error) { |err| instance.error_handler.call(err) }
      end
    end

    # Send data over this WebSocket
    # @param data [String] What to send
    def send(data)
      @client.send(data)
    end

    # Close the WebSocket connection
    def close
{'fraction_non_alphanumeric': 0.08214528173794976, 'fraction_numerical': 0.0, 'mean_word_length': 3.5199386503067487, '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': '5418490', 'n_tokens_mistral': 865, 'n_tokens_neox': 836, 'n_words': 282}