<commit_before># Mostly copied from:
# https://github.com/rails/rails/blob/3-2-stable/activesupport/lib/active_support/deprecation/method_wrappers.rb
def deprecate_methods(target_module, *method_names)
  options = method_names.extract_options!
  method_names += options.keys

  method_names.each do |method_name|
    target_module.alias_method_chain(method_name, :deprecation) do |target, punctuation|
      target_module.module_eval(<<-end_eval, __FILE__, __LINE__ + 1)
        def #{target}_with_deprecation#{punctuation}(*args, &block)
          ::ActiveSupport::Deprecation.warn("Prototype Usage: #{method_name}", caller)
          send(:#{target}_without_deprecation#{punctuation}, *args, &block)
        end
      end_eval
    end
  end
end

# This must be done after_initialize because
# prototype_rails has its own engine initializer
# that runs after local/app initializers.
Rails.application.config.after_initialize do
  if ENV.fetch('DEPRECATE_PROTOTYPE', true) != 'false'
    namespaces = [
      ActionView::Helpers::PrototypeHelper,
      ActionView::Helpers::ScriptaculousHelper,
      PrototypeHelper,
      ActionView::Helpers::JavaScriptHelper
    ]
    namespaces.each do |namespace|
      methods = namespace.public_instance_methods
      deprecate_methods(namespace, *methods)
    end
  end
end<commit_msg>Add another namespace to deprecate<commit_after># Mostly copied from:
# https://github.com/rails/rails/blob/3-2-stable/activesupport/lib/active_support/deprecation/method_wrappers.rb
def deprecate_methods(target_module, *method_names)
  options = method_names.extract_options!
  method_names += options.keys

  method_names.each do |method_name|
    target_module.alias_method_chain(method_name, :deprecation) do |target, punctuation|
      target_module.module_eval(<<-end_eval, __FILE__, __LINE__ + 1)
        def #{target}_with_deprecation#{punctuation}(*args, &block)
          ::ActiveSupport::Deprecation.warn("Prototype Usage: #{method_name}", caller)
          send(:#{target}_without_deprecation#{punctuation}, *args, &block)
        end
      end_eval
    end
  end
end

# This must be done after_initialize because
# prototype_rails has its own engine initializer
# that runs after local/app initializers.
Rails.application.config.after_initialize do
  if ENV.fetch('DEPRECATE_PROTOTYPE', true) != 'false'
    namespaces = [
      ActionView::Helpers::PrototypeHelper,
      ActionView::Helpers::ScriptaculousHelper,
      ActionView::Helpers::JavaScriptHelper,
      ActionView::Helpers::PrototypeHelper::JavaScriptGenerator::GeneratorMethods,
      PrototypeHelper
    ]
    namespaces.each do |namespace|
      methods = namespace.public_instance_methods
      deprecate_methods(namespace, *methods)
    end
  end
end
{'fraction_non_alphanumeric': 0.10116026105873821, 'fraction_numerical': 0.002175489485134155, 'mean_word_length': 4.607723577235772, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '1360494', 'n_tokens_mistral': 834, 'n_tokens_neox': 835, 'n_words': 158}