Class: ThreddedCreateApp::Tasks::CreateRailsApp
- Defined in:
- lib/thredded_create_app/tasks/create_rails_app.rb
Instance Attribute Summary
Attributes inherited from Base
#app_hostname, #app_name, #app_path, #gems
Instance Method Summary collapse
- #after_bundle ⇒ Object
-
#before_bundle ⇒ Object
rubocop:disable Metrics/AbcSize.
-
#initialize(install_gem_bundler_rails:, rails_version:, database:, **args) ⇒ CreateRailsApp
constructor
A new instance of CreateRailsApp.
- #summary ⇒ Object
Methods inherited from Base
#devise_form_fields_begin_pattern, #webpack_js?
Methods included from RunCommand
Methods included from Logging
#log_command, #log_error, #log_info, #log_stderr, #log_verbose, #log_warn, #program_name
Constructor Details
#initialize(install_gem_bundler_rails:, rails_version:, database:, **args) ⇒ CreateRailsApp
Returns a new instance of CreateRailsApp.
10 11 12 13 14 15 16 17 |
# File 'lib/thredded_create_app/tasks/create_rails_app.rb', line 10 def initialize(install_gem_bundler_rails:, rails_version:, database:, **args) super @install_gem_bundler_rails = install_gem_bundler_rails @database = database @rails_version = rails_version @user_install = !File.writable?(Gem.dir) end |
Instance Method Details
#after_bundle ⇒ Object
46 47 48 49 50 51 |
# File 'lib/thredded_create_app/tasks/create_rails_app.rb', line 46 def after_bundle run_generator 'rspec:install' git_commit 'rails g rspec:install' webpacker_install if webpack_js? end |
#before_bundle ⇒ Object
rubocop:disable Metrics/AbcSize
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/thredded_create_app/tasks/create_rails_app.rb', line 24 def before_bundle # rubocop:disable Metrics/AbcSize if @install_gem_bundler_rails run 'gem update --system --no-document --quiet' unless @user_install install_gem 'bundler' install_gem 'rails', version: @rails_version end @rails_version ||= Bundler.with_original_env { latest_installed_rails_version } run "rails _#{@rails_version}_ new . --skip-bundle" \ " --database=#{rails_database}" \ ' --skip-webpack-install' \ "#{' --skip-javascript' unless webpack_js?}" \ ' --skip-test' \ "#{verbose? ? ' --verbose' : ' --quiet'}" run 'rm', 'Gemfile.lock' if File.exist?('Gemfile.lock') replace 'Gemfile', /gem 'sass-rails'.*$/, "gem 'sassc-rails'" add_gem 'rspec-rails', version: '>= 4.0.0.beta3', groups: %i[test] add_gem 'capybara', groups: %i[test] git_commit summary end |
#summary ⇒ Object
19 20 21 22 |
# File 'lib/thredded_create_app/tasks/create_rails_app.rb', line 19 def summary "Create a Rails v#{@rails_version} app #{app_name.inspect} with"\ " #{rails_database} and rspec" end |