<commit_before>#!/usr/bin/ruby
# @todo ERROR Handling! What happens when things crap out?
require 'socket'
require 'rubygems'

require 'fssm'

path = ARGV.shift
port = ARGV.shift || 0 # default is to use the next available port
host = ARGV.shift # default is to bind everything

server = host ? TCPServer.open(host, port) : TCPServer.open(port)

port = server.addr[1]
addrs = server.addr[2..-1].uniq

# puts "*** listening on #{addrs.collect{|a|"#{a}:#{port}"}.join(' ')}"

s = server.accept

port = s.peeraddr[1]
name = s.peeraddr[2]
addr = s.peeraddr[3]

puts "*** recieving from #{name}:#{port}"

# s.puts 'Connected...'

FSSM.monitor path do |m|
    m.update do |base, relative|
      puts "update #{relative}"
      s.puts "update #{relative}"
      # send_asset(relative, options['quiet']) if local_assets_list.include?(relative)
    end
    m.create do |base, relative|
      puts "create #{relative}"
      s.puts "create #{relative}"
      # send_asset(relative, options['quiet']) if local_assets_list.include?(relative)
    end
    # if !options['keep_files']<commit_msg>send info properly<commit_after>#!/usr/bin/ruby
# @todo ERROR Handling! What happens when things crap out?
require 'socket'
require 'rubygems'

require 'json'
require 'fssm'

path = ARGV.shift
port = ARGV.shift || 0 # default is to use the next available port
host = ARGV.shift # default is to bind everything

server = host ? TCPServer.open(host, port) : TCPServer.open(port)

port = server.addr[1]
addrs = server.addr[2..-1].uniq

# puts "*** listening on #{addrs.collect{|a|"#{a}:#{port}"}.join(' ')}"

s = server.accept

peerport = s.peeraddr[1]
name = s.peeraddr[2]
addr = s.peeraddr[3]

# puts "*** recieving from #{name}:#{peerport}"
# startEvent = { :event => 'connected'}
# s.puts = "connected"

FSSM.monitor path do |m|
    m.update do |base, relative|
      payload = {
        :event => "update",
        :base => base,
        :relative => relative
      }
      s.puts payload.to_json
    end
    m.create do |base, relative|
      payload = {
        :event => "update",
        :base => base,
        :relative => relative
      }
      s.puts payload.to_json
    end
    # if !options['keep_files']
{'fraction_non_alphanumeric': 0.15846994535519127, 'fraction_numerical': 0.006375227686703097, 'mean_word_length': 3.359126984126984, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': 2, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7364468', 'n_tokens_mistral': 769, 'n_tokens_neox': 766, 'n_words': 202}