Class: CommandTower::ConfigureGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/command_tower/configure/configure_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_config_fileObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/generators/command_tower/configure/configure_generator.rb', line 16

def create_config_file
  relative = "config/initializers/command_tower.rb"
  path = File.join(destination_root, relative)
  if File.exist?(path) && !options[:force]
    say_status :skip, "#{relative} (already present; pass --force to overwrite)", :yellow
    return
  end

  create_file relative,
    CommandTower.config.class.composer_generate_config(wrapping: "CommandTower.configure", require_file: "command_tower")
end

#create_routeObject



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/generators/command_tower/configure/configure_generator.rb', line 28

def create_route
  return if options[:skip_routes]

  routes_path = File.join(destination_root, "config/routes.rb")
  if File.exist?(routes_path) && File.read(routes_path).include?("CommandTower::Engine")
    say_status :skip, "config/routes.rb (CommandTower::Engine already mounted)", :yellow
    return
  end

  route 'mount CommandTower::Engine => "/"'
end