Sha256: aa35615a9b724cb5f8a16bb4f2e3e7f7841f88e3b3f11027e89ca9e580479476

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

require 'speed_gun'
require 'speed_gun/store/file'

class SpeedGun::Railtie < ::Rails::Railtie
  initializer 'speed_gun' do |app|
    app.middleware.insert(0, SpeedGun::Middleware)

    SpeedGun.config[:enable_if] = -> { Rails.env.development? }
    SpeedGun.config[:backtrace_remove] = Rails.root.to_s + '/'
    SpeedGun.config[:backtrace_includes] = [/^(app|config|lib|test|spec)/]
    SpeedGun.config[:authorize_proc] = ->(request) { Rails.env.development? }
    SpeedGun.config.skip_paths << /^#{Regexp.escape(app.config.assets.prefix)}/
    SpeedGun.config[:store] =
      SpeedGun::Store::File.new(path: Rails.root.join('tmp/speed_gun'))

    ActiveSupport.on_load(:action_controller) do
      require 'speed_gun/profiler/action_controller'
    end

    ActiveSupport.on_load(:action_view) do
      require 'speed_gun/profiler/action_view'
    end

    ActiveSupport.on_load(:active_record) do
      require 'speed_gun/profiler/active_record'

      SpeedGun::Profiler::ActiveRecord.hook_method(
        ActiveRecord::Base.connection.class,
        :execute
      )
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
speed_gun-0.0.4 lib/speed_gun/railtie.rb
speed_gun-0.0.3 lib/speed_gun/railtie.rb
speed_gun-0.0.2 lib/speed_gun/railtie.rb
speed_gun-0.0.1 lib/speed_gun/railtie.rb