<commit_before>class Engine < Rails::Engine
  # Mimic old vendored plugin behavior, attachment_fu/lib is autoloaded.
  config.autoload_paths << File.expand_path("..", __FILE__)

  initializer "attachment_fu" do
    require 'geometry'

    ActiveRecord::Base.send(:extend, Technoweenie::AttachmentFu::ActMethods)
    Technoweenie::AttachmentFu.tempfile_path = ATTACHMENT_FU_TEMPFILE_PATH if Object.const_defined?(:ATTACHMENT_FU_TEMPFILE_PATH)
    FileUtils.mkdir_p Technoweenie::AttachmentFu.tempfile_path
  end
end<commit_msg>Allow use as gem on Rails 2<commit_after>
if defined?(Rails::Engine)
  # Rails >= 3
  class Engine < Rails::Engine
    # Mimic old vendored plugin behavior, attachment_fu/lib is autoloaded.
    config.autoload_paths << File.expand_path("..", __FILE__)

    initializer "attachment_fu" do
      require 'geometry'

      ActiveRecord::Base.send(:extend, Technoweenie::AttachmentFu::ActMethods)
      Technoweenie::AttachmentFu.tempfile_path = ATTACHMENT_FU_TEMPFILE_PATH if Object.const_defined?(:ATTACHMENT_FU_TEMPFILE_PATH)
      FileUtils.mkdir_p Technoweenie::AttachmentFu.tempfile_path
    end
  end
else
  # Rails <= 2
  require 'geometry'

  ActiveRecord::Base.send(:extend, Technoweenie::AttachmentFu::ActMethods)
  Technoweenie::AttachmentFu.tempfile_path = ATTACHMENT_FU_TEMPFILE_PATH if Object.const_defined?(:ATTACHMENT_FU_TEMPFILE_PATH)
  FileUtils.mkdir_p Technoweenie::AttachmentFu.tempfile_path

  $:.unshift(File.expand_path("../vendor", __FILE__))
end
{'fraction_non_alphanumeric': 0.0997322623828648, 'fraction_numerical': 0.002008032128514056, 'mean_word_length': 5.889400921658986, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 4, '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': '3283500', 'n_tokens_mistral': 513, 'n_tokens_neox': 490, 'n_words': 84}