<commit_before>require 'rubygems'
require 'bencode'
require 'socket'
require 'digest'

module CJDNS
  class Interface

    # @option options [String] host
    # @option options [Int] port
    # @option options [String] password
    # @option options [Boolean] debug
    # @raise [RuntimeError] if socket is not a valid cjdns socket
    def initialize(options = {})
      options = { 'host' => 'localhost', 'port' => 11234, 'password' => nil, 'debug' => false }.merge options

      @password = options['password']
      @debug = options['debug']

      puts "connecting to #{options['host']}:#{options['port']}" if @debug
      @socket = TCPSocket.open(options['host'], options['port'])
      raise "#{options['host']}:#{options['port']} doesn't appear to be a cjdns socket" unless ping_self
    end

    # @return [Boolean] true if cjdns socket replies
    def ping_self
      return false unless auth_send('ping')['q'] == 'pong'
      true
    end

    # @return [Int] bytes
    def memory
      return auth_send('memory')['bytes']
    end

    # @param [String] path to node
    # @param [Int] timeout<commit_msg>modifies ping_self, improving error message<commit_after>require 'rubygems'
require 'bencode'
require 'socket'
require 'digest'

module CJDNS
  class Interface

    # @option options [String] host
    # @option options [Int] port
    # @option options [String] password
    # @option options [Boolean] debug
    # @raise [RuntimeError] if socket is not a valid cjdns socket
    def initialize(options = {})
      options = { 'host' => 'localhost', 'port' => 11234, 'password' => nil, 'debug' => false }.merge options

      @password = options['password']
      @debug = options['debug']

      puts "connecting to #{options['host']}:#{options['port']}" if @debug
      @socket = TCPSocket.open(options['host'], options['port'])

      response = ping_self
      raise "Error: #{response['error']}" unless response['q'] == 'pong'
    end

    # @return [Boolean] true if cjdns socket replies
    def ping_self
      auth_send('ping')
    end

    # @return [Int] bytes
    def memory
      return auth_send('memory')['bytes']
    end

    # @param [String] path to node
    # @param [Int] timeout
{'fraction_non_alphanumeric': 0.1410488245931284, 'fraction_numerical': 0.0045207956600361665, 'mean_word_length': 3.382178217821782, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '210368', 'n_tokens_mistral': 682, 'n_tokens_neox': 655, 'n_words': 211}