Class: ActiveSpy::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/rails/generators/active_spy/install/install_generator.rb

Overview

The generator that installs the gem

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject

The source for templates



14
15
16
# File 'lib/rails/generators/active_spy/install/install_generator.rb', line 14

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

Instance Method Details

#create_config_fileObject

Creates a config file based in the active_spy.yml file.



20
21
22
# File 'lib/rails/generators/active_spy/install/install_generator.rb', line 20

def create_config_file
  template 'active_spy.yml', File.join('config', 'active_spy.yml')
end

#inject_config_into_environmentObject

Injects the ActiveSpy initialization in the environment.



26
27
28
29
30
31
32
# File 'lib/rails/generators/active_spy/install/install_generator.rb', line 26

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_engineObject

Mount Engine in the route file.



36
37
38
# File 'lib/rails/generators/active_spy/install/install_generator.rb', line 36

def mount_engine
  route "mount ActiveSpy::Engine => 'active_spy', as: :active_spy"
end