Class: Virgo::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#app_has_engine_route?Boolean

Returns:

  • (Boolean)


15
16
17
18
# File 'lib/generators/virgo/install/install_generator.rb', line 15

def app_has_engine_route?
  route_contents = File.read("#{Rails.root}/config/routes.rb")
  route_contents.include?("Virgo::Engine")
end

#run_installObject



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/generators/virgo/install/install_generator.rb', line 3

def run_install
  unless app_has_engine_route?
    in_root do
      inject_into_file 'config/routes.rb',"\n  mount Virgo::Engine => \"/\"\n", { before: /^end/, verbose: false, force: true }
    end
  end

  generate "virgo:views"
  generate "virgo:migrations"
  generate "virgo:schedule"
end