<commit_before>require "rails"

require "zooplankton/version"

module Zooplankton
  class << self
    def path_template_for(helper_name, query_params={}, supplied_params=nil)
      build_template(:path, helper_name, *parse_params(query_params, supplied_params))
    end

    def url_template_for(helper_name, query_params={}, supplied_params=nil)
      build_template(:url, helper_name, *parse_params(query_params, supplied_params))
    end

    private

    def parse_params(*args)
      if args.first.respond_to?(:to_h)
        query_params = []
        supplied_params = args.first.to_h
      else
        query_params = Array(args.shift)
        supplied_params = args.first || {}
      end

      [query_params, supplied_params]
    end

    def build_template(type, helper_name, query_params, supplied_params)
      return unless named_routes.names.include?(helper_name)<commit_msg>don't try to convert params to a hash if it's an array<commit_after>require "rails"

require "zooplankton/version"

module Zooplankton
  class << self
    def path_template_for(helper_name, query_params={}, supplied_params=nil)
      build_template(:path, helper_name, *parse_params(query_params, supplied_params))
    end

    def url_template_for(helper_name, query_params={}, supplied_params=nil)
      build_template(:url, helper_name, *parse_params(query_params, supplied_params))
    end

    private

    def parse_params(*args)
      if args.first.respond_to?(:to_h) && !args.first.is_a?(Array)
        query_params = []
        supplied_params = args.first.to_h
      else
        query_params = Array(args.shift)
        supplied_params = args.first || {}
      end

      [query_params, supplied_params]
    end

    def build_template(type, helper_name, query_params, supplied_params)
      return unless named_routes.names.include?(helper_name)
{'fraction_non_alphanumeric': 0.0943089430894309, 'fraction_numerical': 0.0, 'mean_word_length': 3.857894736842105, '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': '6049947', 'n_tokens_mistral': 576, 'n_tokens_neox': 563, 'n_words': 113}