<commit_before>#!/usr/bin/env ruby

$:.push('gen-rb')
$:.push('../../lib/rb/lib')

require 'thrift/transport/tsocket'
require 'thrift/protocol/tbinaryprotocol'
require 'thrift/server/tserver'
require 'ThriftTest'

class TestHandler
  def testVoid()
    print "testVoid()\n"
  end

  def testString(thing)
    print "testString(#{thing})\n"
    return thing
  end

  def testByte(thing)
    print "testByte(#{thing})\n"
    return thing
  end

  def testI32(thing)
    print "testI32(#{thing})\n"
    return thing
  end

  def testI64(thing)
    print "testI64(#{thing})\n"
    return thing
  end

  def testDouble(thing)
    print "testDouble(#{thing})\n"
    return thing
  end

  def testStruct(thing)
    print "testStruct(#{thing})\n"
    print "  with attrs: #{thing.string_thing}, #{thing.byte_thing}, #{thing.i32_thing}"
    return thing
  end

  def testMap(thing)
    print "testMap(#{thing})\n"
    return thing
  end
    
  def testSet(thing)
    print "testSet(#{thing})\n"
    return thing
  end

  def testList(thing)
    print "testList(#{thing})\n"
    return thing
  end

  def testNest(thing)
    print "testNest(#{thing})\n"
    puts "  i32_thing: #{thing.i32_thing}"
    puts "  with struct: "
    %w{ string_thing byte_thing i32_thing }.each do |t|
      puts "    #{t}: #{thing.struct_thing.send(t)}"
    end
    return thing
  end
  
  def testNest(thing)
    print "testNest(#{thing})\n"
    puts "  i32_thing: #{thing.i32_thing}"
    puts "  with struct: "
    %w{ string_thing byte_thing i32_thing }.each do |t|
      puts "    #{t}: #{thing.struct_thing.send(t)}"
    end
    return thing
  end
  
  def testInsanity(thing)
    puts "insanity:"
    puts "  #{thing.inspect}"
    num, uid = thing.userMap.find { true }
    return {uid => {num => thing}}
  end

  def testMapMap(thing)
    puts "got: #{thing}"
    return {thing => {thing => thing}}
  end

end

handler = TestHandler.new()
processor = Thrift::Test::ThriftTest::Processor.new(handler)
transport = TServerSocket.new(9090)
server = TSimpleServer.new(processor, transport)
server.serve()<commit_msg>Complete rb test server with testEnum and testTypedef<commit_after>#!/usr/bin/env ruby

$:.push('gen-rb')
$:.push('../../lib/rb/lib')

require 'thrift/transport/tsocket'
require 'thrift/protocol/tbinaryprotocol'
require 'thrift/server/tserver'
require 'ThriftTest'

class TestHandler
  def testVoid()
    print "testVoid()\n"
  end

  def testString(thing)
    print "testString(#{thing})\n"
    return thing
  end

  def testByte(thing)
    print "testByte(#{thing})\n"
    return thing
  end

  def testI32(thing)
    print "testI32(#{thing})\n"
    return thing
  end

  def testI64(thing)
    print "testI64(#{thing})\n"
    return thing
  end

  def testDouble(thing)
    print "testDouble(#{thing})\n"
    return thing
  end

  def testStruct(thing)
    print "testStruct(#{thing})\n"
    print "  with attrs: #{thing.string_thing}, #{thing.byte_thing}, #{thing.i32_thing}"
    return thing
  end

  def testMap(thing)
    print "testMap(#{thing})\n"
    return thing
  end

  def testSet(thing)
    print "testSet(#{thing})\n"
    return thing
  end

  def testList(thing)
    print "testList(#{thing})\n"
    return thing
  end

  def testNest(thing)
    print "testNest(#{thing})\n"
    puts "  i32_thing: #{thing.i32_thing}"
    puts "  with struct: "
    %w{ string_thing byte_thing i32_thing }.each do |t|
      puts "    #{t}: #{thing.struct_thing.send(t)}"
    end
    return thing
  end

  def testInsanity(thing)
    puts "insanity:"
    puts "  #{thing.inspect}"
    num, uid = thing.userMap.find { true }
    return {uid => {num => thing}}
  end

  def testMapMap(thing)
    puts "got: #{thing}"
    return {thing => {thing => thing}}
  end

  def testEnum(thing)
    puts "testEnum(#{thing})"
    return thing
  end

  def testTypedef(thing)
    puts "testTypedef(#{thing})"
    return thing
  end

end

handler = TestHandler.new()
processor = Thrift::Test::ThriftTest::Processor.new(handler)
transport = TServerSocket.new(9090)
server = TSimpleServer.new(processor, transport)
server.serve()
{'fraction_non_alphanumeric': 0.14324060517325524, 'fraction_numerical': 0.011224987798926306, 'mean_word_length': 3.2301341589267287, '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': '772707', 'n_tokens_mistral': 1481, 'n_tokens_neox': 1459, 'n_words': 340}