Class: Spud::SetupGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/spud/setup_generator.rb

Instance Method Summary collapse

Instance Method Details

#setupObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/generators/spud/setup_generator.rb', line 5

def setup
  if ask('NOTICE: Setup will now attempt to delete and/or overwrite existing files. Continue?', :limited_to => ['y', 'n']) == 'n'
    return
  end

  template "views/layouts/application.html.erb", "app/views/layouts/application.html.erb"
  template "views/layouts/error_page.html.erb", "app/views/layouts/error_page.html.erb"

  template "application_controller.rb", "app/controllers/application_controller.rb"
  template 'assets/admin.scss', 'app/assets/stylesheets/admin/application.scss'

  remove_file 'app/assets/stylesheets/application.css'
  template 'assets/application.scss', 'app/assets/stylesheets/application.scss'
  template 'assets/application.js', 'app/assets/javascripts/application.js'
  template 'assets/admin/application.js', 'app/assets/javascripts/admin/application.js'

  if defined?(Bootstrap)
    theme_file = Bootstrap::Rails::Engine.root.join('templates', 'project', '_bootstrap-variables.sass')
    template theme_file, 'app/assets/stylesheets/imports/bootstrap_theme.scss' if File.exist?(theme_file)
    
    modules_file = Bootstrap::Rails::Engine.root.join('assets', 'stylesheets', '_bootstrap.scss')
    template modules_file, 'app/assets/stylesheets/imports/bootstrap_modules.scss' if File.exist?(modules_file)

    template 'assets/bootstrap.js', 'app/assets/javascripts/bootstrap_modules.js'
  end

  environment(spud_core_configs())
  rake('railties:install:migrations')

  if ask("Migrate the database?", :limited_to => ['y', 'n']).downcase == 'y'
    rake('db:migrate')
  end
end