Class: ActiveSpy::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- ActiveSpy::Generators::InstallGenerator
- Defined in:
- lib/rails/generators/active_spy/install/install_generator.rb
Overview
The generator that installs the gem
Class Method Summary collapse
-
.source_root ⇒ Object
The source for templates.
Instance Method Summary collapse
-
#create_config_file ⇒ Object
Creates a config file based in the
active_spy.yml
file. -
#inject_config_into_environment ⇒ Object
Injects the ActiveSpy initialization in the environment.
-
#mount_engine ⇒ Object
Mount Engine in the route file.
Class Method Details
.source_root ⇒ Object
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.('../templates', __FILE__) end |
Instance Method Details
#create_config_file ⇒ Object
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_environment ⇒ Object
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_engine ⇒ Object
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 |