Class: RailsAppGenerator::AddOns::Generators

Inherits:
RailsAppGenerator::Addon show all
Defined in:
lib/rails_app_generator/addons/generators.rb

Overview

Add Rails Generator configuration to rails application

Instance Attribute Summary

Attributes inherited from RailsAppGenerator::Addon

#context, #dependencies, #gem_entries

Instance Method Summary collapse

Methods inherited from RailsAppGenerator::Addon

addon_name, dependencies, depends_on, gem, gem_entries, #initialize, required_gem, reset_gem_entries

Constructor Details

This class inherits a constructor from RailsAppGenerator::Addon

Instance Method Details

#applyObject

Requires Testing (NOT SURE IF THIS IS A GOOD APPROACH, need to look at other generator systems)



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rails_app_generator/addons/generators.rb', line 9

def apply
  directory('lib/generators/rails/navigation', 'lib/generators/rails/navigation') if uses?(:views)

  template = 'lib/generators/rails/scaffold_controller_generator.rb'
  template(template) if uses?(:scaffold)

  generators = <<-RUBY
    config.generators do |generate|
  #{"require_relative '../lib/generators/rails/scaffold_controller_generator'" if uses?(:scaffold)}
  generate.helper false
  generate.javascripts false
  generate.request_specs false
  generate.routing_specs false
  generate.stylesheets false
  #{'generate.test_framework :rspec' if uses?(:rspec)}
  generate.view_specs false
  #{'generate.factory_bot true' if uses?(:factory_bot)}
    end
  RUBY
  inject_into_file 'config/application.rb', generators, before: /^ {2}end\n/
end