Class: HeapPeriscopeUi::Generators::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#add_routesObject



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/generators/heap_periscope_ui/install/install_generator.rb', line 6

def add_routes
  route_info = "mount HeapPeriscopeUi::Engine => '/heap_periscope', as: 'heap_periscope_ui'"
  action_cable_route_info = "mount ActionCable.server => '/cable'"
  route_file_path = File.join(destination_root, 'config', 'routes.rb')
  
  if File.exist?(route_file_path)
    insert_into_file route_file_path, "\n  #{route_info}\n", after: "Rails.application.routes.draw do"
    insert_into_file route_file_path, "\n  #{action_cable_route_info}\n", after: "Rails.application.routes.draw do"
  else
    say "Please add the following to your config/routes.rb file:"
    say "  #{route_info}"
  end
end

#show_readmeObject



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

def show_readme
  readme "README_SETUP" if behavior == :invoke
end