<commit_before>require "rack"
require "adsf/rack"
require "logger"

module Pith

  module Server

    class << self

      def new(project)
        Rack::Builder.new do
          use Rack::CommonLogger, project.logger
          use Rack::ShowExceptions
          use Rack::Lint
          use Pith::Server::AutoBuild, project
          use Adsf::Rack::IndexFileFinder, :root => project.output_dir
          run Rack::File.new(project.output_dir)
        end
      end

      def run(project)
        app = new(project)
        Rack::Handler.get("thin").run(app, :Port => 4321)
      end

    end

    class AutoBuild

      def initialize(app, project)
        @app = app
        @project = project
      end

      def call(env)
        @project.build
        @app.call(env)
      end

    end

  end

end<commit_msg>Use defunkt's "extend self" trick.<commit_after>require "rack"
require "adsf/rack"
require "logger"

module Pith

  module Server

    def new(project)
      Rack::Builder.new do
        use Rack::CommonLogger, project.logger
        use Rack::ShowExceptions
        use Rack::Lint
        use Pith::Server::AutoBuild, project
        use Adsf::Rack::IndexFileFinder, :root => project.output_dir
        run Rack::File.new(project.output_dir)
      end
    end

    def run(project)
      app = new(project)
      Rack::Handler.get("thin").run(app, :Port => 4321)
    end

    extend self
    
    class AutoBuild

      def initialize(app, project)
        @app = app
        @project = project
      end

      def call(env)
        @project.build
        @app.call(env)
      end

    end

  end

end
{'fraction_non_alphanumeric': 0.09876543209876543, 'fraction_numerical': 0.0049382716049382715, 'mean_word_length': 2.0299065420560747, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '2312334', 'n_tokens_mistral': 526, 'n_tokens_neox': 499, 'n_words': 124}