<commit_before># Copyright (c) Torrox GmbH & Co KG. All rights reserved.
# Please note that the content of this file is confidential or protected by law.
# Any unauthorised copying or unauthorised distribution of the information contained herein is prohibited.

$LOAD_PATH << File.expand_path('../../rack/lib', __FILE__)

require 'rack'
require 'rack/handler/sioux'
require 'rack/static'

puts "starting rack_chat...."

class Adapter
    @@SAY_CHANNEL  = { 'p1' => 'say' }
    @@CHAT_CHANNEL = { 'p1' => 'chat' } 
    @@MAX_MESSAGES = 20

    def initialize
        @messages = []
    end
        
    def validate_node node
        node == @@CHAT_CHANNEL 
    end
    
    def authorize subscriber, node
        true
    end
     
    def node_init node
        @messages
    end
    
    def publish node, data, root 
        return [ false, 'invalid channel' ] unless node == @@SAY_CHANNEL
        
        @messages.shift if @messages.size == @@MAX_MESSAGES 
        @messages << { 'head' => '?', 'text' => data }

        root[ @@CHAT_CHANNEL ] = { 'data' => @messages }

        [ true, '' ]
    end
end

ROOT = File.expand_path(File.dirname(__FILE__))

app = Rack::Builder.new do
    use Rack::Static, :urls => [ '/jquery' ], :root => ROOT
    use Rack::Static, :urls => [ '/' ], :index => '/index.html', :root => File.join( ROOT, 'chat' )
    run lambda { | env | [ 404, { 'Content-Type' => 'text/html' }, [] ] }
end

Rack::Handler::Sioux.run( app, 'Environment' => 'debug', 'Host' => 'localhost', 'Port' => 8080, 'Adapter' => Adapter.new )
<commit_msg>the build flavor is selected by the ruby library path; hit how to connect to rack_chat<commit_after># Copyright (c) Torrox GmbH & Co KG. All rights reserved.
# Please note that the content of this file is confidential or protected by law.
# Any unauthorised copying or unauthorised distribution of the information contained herein is prohibited.

$LOAD_PATH << File.expand_path('../../rack/lib', __FILE__)

require 'rack'
require 'rack/handler/sioux'
require 'rack/static'

puts "starting rack_chat...."
puts "connect to server via: \'http://localhost:8080\'"

class Adapter
    @@SAY_CHANNEL  = { 'p1' => 'say' }
    @@CHAT_CHANNEL = { 'p1' => 'chat' } 
    @@MAX_MESSAGES = 20

    def initialize
        @messages = []
    end
        
    def validate_node node
        node == @@CHAT_CHANNEL 
    end
    
    def authorize subscriber, node
        true
    end
     
    def node_init node
        @messages
    end
    
    def publish node, data, root 
        return [ false, 'invalid channel' ] unless node == @@SAY_CHANNEL
        
        @messages.shift if @messages.size == @@MAX_MESSAGES 
        @messages << { 'head' => '?', 'text' => data }

        root[ @@CHAT_CHANNEL ] = { 'data' => @messages }

        [ true, '' ]
    end
end

ROOT = File.expand_path(File.dirname(__FILE__))

app = Rack::Builder.new do
    use Rack::Static, :urls => [ '/jquery' ], :root => ROOT
    use Rack::Static, :urls => [ '/' ], :index => '/index.html', :root => File.join( ROOT, 'chat' )
    run lambda { | env | [ 404, { 'Content-Type' => 'text/html' }, [] ] }
end

Rack::Handler::Sioux.run( app, 'Host' => 'localhost', 'Port' => 8080, 'Adapter' => Adapter.new )

{'fraction_non_alphanumeric': 0.14976744186046512, 'fraction_numerical': 0.00806201550387597, 'mean_word_length': 2.703788748564868, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 32, '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': '782393', 'n_tokens_mistral': 1092, 'n_tokens_neox': 1014, 'n_words': 307}