Sha256: 95a0e61e31b435528efb09ced852d8f864ba85ab70bbd5a4b46eb52ff07b4574

Contents?: true

Size: 1.23 KB

Versions: 15

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

module Bullet
  module Generators
    class InstallGenerator < ::Rails::Generators::Base
      desc <<~DESC
        Description:
            Enable bullet in development/test for your application.
      DESC

      def enable_in_development
        environment(nil, env: 'development') do
          <<~FILE
            config.after_initialize do
              Bullet.enable        = true
              Bullet.alert         = true
              Bullet.bullet_logger = true
              Bullet.console       = true
              Bullet.rails_logger  = true
              Bullet.add_footer    = true
            end

          FILE
        end

        say 'Enabled bullet in config/environments/development.rb'
      end

      def enable_in_test
        return unless yes?('Would you like to enable bullet in test environment? (y/n)')

        environment(nil, env: 'test') do
          <<~FILE
            config.after_initialize do
              Bullet.enable        = true
              Bullet.bullet_logger = true
              Bullet.raise         = true # raise an error if n+1 query occurs
            end

          FILE
        end

        say 'Enabled bullet in config/environments/test.rb'
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
bullet-8.0.0 lib/generators/bullet/install_generator.rb
bullet-7.2.0 lib/generators/bullet/install_generator.rb
bullet-7.1.6 lib/generators/bullet/install_generator.rb
bullet-7.1.5 lib/generators/bullet/install_generator.rb
bullet-7.1.4 lib/generators/bullet/install_generator.rb
bullet-7.1.3 lib/generators/bullet/install_generator.rb
bullet-7.1.2 lib/generators/bullet/install_generator.rb
bullet-7.1.1 lib/generators/bullet/install_generator.rb
bullet-7.1.0 lib/generators/bullet/install_generator.rb
bullet-7.0.7 lib/generators/bullet/install_generator.rb
bullet-7.0.6 lib/generators/bullet/install_generator.rb
bullet-7.0.5 lib/generators/bullet/install_generator.rb
bullet-7.0.4 lib/generators/bullet/install_generator.rb
bullet-7.0.3 lib/generators/bullet/install_generator.rb
bullet-7.0.2 lib/generators/bullet/install_generator.rb