<commit_before>module Pesuz
  module Routing
    class Router
      def draw(&block)
        instance_eval(&block)
      end

      def get(path, to:)
        path = "/#{path}" unless path[0] = "/"
        klass_and_method = controller_and_action_for(to)
        @route_data = { path: path,
                        pattern: pattern_for(path),
                        klass_and_method: klass_and_method
                      }
        endpoints[:get] << @route_data
      end

      def root(to)
        get "/", to: to
      end

      def endpoints
        @endpoints ||= Hash.new { |hash, key| hash[key] = [] }
      end

      private

      def pattern_for(path)
        placeholders = []
        path.gsub!(/(:w+)/) do |match|
          placeholders << match[1..-1].freeze
          "(?<#{placeholders.last}>[^/?#]+)"
        end
        [/^#{path}$/, placeholders]
      end

      def controller_and_action_for(path_to)
        controller_path, action = path_to.split("#")
        controller = "#{controller_path.capitalize}Controller"
        [controller, action.to_sym]
      end
    end
  end
end<commit_msg>feat(): set up routing for each verbs<commit_after>module Pesuz
  module Routing
    class Router
      def draw(&block)
        instance_eval(&block)
      end

      def get(path, to:)
        path = "/#{path}" unless path[0] = "/"
        klass_and_method = controller_and_action_for(to)
        @route_data = { path: path,
                        pattern: pattern_for(path),
                        klass_and_method: klass_and_method
                      }
        endpoints[:get] << @route_data
      end

      def post(path, to:)
        path = "/#{path}" unless path[0] = "/"
        klass_and_method = controller_and_action_for(to)
        @route_data = { path: path,
                        pattern: pattern_for(path),
                        klass_and_method: klass_and_method
                     }
        endpoints[:post] << @route_data
      end

      def put(path, to:)
        path = "/#{path}" unless path[0] = "/"
        klass_and_method = controller_and_action_for(to)
        @route_data = { path: path,
                        pattern: pattern_for(path),
                        klass_and_method: klass_and_method
                     }
        endpoints[:put] << @route_data
      end

      def patch(path, to:)
        path = "/#{path}" unless path[0] = "/"
        klass_and_method = controller_and_action_for(to)
        @route_data = { path: path,
                        pattern: pattern_for(path),
                        klass_and_method: klass_and_method
                     }
        endpoints[:patch] << @route_data
      end

      def delete(path, to:)
        path = "/#{path}" unless path[0] = "/"
        klass_and_method = controller_and_action_for(to)
        @route_data = { path: path,
                        pattern: pattern_for(path),
                        klass_and_method: klass_and_method
                     }
        endpoints[:delete] << @route_data
      end

      def root(to)
        get "/", to: to
      end

      def endpoints
        @endpoints ||= Hash.new { |hash, key| hash[key] = [] }
      end

      private

      def pattern_for(path)
        placeholders = []
        path.gsub!(/(:w+)/) do |match|
          placeholders << match[1..-1].freeze
          "(?<#{placeholders.last}>[^/?#]+)"
        end
        [/^#{path}$/, placeholders]
      end

      def controller_and_action_for(path_to)
        controller_path, action = path_to.split("#")
        controller = "#{controller_path.capitalize}Controller"
        [controller, action.to_sym]
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.11859323882224646, 'fraction_numerical': 0.0027262813522355507, 'mean_word_length': 1.6452775775054074, 'pattern_counts': {'":': 0, '<': 21, '<?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': '2983495', 'n_tokens_mistral': 1110, 'n_tokens_neox': 1083, 'n_words': 221}