welaika-suspenders 1.4.0 → 2.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -7
- data/.ruby-version +1 -0
- data/.travis.yml +7 -2
- data/CONTRIBUTING.md +24 -26
- data/Gemfile.lock +94 -69
- data/NEWS.md +183 -0
- data/README.md +21 -127
- data/Rakefile +3 -3
- data/bin/rake +16 -0
- data/bin/rspec +16 -0
- data/bin/setup +13 -0
- data/bin/welaika-suspenders +8 -11
- data/lib/{welaika_suspenders → suspenders}/actions.rb +1 -16
- data/lib/suspenders/app_builder.rb +424 -0
- data/lib/{welaika_suspenders → suspenders}/generators/app_generator.rb +50 -54
- data/lib/suspenders/version.rb +5 -0
- data/lib/suspenders.rb +4 -0
- data/{features/support → spec/fakes}/bin/heroku +0 -0
- data/{features/support → spec/fakes}/bin/hub +0 -0
- data/spec/features/github_spec.rb +10 -0
- data/spec/features/heroku_spec.rb +19 -0
- data/spec/features/new_project_spec.rb +115 -0
- data/spec/spec_helper.rb +24 -0
- data/{features → spec}/support/fake_github.rb +1 -1
- data/spec/support/fake_heroku.rb +38 -0
- data/spec/support/suspenders.rb +49 -0
- data/suspenders.gemspec +36 -0
- data/templates/Gemfile.erb +58 -0
- data/templates/Procfile +1 -2
- data/templates/README.md.erb +28 -2
- data/templates/_flashes.html.slim +4 -3
- data/templates/_javascript.html.slim +3 -0
- data/templates/action_mailer.rb +5 -0
- data/templates/application.css.scss +3 -4
- data/templates/bin_setup.erb +34 -0
- data/templates/config_i18n_tasks.yml +13 -0
- data/templates/config_locales_en.yml.erb +19 -0
- data/templates/database_cleaner_rspec.rb +1 -4
- data/templates/development_seeds.rb +12 -0
- data/templates/errors.rb +22 -16
- data/templates/{factory_girl_syntax_rspec.rb → factory_girl_rspec.rb} +0 -0
- data/templates/i18n.rb +3 -0
- data/templates/newrelic.yml.erb +34 -0
- data/templates/postgresql_database.yml.erb +1 -1
- data/templates/rack_timeout.rb +1 -1
- data/templates/rails_helper.rb +23 -0
- data/templates/sample.env +1 -12
- data/templates/secrets.yml +14 -0
- data/templates/smtp.rb +9 -10
- data/templates/spec_helper.rb +16 -0
- data/templates/staging.rb +5 -0
- data/templates/suspenders_gitignore +10 -9
- data/templates/suspenders_layout.html.slim +14 -0
- data/templates/travis.yml.erb +24 -0
- data/templates/unicorn.rb +12 -9
- metadata +100 -80
- data/.DS_Store +0 -0
- data/features/github_repo.feature +0 -8
- data/features/heroku_true.feature +0 -9
- data/features/rake_clean.feature +0 -15
- data/features/step_definitions/suspenders_steps.rb +0 -69
- data/features/support/env.rb +0 -10
- data/features/support/fake_heroku.rb +0 -21
- data/lib/welaika_suspenders/app_builder.rb +0 -318
- data/lib/welaika_suspenders/version.rb +0 -4
- data/lib/welaika_suspenders/version_check.rb +0 -26
- data/templates/.DS_Store +0 -0
- data/templates/Gemfile_clean +0 -56
- data/templates/bin_setup +0 -11
- data/templates/capybara_selectors.rb +0 -29
- data/templates/config_locales_en.yml +0 -11
- data/templates/create_dragonfly_jobs.rb +0 -9
- data/templates/dragonfly.rb +0 -9
- data/templates/dragonfly_initializer.rb +0 -47
- data/templates/exist_in_db.rb +0 -6
- data/templates/factories_spec.rb +0 -14
- data/templates/factories_spec_rake_task.rb +0 -9
- data/templates/import_common_javascripts +0 -4
- data/templates/model_spec_helper.rb +0 -38
- data/templates/presenters.rb +0 -3
- data/templates/rails_root_definition.rb +0 -2
- data/templates/rspec +0 -2
- data/templates/rspec_config.rb +0 -16
- data/templates/simplecov_init.rb +0 -3
- data/templates/suspenders_layout.html.slim.erb +0 -12
- data/templates/unit_spec_helper.rb +0 -15
- data/welaika-suspenders.gemspec +0 -35
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/env sh
|
2
|
+
|
3
|
+
# Set up Rails app. Run this script immediately after cloning the codebase.
|
4
|
+
# https://github.com/thoughtbot/guides/tree/master/protocol
|
5
|
+
|
6
|
+
# Exit if any subcommand fails
|
7
|
+
set -e
|
8
|
+
|
9
|
+
# Set up Ruby dependencies via Bundler
|
10
|
+
bundle --version &> /dev/null || gem install bundler --no-document
|
11
|
+
bundle install
|
12
|
+
|
13
|
+
# Set up configurable environment variables
|
14
|
+
if [ ! -f .env ]; then
|
15
|
+
cp .sample.env .env
|
16
|
+
fi
|
17
|
+
|
18
|
+
# Set up database and add any development seed data
|
19
|
+
bundle exec rake dev:prime
|
20
|
+
|
21
|
+
# Add binstubs to PATH via export PATH=".git/safe/../../bin:$PATH" in ~/.zshenv
|
22
|
+
mkdir -p .git/safe
|
23
|
+
|
24
|
+
# Pick a port for Foreman
|
25
|
+
if ! grep -qs 'port' .foreman; then
|
26
|
+
printf 'port: <%= config[:port_number] %>\n' >> .foreman
|
27
|
+
fi
|
28
|
+
|
29
|
+
# Error out if Foreman is not installed
|
30
|
+
if ! command -v foreman > /dev/null; then
|
31
|
+
printf 'Foreman is not installed.\n'
|
32
|
+
printf 'See https://github.com/ddollar/foreman for install instructions.\n'
|
33
|
+
exit 1
|
34
|
+
fi
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'database_cleaner'
|
2
|
-
|
3
1
|
RSpec.configure do |config|
|
4
2
|
config.before(:suite) do
|
5
3
|
DatabaseCleaner.clean_with(:deletion)
|
@@ -9,7 +7,7 @@ RSpec.configure do |config|
|
|
9
7
|
DatabaseCleaner.strategy = :transaction
|
10
8
|
end
|
11
9
|
|
12
|
-
config.before(:each, js
|
10
|
+
config.before(:each, :js => true) do
|
13
11
|
DatabaseCleaner.strategy = :deletion
|
14
12
|
end
|
15
13
|
|
@@ -21,4 +19,3 @@ RSpec.configure do |config|
|
|
21
19
|
DatabaseCleaner.clean
|
22
20
|
end
|
23
21
|
end
|
24
|
-
|
@@ -0,0 +1,12 @@
|
|
1
|
+
if Rails.env.development?
|
2
|
+
require "factory_girl"
|
3
|
+
|
4
|
+
namespace :dev do
|
5
|
+
desc "Seed data for development environment"
|
6
|
+
task prime: "db:setup" do
|
7
|
+
include FactoryGirl::Syntax::Methods
|
8
|
+
|
9
|
+
# create(:user, email: "user@example.com", password: "password")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/templates/errors.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "net/http"
|
2
|
+
require "net/smtp"
|
3
3
|
|
4
4
|
# Example:
|
5
5
|
# begin
|
@@ -8,21 +8,27 @@ require 'net/smtp'
|
|
8
8
|
# notify_hoptoad error
|
9
9
|
# end
|
10
10
|
|
11
|
-
HTTP_ERRORS = [
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
HTTP_ERRORS = [
|
12
|
+
EOFError,
|
13
|
+
Errno::ECONNRESET,
|
14
|
+
Errno::EINVAL,
|
15
|
+
Net::HTTPBadResponse,
|
16
|
+
Net::HTTPHeaderSyntaxError,
|
17
|
+
Net::ProtocolError,
|
18
|
+
Timeout::Error
|
19
|
+
]
|
18
20
|
|
19
|
-
SMTP_SERVER_ERRORS = [
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
SMTP_SERVER_ERRORS = [
|
22
|
+
IOError,
|
23
|
+
Net::SMTPAuthenticationError,
|
24
|
+
Net::SMTPServerBusy,
|
25
|
+
Net::SMTPUnknownError,
|
26
|
+
TimeoutError
|
27
|
+
]
|
24
28
|
|
25
|
-
SMTP_CLIENT_ERRORS = [
|
26
|
-
|
29
|
+
SMTP_CLIENT_ERRORS = [
|
30
|
+
Net::SMTPFatalError,
|
31
|
+
Net::SMTPSyntaxError
|
32
|
+
]
|
27
33
|
|
28
34
|
SMTP_ERRORS = SMTP_SERVER_ERRORS + SMTP_CLIENT_ERRORS
|
File without changes
|
data/templates/i18n.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
common: &default_settings
|
2
|
+
app_name: "<%= app_name %>"
|
3
|
+
audit_log:
|
4
|
+
enabled: false
|
5
|
+
browser_monitoring:
|
6
|
+
auto_instrument: true
|
7
|
+
capture_params: false
|
8
|
+
developer_mode: false
|
9
|
+
error_collector:
|
10
|
+
capture_source: true
|
11
|
+
enabled: true
|
12
|
+
ignore_errors: "ActionController::RoutingError,Sinatra::NotFound"
|
13
|
+
license_key: "<%%= ENV["NEW_RELIC_LICENSE_KEY"] %>"
|
14
|
+
log_level: info
|
15
|
+
monitor_mode: true
|
16
|
+
transaction_tracer:
|
17
|
+
enabled: true
|
18
|
+
record_sql: obfuscated
|
19
|
+
stack_trace_threshold: 0.500
|
20
|
+
transaction_threshold: apdex_f
|
21
|
+
development:
|
22
|
+
<<: *default_settings
|
23
|
+
monitor_mode: false
|
24
|
+
developer_mode: true
|
25
|
+
test:
|
26
|
+
<<: *default_settings
|
27
|
+
monitor_mode: false
|
28
|
+
production:
|
29
|
+
<<: *default_settings
|
30
|
+
monitor_mode: true
|
31
|
+
staging:
|
32
|
+
<<: *default_settings
|
33
|
+
app_name: "<%= app_name %> (Staging)"
|
34
|
+
monitor_mode: true
|
data/templates/rack_timeout.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Rack::Timeout.timeout = (ENV[
|
1
|
+
Rack::Timeout.timeout = (ENV["TIMEOUT_IN_SECONDS"] || 5).to_i
|
@@ -0,0 +1,23 @@
|
|
1
|
+
ENV["RAILS_ENV"] = "test"
|
2
|
+
|
3
|
+
require File.expand_path("../../config/environment", __FILE__)
|
4
|
+
|
5
|
+
require "rspec/rails"
|
6
|
+
require "shoulda/matchers"
|
7
|
+
|
8
|
+
Dir[Rails.root.join("spec/support/**/*.rb")].each { |file| require file }
|
9
|
+
|
10
|
+
module Features
|
11
|
+
# Extend this module in spec/support/features/*.rb
|
12
|
+
include Formulaic::Dsl
|
13
|
+
end
|
14
|
+
|
15
|
+
RSpec.configure do |config|
|
16
|
+
config.include Features, type: :feature
|
17
|
+
config.infer_base_class_for_anonymous_controllers = false
|
18
|
+
config.infer_spec_type_from_file_location!
|
19
|
+
config.use_transactional_fixtures = false
|
20
|
+
end
|
21
|
+
|
22
|
+
ActiveRecord::Migration.maintain_test_schema!
|
23
|
+
Capybara.javascript_driver = :webkit
|
data/templates/sample.env
CHANGED
@@ -1,14 +1,3 @@
|
|
1
1
|
# http://ddollar.github.com/foreman/
|
2
2
|
RACK_ENV=development
|
3
|
-
|
4
|
-
TIMEOUT_IN_SECONDS=10
|
5
|
-
|
6
|
-
# required in production and staging
|
7
|
-
# SMTP_ADDRESS=smtp.sendgrid.net
|
8
|
-
# SMTP_DOMAIN=heroku.com
|
9
|
-
# SMTP_USERNAME=appXXX@heroku.com
|
10
|
-
# SMTP_PASSWORD=pass
|
11
|
-
|
12
|
-
# required in staging
|
13
|
-
# EMAIL_RECIPIENTS=black-hole@example.com
|
14
|
-
|
3
|
+
SECRET_KEY_BASE=development_secret
|
data/templates/smtp.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
1
|
+
SMTP_SETTINGS = {
|
2
|
+
address: ENV.fetch("SMTP_ADDRESS"), # example: "smtp.sendgrid.net"
|
3
|
+
authentication: :plain,
|
4
|
+
domain: ENV.fetch("SMTP_DOMAIN"), # example: "this-app.com"
|
5
|
+
enable_starttls_auto: true,
|
6
|
+
password: ENV.fetch("SMTP_PASSWORD"),
|
7
|
+
port: "587",
|
8
|
+
user_name: ENV.fetch("SMTP_USERNAME")
|
9
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "webmock/rspec"
|
2
|
+
|
3
|
+
# http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
4
|
+
RSpec.configure do |config|
|
5
|
+
config.expect_with :rspec do |expectations|
|
6
|
+
expectations.syntax = :expect
|
7
|
+
end
|
8
|
+
|
9
|
+
config.mock_with :rspec do |mocks|
|
10
|
+
mocks.syntax = :expect
|
11
|
+
end
|
12
|
+
|
13
|
+
config.order = :random
|
14
|
+
end
|
15
|
+
|
16
|
+
WebMock.disable_net_connect!(allow_localhost: true)
|
@@ -1,12 +1,13 @@
|
|
1
1
|
!.keep
|
2
2
|
*.DS_Store
|
3
|
+
*.swo
|
3
4
|
*.swp
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
5
|
+
/.bundle
|
6
|
+
/.env
|
7
|
+
/.foreman
|
8
|
+
/coverage/*
|
9
|
+
/db/*.sqlite3
|
10
|
+
/log/*
|
11
|
+
/public/system
|
12
|
+
/tags
|
13
|
+
/tmp/*
|
@@ -0,0 +1,14 @@
|
|
1
|
+
doctype html
|
2
|
+
html
|
3
|
+
head
|
4
|
+
meta charset="utf-8"
|
5
|
+
meta http-equiv="X-UA-Compatible" content="IE=edge"
|
6
|
+
meta name="ROBOTS" content="NOODP"
|
7
|
+
meta name="viewport" content="width=device-width, initial-scale=1"
|
8
|
+
title= title
|
9
|
+
= stylesheet_link_tag :application, media: 'all'
|
10
|
+
= csrf_meta_tags
|
11
|
+
body class=body_class
|
12
|
+
= render "flashes"
|
13
|
+
= yield
|
14
|
+
= render "javascript"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
before_install:
|
2
|
+
- "echo '--colour' > ~/.rspec"
|
3
|
+
- "echo 'gem: --no-document' > ~/.gemrc"
|
4
|
+
- export DISPLAY=:99.0
|
5
|
+
- sh -e /etc/init.d/xvfb start
|
6
|
+
before_script:
|
7
|
+
- cp .sample.env .env
|
8
|
+
<% if options[:database] == "postgresql" %>
|
9
|
+
- psql -c 'create database "<%= app_name %>_test";' -U postgres
|
10
|
+
<% end %>
|
11
|
+
branches:
|
12
|
+
only:
|
13
|
+
- master
|
14
|
+
cache:
|
15
|
+
- bundler
|
16
|
+
language:
|
17
|
+
- ruby
|
18
|
+
notifications:
|
19
|
+
email:
|
20
|
+
- false
|
21
|
+
rvm:
|
22
|
+
- <%= Suspenders::RUBY_VERSION %>
|
23
|
+
addons:
|
24
|
+
postgresql: "9.3"
|
data/templates/unicorn.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# https://devcenter.heroku.com/articles/rails-unicorn
|
2
2
|
|
3
|
-
worker_processes (ENV[
|
4
|
-
timeout (ENV[
|
3
|
+
worker_processes (ENV["WEB_CONCURRENCY"] || 3).to_i
|
4
|
+
timeout (ENV["WEB_TIMEOUT"] || 5).to_i
|
5
5
|
preload_app true
|
6
6
|
|
7
7
|
before_fork do |server, worker|
|
8
|
-
Signal.trap
|
9
|
-
puts
|
10
|
-
Process.kill
|
8
|
+
Signal.trap "TERM" do
|
9
|
+
puts "Unicorn master intercepting TERM and sending myself QUIT instead"
|
10
|
+
Process.kill "QUIT", Process.pid
|
11
11
|
end
|
12
12
|
|
13
13
|
if defined? ActiveRecord::Base
|
@@ -16,12 +16,15 @@ before_fork do |server, worker|
|
|
16
16
|
end
|
17
17
|
|
18
18
|
after_fork do |server, worker|
|
19
|
-
Signal.trap
|
20
|
-
puts
|
19
|
+
Signal.trap "TERM" do
|
20
|
+
puts "Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT"
|
21
21
|
end
|
22
22
|
|
23
23
|
if defined? ActiveRecord::Base
|
24
|
-
ActiveRecord::Base.
|
24
|
+
config = ActiveRecord::Base.configurations[Rails.env] ||
|
25
|
+
Rails.application.config.database_configuration[Rails.env]
|
26
|
+
config["reaping_frequency"] = (ENV["DB_REAPING_FREQUENCY"] || 10).to_i
|
27
|
+
config["pool"] = (ENV["DB_POOL"] || 2).to_i
|
28
|
+
ActiveRecord::Base.establish_connection(config)
|
25
29
|
end
|
26
30
|
end
|
27
|
-
|