class Platter::AppBuilder

Constants

PORT

Public Instance Methods

add_api_support() click to toggle source

API builds

# File lib/platter/app_builder.rb, line 24
    def add_api_support
      inject_into_file "Gemfile", after: "ruby \"#{Platter::RUBY_VERSION}\"" do
        %Q{

gem "versionist"
gem "active_model_serializers", github: "rails-api/active_model_serializers", branch: "0-8-stable"
        }
      end
    end
add_api_version_base_controller() click to toggle source
# File lib/platter/app_builder.rb, line 38
def add_api_version_base_controller
  template "base_api_controller.erb", "app/controllers/api/v1/base_controller.rb"
end
add_api_version_directories() click to toggle source
# File lib/platter/app_builder.rb, line 34
def add_api_version_directories
  empty_directory "app/controllers/api/v1/"
end
add_exception_notification_mailer_configuration() click to toggle source
# File lib/platter/app_builder.rb, line 160
  def add_exception_notification_mailer_configuration
    %w{ production staging }.each do |env|
      inject_into_file "config/environments/#{env}.rb",
        %Q{

#Exception Notification configuration
config.middleware.use ExceptionNotification::Rack,
:email => {
  :email_prefix => "[#{app_name}] ",
  :sender_address => %{"Exception" <exception@#{app_name.downcase}-#{env}.com>},
  :exception_recipients => %w{}
}
        },
          after: "config.active_record.dump_schema_after_migration = false"
    end
  end
add_smtp_configuration_for_deployment() click to toggle source
# File lib/platter/app_builder.rb, line 177
  def add_smtp_configuration_for_deployment
    %w{ production staging }.each do |env|
      inject_into_file "config/environments/#{env}.rb",
        %Q{

# STMP configuration
config.action_mailer.default_url_options = { :host => ENV['HOST_DEFAULT_URL'], only_path: false }
config.action_mailer.delivery_method = :smtp
        },
          after: "config.active_record.dump_schema_after_migration = false"
    end
  end
add_support_rspec_files() click to toggle source
# File lib/platter/app_builder.rb, line 140
def add_support_rspec_files
  empty_directory "spec/support/"
  template "rspec_support_database_cleaner.erb", "spec/support/database_cleaner.rb"
  template "rspec_support_factory_girl.erb", "spec/support/factory_girl.rb"
  template "rspec_support_i18n.erb", "spec/support/i18n.rb"
end
app() click to toggle source
Calls superclass method
# File lib/platter/app_builder.rb, line 190
def app
  super
  if options["skip_assets"]
    remove_dir "app/assets"
    remove_dir "app/views"
    remove_dir "app/helpers"
  end
end
copy_production_env_to_staging() click to toggle source

STAGING builds

# File lib/platter/app_builder.rb, line 149
def copy_production_env_to_staging
  template "production_env.erb", "config/environments/staging.rb"
end
fix_i18n_deprecation_warning() click to toggle source
# File lib/platter/app_builder.rb, line 109
def fix_i18n_deprecation_warning
  inject_into_class 'config/application.rb', 'Application',
    %Q{
config.i18n.enforce_available_locales = true\n}
end
init_rspec() click to toggle source

TEST builds

# File lib/platter/app_builder.rb, line 136
def init_rspec
  run "docker-compose run --rm web rspec:install"
end
init_sendgrid_initialize_file() click to toggle source

MAILER builds

# File lib/platter/app_builder.rb, line 155
def init_sendgrid_initialize_file
  template "mailer_initializer_config.erb", "config/initializers/mailer_setup.rb"
end
provide_api_routes() click to toggle source
# File lib/platter/app_builder.rb, line 42
def provide_api_routes
  template "api_routes.erb", "config/routes.rb", force: true
end
provide_attach_script() click to toggle source
# File lib/platter/app_builder.rb, line 76
def provide_attach_script
  template "attach.erb", "bin/attach"
  run "chmod a+x bin/attach"
end
provide_db_script() click to toggle source
# File lib/platter/app_builder.rb, line 71
def provide_db_script
  template "check_or_setup_db.erb", "bin/check_or_setup_db"
  run "chmod a+x bin/check_or_setup_db"
end
provide_dev_entrypoint() click to toggle source
# File lib/platter/app_builder.rb, line 66
def provide_dev_entrypoint
  template "dev-entrypoint.sh", "dev-entrypoint"
  run "chmod a+x dev-entrypoint"
end
provide_first_commit() click to toggle source
# File lib/platter/app_builder.rb, line 54
def provide_first_commit
  git add: "."
  git commit: "-m 'Project initialization using Platter'"
end
provide_generators_configuration() click to toggle source
# File lib/platter/app_builder.rb, line 115
def provide_generators_configuration
  inject_into_file 'config/application.rb',
    %q{
# don't generate RSpec tests for views and helpers
config.generators do |g|
  g.test_framework :rspec, fixture: true
  g.fixture_replacement :factory_girl, dir: 'spec/factories'
  g.view_specs false
  g.helper_specs false
  g.stylesheets false
  g.javascripts false
  g.helper false
end

config.autoload_paths += %W(#{config.root}/lib)
    },
      after: "config.active_record.raise_in_transactional_callbacks = true"
end
provide_restoredb_script() click to toggle source
# File lib/platter/app_builder.rb, line 81
def provide_restoredb_script
  empty_directory "db/dumps"
  create_file "db/dumps/.keep"
  template "restoredb.erb", "bin/restoredb"
  run "chmod a+x bin/restoredb"
end
readme() click to toggle source
# File lib/platter/app_builder.rb, line 5
def readme
  template "README.md.erb", "README.md"
end
replace_gemfile() click to toggle source
# File lib/platter/app_builder.rb, line 9
def replace_gemfile
  remove_file "Gemfile"
  template "Gemfile.erb", "Gemfile"
end
setup_db() click to toggle source
# File lib/platter/app_builder.rb, line 18
def setup_db
    run "docker-compose run --rm web rake db:create"
end
setup_development_mail_delivery_strategy() click to toggle source

Development builds

# File lib/platter/app_builder.rb, line 96
  def setup_development_mail_delivery_strategy
    inject_into_file "config/environments/development.rb",
      %Q{

# We use mailcatcher to preview emails
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = { :address => "localhost", :port => 1025 }
config.action_mailer.default_url_options = { host: "localhost:#{PORT}" }
config.action_mailer.asset_host = "http://localhost:#{PORT}"
      },
        after: "config.action_mailer.raise_delivery_errors = false"
  end
setup_docker_compose() click to toggle source

Docker Build

# File lib/platter/app_builder.rb, line 61
def setup_docker_compose
  template "docker-compose.yml.erb", "docker-compose.yml"
  create_file "dev.env"
end
setup_gems() click to toggle source
# File lib/platter/app_builder.rb, line 14
def setup_gems
    run "docker-compose run --rm web bundle"
end
setup_git() click to toggle source

GIT builds

# File lib/platter/app_builder.rb, line 48
def setup_git
  remove_file '.gitignore'
  copy_file "platter_gitignore", ".gitignore"
  git :init
end
setup_server() click to toggle source

Server build

# File lib/platter/app_builder.rb, line 90
def setup_server
  template "Procfile", "Procfile"
end
vendor_stylesheets() click to toggle source
# File lib/platter/app_builder.rb, line 199
def vendor_stylesheets
  empty_directory_with_keep_file 'vendor/assets/stylesheets' unless options[:skip_assets]
end