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

module Rack
  # We register with the handler lack can load our server.
  module Handler
    # We boot the server here
    class Yars
      def self.run(app, options = {})
        environment  = ENV['RACK_ENV'] || 'development'
        default_host = environment == 'development' ? 'localhost' : '0.0.0.0'

        host = options.delete(:Host) || default_host
        port = options.delete(:Port) || 8080
        server = ::Yars::Server.new host, port, app, options

        yield server if block_given?

        server.start
      end

      def self.valid_options
        {
          'Host=HOST'       => 'Hostname to listen on (default: locahost)',
          'Port=PORT'       => 'Port to listen on (default: 8080)',
          'Concurrency=NUM' => 'Number of threads to run (default: 16)'
        }
      end
    end

    register :yars, Yars
  end
end
<commit_msg>Add ability to pass app block<commit_after>require 'rack/handler'
require 'yars'

module Rack
  # We register with the handler lack can load our server.
  module Handler
    # We boot the server here
    class Yars
      def self.run(app, options = {}, &block)
        environment  = ENV['RACK_ENV'] || 'development'
        default_host = environment == 'development' ? 'localhost' : '0.0.0.0'

        app = Rack::Builder.new(&block).to_app if block_given?

        host = options.delete(:Host) || default_host
        port = options.delete(:Port) || 8080
        server = ::Yars::Server.new host, port, app, options

        yield server if block_given?

        server.start
      end

      def self.valid_options
        {
          'Host=HOST'       => 'Hostname to listen on (default: locahost)',
          'Port=PORT'       => 'Port to listen on (default: 8080)',
          'Concurrency=NUM' => 'Number of threads to run (default: 16)'
        }
      end
    end

    register :yars, Yars
  end
end

{'fraction_non_alphanumeric': 0.11243523316062176, 'fraction_numerical': 0.014507772020725389, 'mean_word_length': 2.2784380305602716, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '3361193', 'n_tokens_mistral': 606, 'n_tokens_neox': 568, 'n_words': 180}