Class: QaServer::Install

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

Instance Method Summary collapse

Instance Method Details



13
14
15
# File 'lib/generators/qa_server/install_generator.rb', line 13

def banner
  say_status('info', 'INSTALLING QA_SERVER', :blue)
end

#create_location_for_chartsObject



51
52
53
54
# File 'lib/generators/qa_server/install_generator.rb', line 51

def create_location_for_charts
  say_status('info', '  -- creating directory to hold dynamically generated charts', :blue)
  copy_file 'app/assets/images/qa_server/charts/.keep'
end

#inject_bootstrapObject



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/generators/qa_server/install_generator.rb', line 38

def inject_bootstrap
  say_status('info', '  -- adding bootstrap resources', :blue)

  inject_into_file 'app/views/layouts/application.html.erb', after: /<head>\n/ do
    "    <!-- Latest compiled and minified CSS -->\n"\
    "    <link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css'>\n"\
    "    <!-- jQuery library -->\n"\
    "    <script src='https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js'></script>\n"\
    "    <!-- Latest compiled JavaScript -->\n"\
    "    <script src='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js'></script>\n"
  end
end

#inject_routesObject

The engine routes have to come after the devise routes so that /users/sign_in will work



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/generators/qa_server/install_generator.rb', line 24

def inject_routes
  say_status('info', '  -- adding qa_server routes', :blue)

  # # Remove root route that was added by blacklight generator
  # gsub_file 'config/routes.rb', /root (:to =>|to:) "catalog#index"/, ''

  inject_into_file 'config/routes.rb', after: /Rails.application.routes.draw do\n/ do
    "  mount Qa::Engine => '/authorities'\n"\
    "  mount QaServer::Engine, at: '/'\n"\
    "  resources :welcome, only: 'index'\n"\
    "  root 'qa_server/homepage#index'\n"
  end
end

#run_required_generatorsObject



17
18
19
20
21
# File 'lib/generators/qa_server/install_generator.rb', line 17

def run_required_generators
  generate "qa_server:assets"
  generate "qa_server:config"
  generate "qa_server:models#{options[:force] ? ' -f' : ''}"
end