<commit_before>require "barrister-sinatra/version"
require 'barrister'
require 'sinatra/base'

module Barrister

  module Sinatra

    class Container

      def initialize(json_path, mount_path, handlers, port=4567, host='localhost')
        my_app = ::Sinatra.new do
          set :bind, host
          set :port, port

          contract = Barrister::contract_from_file json_path
          server   = Barrister::Server.new(contract)

          # register each provided handler
          handlers.each do |handler_klass|
            server.add_handler handler_klass.to_s, handler_klass.new
          end

          post mount_path do
            request.body.rewind
            resp = server.handle_json(request.body.read)

            status 200
            headers 'Content-Type' => 'application/json'
            resp
          end
        end

        my_app.run!
      end

    end

  end

end<commit_msg>Adding "start" method to follow barrister-redis precedence<commit_after>require "barrister-sinatra/version"
require 'barrister'
require 'sinatra/base'

module Barrister

  module Sinatra

    class Container

      def initialize(json_path, mount_path, handlers, port=4567, host='localhost')
        @my_app = ::Sinatra.new do
          set :bind, host
          set :port, port

          contract = Barrister::contract_from_file json_path
          server   = Barrister::Server.new(contract)

          # register each provided handler
          handlers.each do |handler_klass|
            server.add_handler handler_klass.to_s, handler_klass.new
          end

          post mount_path do
            request.body.rewind
            resp = server.handle_json(request.body.read)

            status 200
            headers 'Content-Type' => 'application/json'
            resp
          end
        end
      end

      def start
        @my_app.run!
      end

    end

  end

end
{'fraction_non_alphanumeric': 0.07116499736425935, 'fraction_numerical': 0.007380073800738007, 'mean_word_length': 1.970266040688576, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2098455', 'n_tokens_mistral': 552, 'n_tokens_neox': 521, 'n_words': 132}