class Tirantes::AppBuilder
Public Instance Methods
configure_action_mailer()
click to toggle source
# File lib/tirantes/app_builder.rb, line 201 def configure_action_mailer action_mailer_host 'development', "#{app_name}.local" action_mailer_host 'test', 'www.example.com' action_mailer_host 'staging', "staging.#{app_name}.com" action_mailer_host 'production', "#{app_name}.com" end
configure_background_jobs_for_minitest()
click to toggle source
# File lib/tirantes/app_builder.rb, line 166 def configure_background_jobs_for_minitest copy_file 'background_jobs_minitest.rb', 'test/support/background_jobs.rb' run 'rails g delayed_job:active_record' end
configure_exception_notifier()
click to toggle source
# File lib/tirantes/app_builder.rb, line 79 def configure_exception_notifier copy_file 'exception_notification.rb', 'config/initializers/exception_notification.rb' end
configure_generators()
click to toggle source
# File lib/tirantes/app_builder.rb, line 62 def configure_generators config = <<-RUBY config.generators do |generate| generate.helper false generate.javascript_engine false generate.request_specs false generate.routing_specs false generate.stylesheets false generate.test_framework :mini_test, :spec => true, :fixture => true generate.view_specs false end RUBY inject_into_class 'config/application.rb', 'Application', config end
configure_minitest()
click to toggle source
# File lib/tirantes/app_builder.rb, line 161 def configure_minitest remove_file 'test/test_helper.rb' copy_file 'test_helper.rb', 'test/test_helper.rb' end
configure_pretty_formatter()
click to toggle source
# File lib/tirantes/app_builder.rb, line 179 def configure_pretty_formatter config = <<-RUBY config.log_formatter = PrettyFormatter.formatter RUBY inject_into_class 'config/application.rb', 'Application', config end
configure_puma()
click to toggle source
# File lib/tirantes/app_builder.rb, line 212 def configure_puma copy_file 'puma.rb', 'config/puma.rb' end
configure_rack_timeout()
click to toggle source
# File lib/tirantes/app_builder.rb, line 197 def configure_rack_timeout copy_file 'rack_timeout.rb', 'config/initializers/rack_timeout.rb' end
configure_simple_form()
click to toggle source
# File lib/tirantes/app_builder.rb, line 187 def configure_simple_form run 'rails g simple_form:install' copy_file 'simple_form_purecss.rb', 'config/simple_form_purecss.rb' end
configure_smtp()
click to toggle source
# File lib/tirantes/app_builder.rb, line 83 def configure_smtp copy_file 'smtp.rb', 'config/initializers/smtp.rb' prepend_file 'config/environments/production.rb', "require Rails.root.join('config/initializers/smtp')\n" config = <<-RUBY config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = SMTP_SETTINGS RUBY inject_into_file 'config/environments/production.rb', config, :after => 'config.action_mailer.raise_delivery_errors = false' end
configure_time_formats()
click to toggle source
# File lib/tirantes/app_builder.rb, line 192 def configure_time_formats remove_file 'config/locales/en.yml' copy_file 'config_locales_en.yml', 'config/locales/en.yml' end
configure_time_zone()
click to toggle source
# File lib/tirantes/app_builder.rb, line 171 def configure_time_zone config = <<-RUBY config.active_record.default_timezone = :utc RUBY inject_into_class 'config/application.rb', 'Application', config end
copy_miscellaneous_files()
click to toggle source
# File lib/tirantes/app_builder.rb, line 281 def copy_miscellaneous_files copy_file 'errors.rb', 'config/initializers/errors.rb' end
create_application_layout()
click to toggle source
# File lib/tirantes/app_builder.rb, line 122 def create_application_layout template 'tirantes_layout.html.erb.erb', 'app/views/layouts/application.html.erb', :force => true end
create_common_javascripts()
click to toggle source
# File lib/tirantes/app_builder.rb, line 134 def create_common_javascripts directory 'javascripts', 'app/assets/javascripts' end
create_database()
click to toggle source
# File lib/tirantes/app_builder.rb, line 143 def create_database bundle_command 'exec rake db:create' end
create_github_repo(repo_name)
click to toggle source
# File lib/tirantes/app_builder.rb, line 276 def create_github_repo(repo_name) path_addition = override_path_for_tests run "#{path_addition} hub create #{repo_name}" end
create_heroku_apps()
click to toggle source
# File lib/tirantes/app_builder.rb, line 258 def create_heroku_apps path_addition = override_path_for_tests run "#{path_addition} heroku create #{app_name}-production --remote=production" run "#{path_addition} heroku create #{app_name}-staging --remote=staging" run "#{path_addition} heroku config:add RACK_ENV=staging RAILS_ENV=staging --remote=staging" end
create_partials_directory()
click to toggle source
# File lib/tirantes/app_builder.rb, line 110 def create_partials_directory empty_directory 'app/views/application' end
customize_error_pages()
click to toggle source
# File lib/tirantes/app_builder.rb, line 285 def customize_error_pages meta_tags =<<-EOS <meta charset='utf-8' /> <meta name='ROBOTS' content='NOODP' /> EOS %w(500 404 422).each do |page| inject_into_file "public/#{page}.html", meta_tags, :after => "<head>\n" replace_in_file "public/#{page}.html", /<!--.+-->\n/, '' end end
disable_xml_params()
click to toggle source
# File lib/tirantes/app_builder.rb, line 303 def disable_xml_params copy_file 'disable_xml_params.rb', 'config/initializers/disable_xml_params.rb' end
enable_database_cleaner()
click to toggle source
# File lib/tirantes/app_builder.rb, line 157 def enable_database_cleaner copy_file 'database_cleaner_minitest.rb', 'test/support/database_cleaner.rb' end
generate_minitest()
click to toggle source
# File lib/tirantes/app_builder.rb, line 208 def generate_minitest generate 'rails g mini_test:install' end
gitignore_files()
click to toggle source
# File lib/tirantes/app_builder.rb, line 235 def gitignore_files remove_file '.gitignore' copy_file 'tirantes_gitignore', '.gitignore' [ 'app/views/pages', 'test/lib', 'test/controllers', 'test/models', 'test/integration', 'test/helpers', 'test/support/matchers', 'test/support/mixins', 'test/support/shared_examples' ].each do |dir| run "mkdir #{dir}" run "touch #{dir}/.keep" end end
init_git()
click to toggle source
# File lib/tirantes/app_builder.rb, line 254 def init_git run 'git init' end
provide_setup_script()
click to toggle source
# File lib/tirantes/app_builder.rb, line 36 def provide_setup_script foreman = <<-RUBY # Set up Rails app. Run this script immediately after cloning the codebase. # https://github.com/thoughtbot/guides/tree/master/protocol # Set up configurable environment variables if [ ! -f .env ]; then cp .sample.env .env fi # Pick a port for Foreman echo "port: 7000" > .foreman # Set up DNS via Pow if [ -d ~/.pow ] then echo 7000 > ~/.pow/`basename $PWD` else echo "Pow not set up but the team uses it for this project. Setup: http://goo.gl/RaDPO" fi RUBY append_file 'bin/setup', foreman run 'chmod a+x bin/setup' end
raise_on_delivery_errors()
click to toggle source
# File lib/tirantes/app_builder.rb, line 17 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()
click to toggle source
# File lib/tirantes/app_builder.rb, line 22 def raise_on_unpermitted_parameters action_on_unpermitted_parameters = <<-RUBY # Raise an ActionController::UnpermittedParameters exception when # a parameter is not explcitly permitted but is passed anyway. config.action_controller.action_on_unpermitted_parameters = :raise RUBY inject_into_file( "config/environments/development.rb", action_on_unpermitted_parameters, before: "\nend" ) end
readme()
click to toggle source
# File lib/tirantes/app_builder.rb, line 5 def readme template 'README.md.erb', 'README.md' end
remove_public_index()
click to toggle source
# File lib/tirantes/app_builder.rb, line 9 def remove_public_index remove_file 'public/index.html' end
remove_rails_logo_image()
click to toggle source
# File lib/tirantes/app_builder.rb, line 13 def remove_rails_logo_image remove_file 'app/assets/images/rails.png' end
remove_routes_comment_lines()
click to toggle source
# File lib/tirantes/app_builder.rb, line 297 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
remove_turbolinks()
click to toggle source
# File lib/tirantes/app_builder.rb, line 128 def remove_turbolinks replace_in_file 'app/assets/javascripts/application.js', /\/\/= require turbolinks\n/, '' end
replace_gemfile()
click to toggle source
# File lib/tirantes/app_builder.rb, line 147 def replace_gemfile remove_file 'Gemfile' copy_file 'Gemfile_clean', 'Gemfile' end
set_heroku_remotes()
click to toggle source
# File lib/tirantes/app_builder.rb, line 265 def set_heroku_remotes remotes = <<-RUBY # Set up staging and production git remotes git remote add staging git@heroku.com:#{app_name}-staging.git git remote add production git@heroku.com:#{app_name}-production.git RUBY append_file 'bin/setup', remotes end
set_ruby_to_version_being_used()
click to toggle source
# File lib/tirantes/app_builder.rb, line 152 def set_ruby_to_version_being_used inject_into_file 'Gemfile', "\n\nruby '#{RUBY_VERSION}'", after: /source 'https:\/\/rubygems.org'/ end
setup_default_rake_task()
click to toggle source
# File lib/tirantes/app_builder.rb, line 307 def setup_default_rake_task append_file 'Rakefile' do "task(:default).clear\ntask :default => ['test:all']\n" end end
setup_foreman()
click to toggle source
# File lib/tirantes/app_builder.rb, line 216 def setup_foreman copy_file 'sample.env', '.sample.env' copy_file 'Procfile', 'Procfile' end
setup_secret_token()
click to toggle source
# File lib/tirantes/app_builder.rb, line 106 def setup_secret_token template 'secret_token.rb.erb', 'config/initializers/secret_token.rb', :force => true end
setup_staging_environment()
click to toggle source
# File lib/tirantes/app_builder.rb, line 99 def setup_staging_environment run 'cp config/environments/production.rb config/environments/staging.rb' prepend_file 'config/environments/staging.rb', "Mail.register_interceptor RecipientInterceptor.new(ENV['EMAIL_RECIPIENTS'])\n" end
setup_stylesheets()
click to toggle source
# File lib/tirantes/app_builder.rb, line 221 def setup_stylesheets remove_file 'app/assets/stylesheets/application.css' copy_file 'application.css.scss', 'app/assets/stylesheets/application.css.scss' [ 'app/assets/stylesheets/base', 'app/assets/stylesheets/layout', 'app/assets/stylesheets/modules' ].each do |dir| run "mkdir #{dir}" run "touch #{dir}/.keep" end end
use_postgres_config_template()
click to toggle source
# File lib/tirantes/app_builder.rb, line 138 def use_postgres_config_template template 'postgresql_database.yml.erb', 'config/database.yml', :force => true end
Private Instance Methods
override_path_for_tests()
click to toggle source
# File lib/tirantes/app_builder.rb, line 315 def override_path_for_tests if ENV['TESTING'] support_bin = File.expand_path(File.join('..', '..', '..', 'features', 'support', 'bin')) "PATH=#{support_bin}:$PATH" end end