<commit_before>require 'hocus_pocus/engine'
require 'hocus_pocus/filter'

module HocusPocus
  VIEW_FILENAMES = :__hocus_pocus_view_filenames__
  EDITOR = :__hocus_pocus_editor__
  GENERATOR = :__hocus_pocus_generator__
  SPEC = :__hocus_pocus_spec__
end

if Rails.env.development?
  ActiveSupport.on_load(:after_initialize) do
    Rails.application.routes.append do
      mount HocusPocus::Engine, :at => '/'
    end
  end

  class ::ActionController::Base
    before_filter HocusPocus::Filter
    after_filter HocusPocus::Filter
  end

  class ::ActionView::Base
    def method_missing(method, args = {}, &blk)
      if method.to_s =~ /(new_|edit_)?(.*)(_path|_url)\z/
        # to avoid DoubleRenderError
        controller.instance_variable_set :@_response_body, nil
        #FIXME preserve args
        controller.redirect_to "/#{$2.pluralize}?return_path=#{method}(#{args})"
      else
        super
      end
    end
  end

  class ::ActionView::PartialRenderer
    def render_partial_with_filename_caching
      (Thread.current[HocusPocus::VIEW_FILENAMES] ||= []) << @template unless @view.controller.is_a?(HocusPocus::EditorController)
      render_partial_without_filename_caching
    end
    alias_method_chain :render_partial, :filename_caching
  end
end
<commit_msg>load nothing for non-development env<commit_after>if Rails.env.development?
  require 'hocus_pocus/engine'
  require 'hocus_pocus/filter'

  module HocusPocus
    VIEW_FILENAMES = :__hocus_pocus_view_filenames__
    EDITOR = :__hocus_pocus_editor__
    GENERATOR = :__hocus_pocus_generator__
    SPEC = :__hocus_pocus_spec__
  end

  ActiveSupport.on_load(:after_initialize) do
    Rails.application.routes.append do
      mount HocusPocus::Engine, :at => '/'
    end
  end

  class ::ActionController::Base
    before_filter HocusPocus::Filter
    after_filter HocusPocus::Filter
  end

  class ::ActionView::Base
    def method_missing(method, args = {}, &blk)
      if method.to_s =~ /(new_|edit_)?(.*)(_path|_url)\z/
        # to avoid DoubleRenderError
        controller.instance_variable_set :@_response_body, nil
        #FIXME preserve args
        controller.redirect_to "/#{$2.pluralize}?return_path=#{method}(#{args})"
      else
        super
      end
    end
  end

  class ::ActionView::PartialRenderer
    def render_partial_with_filename_caching
      (Thread.current[HocusPocus::VIEW_FILENAMES] ||= []) << @template unless @view.controller.is_a?(HocusPocus::EditorController)
      render_partial_without_filename_caching
    end
    alias_method_chain :render_partial, :filename_caching
  end
end

{'fraction_non_alphanumeric': 0.09903660886319846, 'fraction_numerical': 0.0007707129094412332, 'mean_word_length': 4.011583011583012, 'pattern_counts': {'":': 0, '<': 7, '<?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': '6674132', 'n_tokens_mistral': 876, 'n_tokens_neox': 852, 'n_words': 150}