Class: Suspenders::AppBuilder
- Inherits:
-
Rails::AppBuilder
- Object
- Rails::AppBuilder
- Suspenders::AppBuilder
- Includes:
- Actions
- Defined in:
- lib/suspenders/app_builder.rb
Instance Method Summary collapse
- #add_helpers_for_rspec ⇒ Object
- #configure_action_mailer ⇒ Object
- #configure_action_mailer_in_specs ⇒ Object
- #configure_active_job ⇒ Object
- #configure_automatic_deployment ⇒ Object
- #configure_available_locales ⇒ Object
- #configure_background_jobs_for_rspec ⇒ Object
- #configure_bullet ⇒ Object
- #configure_capybara_webkit ⇒ Object
- #configure_ci ⇒ Object
- #configure_generators ⇒ Object
- #configure_i18n_for_missing_translations ⇒ Object
- #configure_i18n_for_test_environment ⇒ Object
- #configure_i18n_tasks ⇒ Object
- #configure_letter_opener ⇒ Object
- #configure_locales ⇒ Object
- #configure_puma ⇒ Object
- #configure_quiet_assets ⇒ Object
- #configure_rack_timeout ⇒ Object
- #configure_rspec ⇒ Object
- #configure_simple_form ⇒ Object
- #configure_slim ⇒ Object
- #configure_smtp ⇒ Object
- #configure_spec_support_features ⇒ Object
- #configure_time_formats ⇒ Object
- #copy_dotfiles ⇒ Object
- #copy_miscellaneous_files ⇒ Object
- #create_application_layout ⇒ Object
- #create_binstubs ⇒ Object
- #create_database ⇒ Object
- #create_github_repo(repo_name) ⇒ Object
- #create_heroku_apps(flags) ⇒ Object
- #create_partials_directory ⇒ Object
- #create_production_heroku_app(flags) ⇒ Object
- #create_ruby_gemset_file ⇒ Object
- #create_shared_flashes ⇒ Object
- #create_shared_javascripts ⇒ Object
- #create_staging_heroku_app(flags) ⇒ Object
- #customize_error_pages ⇒ Object
- #disable_xml_params ⇒ Object
- #disallow_wrapping_parameters ⇒ Object
- #enable_database_cleaner ⇒ Object
- #enable_rack_canonical_host ⇒ Object
- #enable_rack_deflater ⇒ Object
- #fix_i18n_deprecation_warning ⇒ Object
- #generate_rspec ⇒ Object
- #gitignore_files ⇒ Object
- #init_git ⇒ Object
- #install_bitters ⇒ Object
- #install_refills ⇒ Object
- #join_heroku_app(environment) ⇒ Object
- #provide_deploy_script ⇒ Object
- #provide_dev_prime_task ⇒ Object
- #provide_setup_script ⇒ Object
- #provide_shoulda_matchers_config ⇒ Object
- #raise_on_delivery_errors ⇒ Object
- #raise_on_unpermitted_parameters ⇒ Object
- #readme ⇒ Object
- #remove_config_comment_lines ⇒ Object
- #remove_routes_comment_lines ⇒ Object
- #replace_gemfile ⇒ Object
- #set_heroku_rails_secrets ⇒ Object
- #set_heroku_remotes ⇒ Object
- #set_heroku_serve_static_files ⇒ Object
- #set_ruby_to_version_being_used ⇒ Object
- #set_up_factory_girl_for_rspec ⇒ Object
- #set_up_faker ⇒ Object
- #setup_asset_host ⇒ Object
- #setup_brakeman ⇒ Object
- #setup_bundler_audit ⇒ Object
- #setup_default_rake_task ⇒ Object
- #setup_foreman ⇒ Object
- #setup_heroku_specific_gems ⇒ Object
- #setup_rubocop ⇒ Object
- #setup_secret_token ⇒ Object
- #setup_spring ⇒ Object
- #setup_staging_environment ⇒ Object
- #setup_stylesheets ⇒ Object
- #use_postgres_config_template ⇒ Object
Methods included from Actions
#action_mailer_host, #configure_application_file, #configure_environment, #replace_in_file
Instance Method Details
#add_helpers_for_rspec ⇒ Object
82 83 84 85 |
# File 'lib/suspenders/app_builder.rb', line 82 def add_helpers_for_rspec copy_file 'queries_helper_rspec.rb', 'spec/support/queries_helper.rb' copy_file 'fixtures_helper_rspec.rb', 'spec/support/fixtures_helper.rb' end |
#configure_action_mailer ⇒ Object
307 308 309 310 311 |
# File 'lib/suspenders/app_builder.rb', line 307 def configure_action_mailer action_mailer_host "development", %{"localhost:3000"} action_mailer_host "test", %{"www.example.com"} action_mailer_host "production", %{ENV.fetch("APPLICATION_HOST")} end |
#configure_action_mailer_in_specs ⇒ Object
268 269 270 |
# File 'lib/suspenders/app_builder.rb', line 268 def configure_action_mailer_in_specs copy_file 'action_mailer.rb', 'spec/support/action_mailer.rb' end |
#configure_active_job ⇒ Object
321 322 323 324 325 326 |
# File 'lib/suspenders/app_builder.rb', line 321 def configure_active_job configure_application_file( "config.active_job.queue_adapter = :delayed_job" ) configure_environment "test", "config.active_job.queue_adapter = :inline" end |
#configure_automatic_deployment ⇒ Object
471 472 473 474 475 476 477 478 479 480 481 482 483 |
# File 'lib/suspenders/app_builder.rb', line 471 def configure_automatic_deployment staging_remote_name = heroku_app_name_for("staging") deploy_command = " deployment:\n staging:\n branch: master\n commands:\n - git remote add staging [email protected]:\#{staging_remote_name}.git\n - bin/deploy staging\n YML\n\n append_file \"circle.yml\", deploy_command\nend\n".strip_heredoc |
#configure_available_locales ⇒ Object
313 314 315 316 317 318 319 |
# File 'lib/suspenders/app_builder.rb', line 313 def configure_available_locales config = "config.i18n.available_locales = [:en, :it]\n RUBY\n\n inject_into_class 'config/application.rb', 'Application', config\nend\n" |
#configure_background_jobs_for_rspec ⇒ Object
264 265 266 |
# File 'lib/suspenders/app_builder.rb', line 264 def configure_background_jobs_for_rspec run 'rails g delayed_job:active_record' end |
#configure_bullet ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/suspenders/app_builder.rb', line 22 def configure_bullet config = " config.after_initialize do\n Bullet.enable = true\n Bullet.bullet_logger = true\n Bullet.console = true\n Bullet.rails_logger = true\n # Bullet.stacktrace_includes = [ 'your_gem', 'your_middleware' ]\n end\n RUBY\n configure_environment \"development\", config\nend\n".strip_heredoc |
#configure_capybara_webkit ⇒ Object
272 273 274 |
# File 'lib/suspenders/app_builder.rb', line 272 def copy_file "capybara_webkit.rb", "spec/support/capybara_webkit.rb" end |
#configure_ci ⇒ Object
246 247 248 |
# File 'lib/suspenders/app_builder.rb', line 246 def configure_ci template "circle.yml.erb", "circle.yml" end |
#configure_generators ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/suspenders/app_builder.rb', line 60 def configure_generators config = "\nconfig.generators do |generate|\n generate.helper false\n generate.javascript_engine false\n generate.request_specs false\n generate.routing_specs false\n generate.stylesheets false\n generate.test_framework :rspec\n generate.view_specs false\nend\n\n RUBY\n\n inject_into_class 'config/application.rb', 'Application', config\nend\n" |
#configure_i18n_for_missing_translations ⇒ Object
254 255 256 257 |
# File 'lib/suspenders/app_builder.rb', line 254 def configure_i18n_for_missing_translations raise_on_missing_translations_in("development") raise_on_missing_translations_in("test") end |
#configure_i18n_for_test_environment ⇒ Object
250 251 252 |
# File 'lib/suspenders/app_builder.rb', line 250 def configure_i18n_for_test_environment copy_file "i18n.rb", "spec/support/i18n.rb" end |
#configure_i18n_tasks ⇒ Object
259 260 261 262 |
# File 'lib/suspenders/app_builder.rb', line 259 def configure_i18n_tasks run "cp $(i18n-tasks gem-path)/templates/rspec/i18n_spec.rb spec/" copy_file "config_i18n_tasks.yml", "config/i18n-tasks.yml" end |
#configure_letter_opener ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/suspenders/app_builder.rb', line 14 def configure_letter_opener inject_into_file( "config/environments/development.rb", "\n config.action_mailer.delivery_method = :letter_opener", after: "config.action_mailer.raise_delivery_errors = true", ) end |
#configure_locales ⇒ Object
276 277 278 279 |
# File 'lib/suspenders/app_builder.rb', line 276 def configure_locales remove_file "config/locales/en.yml" template "config_locales_it.yml.erb", "config/locales/it.yml" end |
#configure_puma ⇒ Object
340 341 342 |
# File 'lib/suspenders/app_builder.rb', line 340 def configure_puma copy_file "puma.rb", "config/puma.rb" end |
#configure_quiet_assets ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/suspenders/app_builder.rb', line 43 def configure_quiet_assets config = "config.quiet_assets = true\n RUBY\n\n inject_into_class \"config/application.rb\", \"Application\", config\nend\n" |
#configure_rack_timeout ⇒ Object
291 292 293 294 295 296 297 |
# File 'lib/suspenders/app_builder.rb', line 291 def configure_rack_timeout rack_timeout_config = "Rack::Timeout.timeout = (ENV[\"RACK_TIMEOUT\"] || 10).to_i\n RUBY\n\n append_file \"config/environments/production.rb\", rack_timeout_config\nend\n" |
#configure_rspec ⇒ Object
239 240 241 242 243 244 |
# File 'lib/suspenders/app_builder.rb', line 239 def configure_rspec remove_file "spec/rails_helper.rb" remove_file "spec/spec_helper.rb" copy_file "rails_helper.rb", "spec/rails_helper.rb" copy_file "spec_helper.rb", "spec/spec_helper.rb" end |
#configure_simple_form ⇒ Object
303 304 305 |
# File 'lib/suspenders/app_builder.rb', line 303 def configure_simple_form bundle_command "exec rails generate simple_form:install" end |
#configure_slim ⇒ Object
299 300 301 |
# File 'lib/suspenders/app_builder.rb', line 299 def configure_slim copy_file 'slim.rb', 'config/initializers/slim.rb' end |
#configure_smtp ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/suspenders/app_builder.rb', line 91 def configure_smtp copy_file 'smtp.rb', 'config/smtp.rb' prepend_file 'config/environments/production.rb', %{require Rails.root.join("config/smtp")\n} config = "\n config.action_mailer.delivery_method = :smtp\n config.action_mailer.smtp_settings = SMTP_SETTINGS\n RUBY\n\n inject_into_file 'config/environments/production.rb', config,\n after: \"config.action_mailer.raise_delivery_errors = false\"\nend\n" |
#configure_spec_support_features ⇒ Object
234 235 236 237 |
# File 'lib/suspenders/app_builder.rb', line 234 def configure_spec_support_features empty_directory_with_keep_file 'spec/features' empty_directory_with_keep_file 'spec/support/features' end |
#configure_time_formats ⇒ Object
281 282 283 284 285 286 287 288 289 |
# File 'lib/suspenders/app_builder.rb', line 281 def configure_time_formats replace_in_file "config/application.rb", "# config.time_zone = 'Central Time (US & Canada)'", "config.time_zone = 'Rome'" replace_in_file "config/application.rb", "# config.i18n.default_locale = :de", "config.i18n.default_locale = :it" end |
#copy_dotfiles ⇒ Object
391 392 393 |
# File 'lib/suspenders/app_builder.rb', line 391 def copy_dotfiles directory("dotfiles", ".") end |
#copy_miscellaneous_files ⇒ Object
512 513 514 515 516 |
# File 'lib/suspenders/app_builder.rb', line 512 def copy_miscellaneous_files copy_file "browserslist", "browserslist" copy_file "errors.rb", "config/initializers/errors.rb" copy_file "json_encoding.rb", "config/initializers/json_encoding.rb" end |
#create_application_layout ⇒ Object
186 187 188 189 190 191 |
# File 'lib/suspenders/app_builder.rb', line 186 def create_application_layout remove_file 'app/views/layouts/application.html.erb' template 'suspenders_layout.html.slim', 'app/views/layouts/application.html.slim', force: true end |
#create_binstubs ⇒ Object
507 508 509 510 |
# File 'lib/suspenders/app_builder.rb', line 507 def create_binstubs bundle_command "binstubs brakeman" bundle_command "binstubs rubocop" end |
#create_database ⇒ Object
198 199 200 |
# File 'lib/suspenders/app_builder.rb', line 198 def create_database bundle_command 'exec rake db:create db:migrate' end |
#create_github_repo(repo_name) ⇒ Object
485 486 487 488 |
# File 'lib/suspenders/app_builder.rb', line 485 def create_github_repo(repo_name) path_addition = override_path_for_tests run "#{path_addition} hub create #{repo_name}" end |
#create_heroku_apps(flags) ⇒ Object
413 414 415 416 |
# File 'lib/suspenders/app_builder.rb', line 413 def create_heroku_apps(flags) create_staging_heroku_app(flags) create_production_heroku_app(flags) end |
#create_partials_directory ⇒ Object
173 174 175 |
# File 'lib/suspenders/app_builder.rb', line 173 def create_partials_directory empty_directory 'app/views/application' end |
#create_production_heroku_app(flags) ⇒ Object
407 408 409 410 411 |
# File 'lib/suspenders/app_builder.rb', line 407 def create_production_heroku_app(flags) app_name = heroku_app_name_for("production") run_heroku "create #{app_name} #{flags}", "production" end |
#create_ruby_gemset_file ⇒ Object
211 212 213 |
# File 'lib/suspenders/app_builder.rb', line 211 def create_ruby_gemset_file create_file '.ruby-gemset', "#{app_name}\n" end |
#create_shared_flashes ⇒ Object
177 178 179 180 |
# File 'lib/suspenders/app_builder.rb', line 177 def create_shared_flashes copy_file '_flashes.html.slim', 'app/views/application/_flashes.html.slim' copy_file "flashes_helper.rb", "app/helpers/flashes_helper.rb" end |
#create_shared_javascripts ⇒ Object
182 183 184 |
# File 'lib/suspenders/app_builder.rb', line 182 def create_shared_javascripts copy_file '_javascript.html.slim', 'app/views/application/_javascript.html.slim' end |
#create_staging_heroku_app(flags) ⇒ Object
399 400 401 402 403 404 405 |
# File 'lib/suspenders/app_builder.rb', line 399 def create_staging_heroku_app(flags) rack_env = "RACK_ENV=staging RAILS_ENV=staging" app_name = heroku_app_name_for("staging") run_heroku "create #{app_name} #{flags}", "staging" run_heroku "config:add #{rack_env}", "staging" end |
#customize_error_pages ⇒ Object
518 519 520 521 522 523 524 525 526 527 528 529 |
# File 'lib/suspenders/app_builder.rb', line 518 def customize_error_pages =" <meta charset=\"utf-8\" />\n <meta name=\"ROBOTS\" content=\"NOODP\" />\n <meta name=\"viewport\" content=\"initial-scale=1\" />\n EOS\n\n %w(500 404 422).each do |page|\n inject_into_file \"public/\#{page}.html\", meta_tags, after: \"<head>\\n\"\n replace_in_file \"public/\#{page}.html\", /<!--.+-->\\n/, ''\n end\nend\n" |
#disable_xml_params ⇒ Object
559 560 561 |
# File 'lib/suspenders/app_builder.rb', line 559 def disable_xml_params copy_file 'disable_xml_params.rb', 'config/initializers/disable_xml_params.rb' end |
#disallow_wrapping_parameters ⇒ Object
169 170 171 |
# File 'lib/suspenders/app_builder.rb', line 169 def disallow_wrapping_parameters remove_file "config/initializers/wrap_parameters.rb" end |
#enable_database_cleaner ⇒ Object
223 224 225 |
# File 'lib/suspenders/app_builder.rb', line 223 def enable_database_cleaner copy_file 'database_cleaner_rspec.rb', 'spec/support/database_cleaner.rb' end |
#enable_rack_canonical_host ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/suspenders/app_builder.rb', line 107 def enable_rack_canonical_host config = "\n # Ensure requests are only served from one, canonical host name\n config.middleware.use Rack::CanonicalHost, ENV.fetch(\"APPLICATION_HOST\")\n RUBY\n\n inject_into_file(\n \"config/environments/production.rb\",\n config,\n after: serve_static_files_line\n )\nend\n" |
#enable_rack_deflater ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/suspenders/app_builder.rb', line 121 def enable_rack_deflater config = "\n # Enable deflate / gzip compression of controller-generated responses\n config.middleware.use Rack::Deflater\n RUBY\n\n inject_into_file(\n \"config/environments/production.rb\",\n config,\n after: serve_static_files_line\n )\nend\n" |
#fix_i18n_deprecation_warning ⇒ Object
328 329 330 331 332 333 334 |
# File 'lib/suspenders/app_builder.rb', line 328 def fix_i18n_deprecation_warning config = "config.i18n.enforce_available_locales = true\n RUBY\n\n inject_into_class 'config/application.rb', 'Application', config\nend\n" |
#generate_rspec ⇒ Object
336 337 338 |
# File 'lib/suspenders/app_builder.rb', line 336 def generate_rspec generate 'rspec:install' end |
#gitignore_files ⇒ Object
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 |
# File 'lib/suspenders/app_builder.rb', line 365 def gitignore_files remove_file '.gitignore' copy_file 'suspenders_gitignore', '.gitignore' [ 'app/forms', 'app/decorators', 'app/queries', 'app/services', 'app/views/pages', 'spec/controllers', 'spec/forms', 'spec/helpers', 'spec/lib', 'spec/decorators', 'spec/queries', 'spec/services', 'spec/fixtures', 'spec/support/matchers', 'spec/support/mixins', 'spec/support/shared_examples' ].each do |dir| run "mkdir #{dir}" run "touch #{dir}/.keep" end end |
#init_git ⇒ Object
395 396 397 |
# File 'lib/suspenders/app_builder.rb', line 395 def init_git run 'git init' end |
#install_bitters ⇒ Object
361 362 363 |
# File 'lib/suspenders/app_builder.rb', line 361 def install_bitters run "bitters install --path app/assets/stylesheets" end |
#install_refills ⇒ Object
355 356 357 358 359 |
# File 'lib/suspenders/app_builder.rb', line 355 def install_refills run "rails generate refills:import flashes" run "rm app/views/refills/_flashes.html.erb" run "rmdir app/views/refills" end |
#join_heroku_app(environment) ⇒ Object
429 430 431 432 433 434 435 436 437 438 439 |
# File 'lib/suspenders/app_builder.rb', line 429 def join_heroku_app(environment) heroku_app_name = heroku_app_name_for(environment) "if heroku join --app \#{heroku_app_name} &> /dev/null; then\n git remote add \#{environment} [email protected]:\#{heroku_app_name}.git || true\n printf 'You are a collaborator on the \"\#{heroku_app_name}\" Heroku app\\n'\nelse\n printf 'Ask for access to the \"\#{heroku_app_name}\" Heroku app\\n'\nfi\n SHELL\nend\n" |
#provide_deploy_script ⇒ Object
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 |
# File 'lib/suspenders/app_builder.rb', line 453 def provide_deploy_script copy_file "bin_deploy", "bin/deploy" instructions = "\n## Deploying\n\nIf you have previously run the `./bin/setup` script,\nyou can deploy to staging and production with:\n\n$ ./bin/deploy staging\n$ ./bin/deploy production\n MARKDOWN\n\n append_file \"README.md\", instructions\n run \"chmod a+x bin/deploy\"\nend\n" |
#provide_dev_prime_task ⇒ Object
56 57 58 |
# File 'lib/suspenders/app_builder.rb', line 56 def provide_dev_prime_task copy_file 'dev.rake', 'lib/tasks/dev.rake' end |
#provide_setup_script ⇒ Object
51 52 53 54 |
# File 'lib/suspenders/app_builder.rb', line 51 def provide_setup_script template "bin_setup.erb", "bin/setup", force: true run "chmod a+x bin/setup" end |
#provide_shoulda_matchers_config ⇒ Object
227 228 229 230 231 232 |
# File 'lib/suspenders/app_builder.rb', line 227 def provide_shoulda_matchers_config copy_file( "shoulda_matchers_config_rspec.rb", "spec/support/shoulda_matchers.rb" ) end |
#raise_on_delivery_errors ⇒ Object
9 10 11 12 |
# File 'lib/suspenders/app_builder.rb', line 9 def raise_on_delivery_errors replace_in_file 'config/environments/development.rb', 'raise_delivery_errors = false', 'raise_delivery_errors = true' end |
#raise_on_unpermitted_parameters ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/suspenders/app_builder.rb', line 35 def raise_on_unpermitted_parameters config = "config.action_controller.action_on_unpermitted_parameters = :raise\n RUBY\n\n inject_into_class \"config/application.rb\", \"Application\", config\nend\n" |
#readme ⇒ Object
5 6 7 |
# File 'lib/suspenders/app_builder.rb', line 5 def readme template 'README.md.erb', 'README.md' end |
#remove_config_comment_lines ⇒ Object
531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 |
# File 'lib/suspenders/app_builder.rb', line 531 def remove_config_comment_lines config_files = [ "application.rb", "environment.rb", "environments/development.rb", "environments/production.rb", "environments/test.rb", ] config_files.each do |config_file| path = File.join(destination_root, "config/#{config_file}") accepted_content = File.readlines(path).reject do |line| line =~ /^.*#.*$/ || line =~ /^$\n/ end File.open(path, "w") do |file| accepted_content.each { |line| file.puts line } end end end |
#remove_routes_comment_lines ⇒ Object
553 554 555 556 557 |
# File 'lib/suspenders/app_builder.rb', line 553 def remove_routes_comment_lines replace_in_file 'config/routes.rb', /Rails\.application\.routes\.draw do.*end/m, "Rails.application.routes.draw do\nend" end |
#replace_gemfile ⇒ Object
202 203 204 205 |
# File 'lib/suspenders/app_builder.rb', line 202 def replace_gemfile remove_file 'Gemfile' template 'Gemfile.erb', 'Gemfile' end |
#set_heroku_rails_secrets ⇒ Object
441 442 443 444 445 |
# File 'lib/suspenders/app_builder.rb', line 441 def set_heroku_rails_secrets %w(staging production).each do |environment| run_heroku "config:add SECRET_KEY_BASE=#{generate_secret}", environment end end |
#set_heroku_remotes ⇒ Object
418 419 420 421 422 423 424 425 426 427 |
# File 'lib/suspenders/app_builder.rb', line 418 def set_heroku_remotes remotes = "\n# Set up the staging and production apps.\n\#{join_heroku_app('staging')}\n\#{join_heroku_app('production')}\n SHELL\n\n append_file 'bin/setup', remotes\nend\n" |
#set_heroku_serve_static_files ⇒ Object
447 448 449 450 451 |
# File 'lib/suspenders/app_builder.rb', line 447 def set_heroku_serve_static_files %w(staging production).each do |environment| run_heroku "config:add RAILS_SERVE_STATIC_FILES=true", environment end end |
#set_ruby_to_version_being_used ⇒ Object
207 208 209 |
# File 'lib/suspenders/app_builder.rb', line 207 def set_ruby_to_version_being_used create_file '.ruby-version', "#{Suspenders::RUBY_VERSION}\n" end |
#set_up_factory_girl_for_rspec ⇒ Object
78 79 80 |
# File 'lib/suspenders/app_builder.rb', line 78 def set_up_factory_girl_for_rspec copy_file 'factory_girl_rspec.rb', 'spec/support/factory_girl.rb' end |
#set_up_faker ⇒ Object
87 88 89 |
# File 'lib/suspenders/app_builder.rb', line 87 def set_up_faker copy_file 'faker_rspec.rb', 'spec/support/faker.rb' end |
#setup_asset_host ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/suspenders/app_builder.rb', line 135 def setup_asset_host replace_in_file 'config/environments/production.rb', "# config.action_controller.asset_host = 'http://assets.example.com'", 'config.action_controller.asset_host = ENV.fetch("ASSET_HOST", ENV.fetch("APPLICATION_HOST"))' replace_in_file 'config/initializers/assets.rb', "config.assets.version = '1.0'", 'config.assets.version = (ENV["ASSETS_VERSION"] || "1.0")' inject_into_file( "config/environments/production.rb", ' config.static_cache_control = "public, max-age=#{1.year.to_i}"', after: serve_static_files_line ) end |
#setup_brakeman ⇒ Object
494 495 496 |
# File 'lib/suspenders/app_builder.rb', line 494 def setup_brakeman copy_file "brakeman.rake", "lib/tasks/brakeman.rake" end |
#setup_bundler_audit ⇒ Object
490 491 492 |
# File 'lib/suspenders/app_builder.rb', line 490 def setup_bundler_audit copy_file "bundler_audit.rake", "lib/tasks/bundler_audit.rake" end |
#setup_default_rake_task ⇒ Object
563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 |
# File 'lib/suspenders/app_builder.rb', line 563 def setup_default_rake_task append_file 'Rakefile' do "task(:default).clear\n\nif defined? RSpec\n task(:spec).clear\n RSpec::Core::RakeTask.new(:spec) do |t|\nt.verbose = false\n end\nend\n\ntask default: :rubocop\ntask default: :spec\ntask default: \"brakeman:check\"\ntask default: \"bundler:audit\"\n EOS\n end\nend\n" |
#setup_foreman ⇒ Object
344 345 346 347 |
# File 'lib/suspenders/app_builder.rb', line 344 def setup_foreman copy_file 'sample.env', '.sample.env' copy_file 'Procfile', 'Procfile' end |
#setup_heroku_specific_gems ⇒ Object
215 216 217 218 219 220 221 |
# File 'lib/suspenders/app_builder.rb', line 215 def setup_heroku_specific_gems inject_into_file( "Gemfile", %{\n\s\sgem "rails_stdout_logging"}, after: /group :staging, :production do/ ) end |
#setup_rubocop ⇒ Object
498 499 500 501 |
# File 'lib/suspenders/app_builder.rb', line 498 def setup_rubocop copy_file "rubocop.rake", "lib/tasks/rubocop.rake" copy_file "rubocop.yml", ".rubocop.yml" end |
#setup_secret_token ⇒ Object
165 166 167 |
# File 'lib/suspenders/app_builder.rb', line 165 def setup_secret_token template 'secrets.yml', 'config/secrets.yml', force: true end |
#setup_spring ⇒ Object
503 504 505 |
# File 'lib/suspenders/app_builder.rb', line 503 def setup_spring bundle_command "exec spring binstub --all" end |
#setup_staging_environment ⇒ Object
151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/suspenders/app_builder.rb', line 151 def setup_staging_environment staging_file = 'config/environments/staging.rb' copy_file 'staging.rb', staging_file config = "\nRails.application.configure do\n # ...\nend\n RUBY\n\n append_file staging_file, config\nend\n" |
#setup_stylesheets ⇒ Object
349 350 351 352 353 |
# File 'lib/suspenders/app_builder.rb', line 349 def setup_stylesheets remove_file 'app/assets/stylesheets/application.css' copy_file 'application.css.sass', 'app/assets/stylesheets/application.css.sass' end |
#use_postgres_config_template ⇒ Object
193 194 195 196 |
# File 'lib/suspenders/app_builder.rb', line 193 def use_postgres_config_template template 'postgresql_database.yml.erb', 'config/database.yml', force: true end |