Sha256: 673a54bdd5640374e2c1394320ede67bafdbd971cb2308afee5db6c645a18d31

Contents?: true

Size: 1.18 KB

Versions: 23

Compression:

Stored size: 1.18 KB

Contents

# encoding: utf-8

module ActiveSpy
  # Module that holds the rails generators
  #
  module Generators
    # The generator that installs the gem
    #
    class InstallGenerator < ::Rails::Generators::Base
      desc 'Creates an active_spy gem configuration file at config/active_spy.yml, and inject configurations at config/environment.rb'

      # The source for templates
      #
      def self.source_root
        @@_active_spy_source_root ||= File.expand_path('../templates', __FILE__)
      end

      # Creates a config file based in the +active_spy.yml+ file.
      #
      def create_config_file
        template 'active_spy.yml', File.join('config', 'active_spy.yml')
      end

      # Injects the {ActiveSpy} initialization in the environment.
      #
      def inject_config_into_environment
        content = File.read(File.join(@@_active_spy_source_root, 'initializer.rb'))

        File.open('config/environment.rb', 'a+') do |f|
          f << content unless f.read.include?(content)
        end
      end

      # Mount {ActiveSpy::Engine} in the route file.
      #
      def mount_engine
        route "mount ActiveSpy::Engine => 'active_spy', as: :active_spy"
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
active_spy-2.0.0.pre4 lib/rails/generators/active_spy/install/install_generator.rb
active_spy-2.0.0.pre3 lib/rails/generators/active_spy/install/install_generator.rb
active_spy-2.0.0.pre2 lib/rails/generators/active_spy/install/install_generator.rb
active_spy-2.0.0.pre1 lib/rails/generators/active_spy/install/install_generator.rb
active_spy-1.4.4 lib/rails/generators/active_spy/install/install_generator.rb
active_spy-1.4.3 lib/rails/generators/active_spy/install/install_generator.rb
active_spy-1.4.2 lib/rails/generators/active_spy/install/install_generator.rb
active_spy-1.4.1 lib/rails/generators/active_spy/install/install_generator.rb
active_spy-1.4.0 lib/rails/generators/active_spy/install/install_generator.rb
active_spy-1.3.12 lib/rails/generators/active_spy/install/install_generator.rb
active_spy-1.3.11 lib/rails/generators/active_spy/install/install_generator.rb
active_spy-1.3.10 lib/rails/generators/active_spy/install/install_generator.rb
active_spy-1.3.9 lib/rails/generators/active_spy/install/install_generator.rb
active_spy-1.3.8 lib/rails/generators/active_spy/install/install_generator.rb
active_spy-1.3.7 lib/rails/generators/active_spy/install/install_generator.rb
active_spy-1.3.6 lib/rails/generators/active_spy/install/install_generator.rb
active_spy-1.3.5 lib/rails/generators/active_spy/install/install_generator.rb
active_spy-1.3.4 lib/rails/generators/active_spy/install/install_generator.rb
active_spy-1.3.3 lib/rails/generators/active_spy/install/install_generator.rb
active_spy-1.3.2 lib/rails/generators/active_spy/install/install_generator.rb