<commit_before>module HK

  class Router

    def initialize
      @routes_by_method = {}
      @routes = []
      yield(self)
      compute
    end

    def bind(path, infos)
      route = {}
      route[:path] = path
      route = route.merge!(infos)
      @routes << route
    end

    def get_routes
      @routes
    end

    def get_routes_by_method
      @routes_by_method
    end

    def root(infos)
      raise TypeError unless infos.is_a?(Hash)
      bind("/", infos)
    end

    def match?(env)
      method = env['REQUEST_METHOD'].downcase.to_sym
      path = env['REQUEST_PATH'].eql?("/") ? "/" :
             env['REQUEST_PATH'].gsub(/\/$/, '')<commit_msg>Bug fix when unknown method passed.<commit_after>module HK

  class Router

    def initialize
      @routes_by_method = {}
      @routes = []
      yield(self)
      compute
    end

    def bind(path, infos)
      route = {}
      route[:path] = path
      route = route.merge!(infos)
      @routes << route
    end

    def get_routes
      @routes
    end

    def get_routes_by_method
      @routes_by_method
    end

    def root(infos)
      raise TypeError unless infos.is_a?(Hash)
      bind("/", infos)
    end

    def match?(env)
      method = env['REQUEST_METHOD'].downcase.to_sym
      path = env['REQUEST_PATH'].eql?("/") ? "/" :
             env['REQUEST_PATH'].gsub(/\/$/, '')
      if !@routes_by_method.has_key?(method)
        raise Exception, "Unknown route for path: #{env['REQUEST_PATH']}"
      end
{'fraction_non_alphanumeric': 0.12842809364548494, 'fraction_numerical': 0.0, 'mean_word_length': 2.090909090909091, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '2723578', 'n_tokens_mistral': 492, 'n_tokens_neox': 494, 'n_words': 107}