Class: BootupGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
HelperMethods
Defined in:
lib/generators/bootup/bootup_generator.rb

Instance Method Summary collapse

Methods included from HelperMethods

#create_mongoid, #create_postgres, #fetch_database, #first_commit, #setup_authentication, #setup_gems, #setup_testing, #setup_view_stuff

Instance Method Details

#generate_bootupObject



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
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/generators/bootup/bootup_generator.rb', line 10

def generate_bootup
  log :bootup, "Booting #{app_name}......"

  #Get database from User
  @db = fetch_database

  #Setup & bundle the Gemfile
  setup_gems

  log :bootup_log, "Removing public/index.."
  inside Rails.root do
    run "rm public/index.html"
  end

  #For postgres databases, a username password needs to be part of database.yml. This data needs to come from the user. For mongoid, the mongoid:config generator is run
  @db == 'postgres' ? create_postgres : create_mongoid

  #Run generators for all view related gems
  setup_view_stuff

  tests = ask("\n\n Would you like to get rid of the default testing framework & install Rspec with Guard?", :blue)
  if %w(y yes).include? tests
    #Setup Rspec & Guard
    setup_testing
  else
    log :bootup_log, "Skipping removal of tests"
  end

  #Git init, git add & git commit
  first_commit

  auth = ask("\n\n Would you like Bootup to create an application with basic authentication to start off with?", :blue)

  if %w(Y y Yes YES yes).include? auth
    #This sets a complete web application with authentication
    setup_authentication
  end

  say "\n Installation complete! Hope bootup helped you save some time. \n\n\n", :green
end