<commit_before>require 'rack_jax'
require 'rack/handler'

Rack::Handler.register('rack_jax', 'Rack::Handler::RackJax')

module Rack
  module Handler

    class RackJax
      def self.run(app, options={})
        puts 'Extracting options...'
        host = options.delete(:Host) || default_host
        port = options.delete(:Port) || 7070

        puts 'Wrapping app...'
        wrapp = ::RackJax::AppWrapper.new(app, host, port)

        puts 'Creating server...'
        server = create_server(wrapp, port.to_i)

        puts 'Starting server...'
        server.listen
        server.serve
      end

      def self.valid_options
        {
          "Host=HOST" => "Hostname to listen on (default: #{default_host})",
          "Port=PORT" => "Port to listen on (default: 7070)",
        }
      end

      private

      def self.create_server(app, port)
        Java::NetZefiraizingHttp_server::HttpServer::create_server(port, app)
      end

      def self.default_host
        environment  = ENV['RACK_ENV'] || 'development'
        environment == 'development' ? 'localhost' : '0.0.0.0'
      end
    end
  end
end
<commit_msg>Print the listening port in server startup<commit_after>require 'rack_jax'
require 'rack/handler'

Rack::Handler.register('rack_jax', 'Rack::Handler::RackJax')

module Rack
  module Handler

    class RackJax
      def self.run(app, options={})
        puts 'Extracting options...'
        host = options.delete(:Host) || default_host
        port = options.delete(:Port) || 7070

        puts 'Wrapping app...'
        wrapp = ::RackJax::AppWrapper.new(app, host, port)

        puts 'Creating server...'
        server = create_server(wrapp, port.to_i)

        puts "Starting server on port #{port}..."
        server.listen
        server.serve
      end

      def self.valid_options
        {
          "Host=HOST" => "Hostname to listen on (default: #{default_host})",
          "Port=PORT" => "Port to listen on (default: 7070)",
        }
      end

      private

      def self.create_server(app, port)
        Java::NetZefiraizingHttp_server::HttpServer::create_server(port, app)
      end

      def self.default_host
        environment  = ENV['RACK_ENV'] || 'development'
        environment == 'development' ? 'localhost' : '0.0.0.0'
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.12591951536131546, 'fraction_numerical': 0.01038511466897447, 'mean_word_length': 2.36046511627907, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '7221087', 'n_tokens_mistral': 740, 'n_tokens_neox': 709, 'n_words': 169}