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

#add_to_gemfile ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/generators/qa_server/install_generator.rb', line 23

def add_to_gemfile
  say_status('info', '  -- adding qa_server required gems', :blue)
  gem 'qa', github: 'samvera/questioning_authority', branch: 'min_context'
  gem 'linkeddata'

  Bundler.with_clean_env do
    run "bundle install"
  end
end


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

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

#inject_bootstrap ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/generators/qa_server/install_generator.rb', line 48

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_routes ⇒ Object

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



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/generators/qa_server/install_generator.rb', line 34

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_generators ⇒ Object



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