Sha256: c1eef467dca14457118ae39271067fba19b842c16c79d0fc25796be686f10723

Contents?: true

Size: 1.58 KB

Versions: 3

Compression:

Stored size: 1.58 KB

Contents

require 'speedup/controller_helpers'
require 'speedup/middleware'

module SpeedupRails
  class Engine < ::Rails::Engine
    isolate_namespace SpeedupRails

    engine_name :speedup

    def self.automount!(path = nil)
      engine = self
      path ||= engine.to_s.underscore.split('/').first
      Rails.application.routes.draw do
        mount engine => path
      end
    end

    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.speedup = ActiveSupport::OrderedOptions.new

    # Default adapter
    config.speedup.adapter = Rails.env.development? ? :memory : :file

    config.speedup.collectors = [:request, :queries, :partials]
    config.speedup.collectors += [:bullet] if Rails.env.development?
    config.speedup.collectors = [] if Rails.env.test?

    config.speedup.show_bar = Rails.env.development?
    config.speedup.automount = true

    initializer 'speedup.set_configs' do |app|
      ActiveSupport.on_load(:speedup) do
        app.config.speedup.each do |k,v|
          send "#{k}=", v
        end
      end
    end

    initializer 'speedup.include_controller_helpers' do
      ActiveSupport.on_load(:action_controller) do
        include Speedup::ControllerHelpers
      end

      config.to_prepare do
        Speedup.prepare_collectors if Speedup.enabled?
      end
    end

    initializer "speedup.add_middleware" do |app|
      app.middleware.insert_after 'ActionDispatch::RequestId', 'Speedup::Middleware'
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
speedup-rails-0.0.9 lib/speedup-rails/engine.rb
speedup-rails-0.0.7 lib/speedup-rails/engine.rb
speedup-rails-0.0.6 lib/speedup-rails/engine.rb