<commit_before>require 'doorkeeper'
require 'doorkeeper-jwt'
require 'api_guardian/doorkeeper/helpers'
require 'api_guardian/doorkeeper/otp_validation'
require 'api_guardian/doorkeeper/jwt_validation'

module ApiGuardian
  Doorkeeper = ::Doorkeeper

  class Engine < ::Rails::Engine
    isolate_namespace ApiGuardian

    config.generators do |g|
      g.test_framework :rspec, fixture: false
      g.fixture_replacement :factory_girl, dir: 'spec/factories'
      g.assets false
      g.helper false
    end

    config.middleware.insert_before 0, 'Rack::Cors' do
      allow do
        origins '*'
        resource '*', headers: :any, methods: [:get, :post, :options]
      end
    end

    initializer 'api_guardian.doorkeeper_helpers' do
      ActiveSupport.on_load(:action_controller) do
        Doorkeeper::ApplicationMetalController.send(:include, AbstractController::Callbacks)
        Doorkeeper::ApplicationMetalController.send(:include, ActionController::Rescue)
        Doorkeeper::ApplicationMetalController.send(:include, ApiGuardian::DoorkeeperHelpers)
      end
    end
  end
end
<commit_msg>Fixed Rack::Cors middleware to be Rails 5 compatible<commit_after>require 'doorkeeper'
require 'doorkeeper-jwt'
require 'api_guardian/doorkeeper/helpers'
require 'api_guardian/doorkeeper/otp_validation'
require 'api_guardian/doorkeeper/jwt_validation'

module ApiGuardian
  Doorkeeper = ::Doorkeeper

  class Engine < ::Rails::Engine
    isolate_namespace ApiGuardian

    config.generators do |g|
      g.test_framework :rspec, fixture: false
      g.fixture_replacement :factory_girl, dir: 'spec/factories'
      g.assets false
      g.helper false
    end

    config.middleware.insert_before 0, Rack::Cors do
      allow do
        origins '*'
        resource '*', headers: :any, methods: [:get, :post, :put, :delete, :options]
      end
    end

    initializer 'api_guardian.doorkeeper_helpers' do
      ActiveSupport.on_load(:action_controller) do
        Doorkeeper::ApplicationMetalController.send(:include, AbstractController::Callbacks)
        Doorkeeper::ApplicationMetalController.send(:include, ActionController::Rescue)
        Doorkeeper::ApplicationMetalController.send(:include, ApiGuardian::DoorkeeperHelpers)
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.09267431597528684, 'fraction_numerical': 0.001323918799646955, 'mean_word_length': 4.1058558558558556, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1522206', 'n_tokens_mistral': 683, 'n_tokens_neox': 686, 'n_words': 141}