Sha256: 1e7fda183a2720e05019bee1980d15221e368e8a668037cc261523ccea39bcc0

Contents?: true

Size: 1.38 KB

Versions: 2

Compression:

Stored size: 1.38 KB

Contents

require 'rails'

module Metasploit
  module Concern

    class Engine < ::Rails::Engine
      #
      # `config`
      #

      # @see http://viget.com/extend/rails-engine-testing-with-rspec-capybara-and-factorygirl
      config.generators do |g|
        g.assets false
        g.helper false
        g.test_framework :rspec, fixture: false
      end

      #
      # `initializer`s
      #

      initializer 'metasploit_concern.load_concerns' do
        application = Rails.application
        engines = application.railties.engines

        # application is an engine
        engines = [application, *engines]

        engines.each do |engine|
          concerns_path = engine.paths['app/concerns']

          if concerns_path
            if concerns_path.eager_load?
              raise Metasploit::Concern::Error::EagerLoad, engine
            end

            unless concerns_path.autoload?
              raise Metasploit::Concern::Error::SkipAutoload, engine
            end

            concerns_directories = concerns_path.existent_directories

            concerns_directories.each do |concerns_directory|
              concerns_pathname = Pathname.new(concerns_directory)
              loader = Metasploit::Concern::Loader.new(root: concerns_pathname)
              loader.register
            end
          end
        end
      end

      isolate_namespace Metasploit::Concern
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
metasploit-concern-0.4.0 lib/metasploit/concern/engine.rb
metasploit-concern-0.4.0.pre.app.pre.concerns.pre.eager.pre.load lib/metasploit/concern/engine.rb