<commit_before>module RouteTranslator
  module Translator
    module RouteHelpers
      class << self
        private

        def add_helpers_to_test_cases(helper_container)
          %w(ActionController ActionMailer ActionView).each do |klass_name|
            next unless Module.const_defined?(klass_name)
            klass_name.constantize::TestCase.__send__(:include, helper_container)
          end
        end
      end

      module_function

      # Add standard route helpers for default locale e.g.
      #   I18n.locale = :de
      #   people_path -> people_de_path
      #   I18n.locale = :fr
      #   people_path -> people_fr_path
      def add(old_name, named_route_collection)
        if named_route_collection.respond_to?(:url_helpers_module)
          url_helpers_module = named_route_collection.url_helpers_module
          path_helpers_module = named_route_collection.path_helpers_module
          url_helpers_list = named_route_collection.helper_names
          path_helpers_list = named_route_collection.helper_names
        else
          url_helpers_module = named_route_collection.module
          path_helpers_module = named_route_collection.module
          url_helpers_list = named_route_collection.helpers
          path_helpers_list = named_route_collection.helpers
        end

        [
          ['path', path_helpers_module, path_helpers_list],
          ['url', url_helpers_module, url_helpers_list]
        ].each do |suffix, helper_container, helper_list|
          new_helper_name = "#{old_name}_#{suffix}"

          helper_list.push(new_helper_name.to_sym) unless helper_list.include?(new_helper_name.to_sym)<commit_msg>Improve Translator::RouteHelpers module<commit_after>module RouteTranslator
  module Translator
    module RouteHelpers
      class << self
        private

        def add_helpers_to_test_cases(helper_container)
          %w(ActionController ActionMailer ActionView).each do |klass_name|
            next unless Module.const_defined?(klass_name)
            klass_name.constantize::TestCase.__send__(:include, helper_container)
          end
        end
      end

      module_function

      # Add standard route helpers for default locale e.g.
      #   I18n.locale = :de
      #   people_path -> people_de_path
      #   I18n.locale = :fr
      #   people_path -> people_fr_path
      def add(old_name, named_route_collection)
        helper_list = named_route_collection.helper_names

        %w(path url).each do |suffix|
          helper_container = named_route_collection.send(:"#{suffix}_helpers_module")
          new_helper_name = "#{old_name}_#{suffix}"

          helper_list.push(new_helper_name.to_sym) unless helper_list.include?(new_helper_name.to_sym)
{'fraction_non_alphanumeric': 0.06847308678139875, 'fraction_numerical': 0.0029293299157817647, 'mean_word_length': 2.902857142857143, 'pattern_counts': {'":': 0, '<': 7, '<?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': '5893334', 'n_tokens_mistral': 788, 'n_tokens_neox': 799, 'n_words': 138}