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.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -7
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +7 -2
  5. data/CONTRIBUTING.md +24 -26
  6. data/Gemfile.lock +94 -69
  7. data/NEWS.md +183 -0
  8. data/README.md +21 -127
  9. data/Rakefile +3 -3
  10. data/bin/rake +16 -0
  11. data/bin/rspec +16 -0
  12. data/bin/setup +13 -0
  13. data/bin/welaika-suspenders +8 -11
  14. data/lib/{welaika_suspenders → suspenders}/actions.rb +1 -16
  15. data/lib/suspenders/app_builder.rb +424 -0
  16. data/lib/{welaika_suspenders → suspenders}/generators/app_generator.rb +50 -54
  17. data/lib/suspenders/version.rb +5 -0
  18. data/lib/suspenders.rb +4 -0
  19. data/{features/support → spec/fakes}/bin/heroku +0 -0
  20. data/{features/support → spec/fakes}/bin/hub +0 -0
  21. data/spec/features/github_spec.rb +10 -0
  22. data/spec/features/heroku_spec.rb +19 -0
  23. data/spec/features/new_project_spec.rb +115 -0
  24. data/spec/spec_helper.rb +24 -0
  25. data/{features → spec}/support/fake_github.rb +1 -1
  26. data/spec/support/fake_heroku.rb +38 -0
  27. data/spec/support/suspenders.rb +49 -0
  28. data/suspenders.gemspec +36 -0
  29. data/templates/Gemfile.erb +58 -0
  30. data/templates/Procfile +1 -2
  31. data/templates/README.md.erb +28 -2
  32. data/templates/_flashes.html.slim +4 -3
  33. data/templates/_javascript.html.slim +3 -0
  34. data/templates/action_mailer.rb +5 -0
  35. data/templates/application.css.scss +3 -4
  36. data/templates/bin_setup.erb +34 -0
  37. data/templates/config_i18n_tasks.yml +13 -0
  38. data/templates/config_locales_en.yml.erb +19 -0
  39. data/templates/database_cleaner_rspec.rb +1 -4
  40. data/templates/development_seeds.rb +12 -0
  41. data/templates/errors.rb +22 -16
  42. data/templates/{factory_girl_syntax_rspec.rb → factory_girl_rspec.rb} +0 -0
  43. data/templates/i18n.rb +3 -0
  44. data/templates/newrelic.yml.erb +34 -0
  45. data/templates/postgresql_database.yml.erb +1 -1
  46. data/templates/rack_timeout.rb +1 -1
  47. data/templates/rails_helper.rb +23 -0
  48. data/templates/sample.env +1 -12
  49. data/templates/secrets.yml +14 -0
  50. data/templates/smtp.rb +9 -10
  51. data/templates/spec_helper.rb +16 -0
  52. data/templates/staging.rb +5 -0
  53. data/templates/suspenders_gitignore +10 -9
  54. data/templates/suspenders_layout.html.slim +14 -0
  55. data/templates/travis.yml.erb +24 -0
  56. data/templates/unicorn.rb +12 -9
  57. metadata +100 -80
  58. data/.DS_Store +0 -0
  59. data/features/github_repo.feature +0 -8
  60. data/features/heroku_true.feature +0 -9
  61. data/features/rake_clean.feature +0 -15
  62. data/features/step_definitions/suspenders_steps.rb +0 -69
  63. data/features/support/env.rb +0 -10
  64. data/features/support/fake_heroku.rb +0 -21
  65. data/lib/welaika_suspenders/app_builder.rb +0 -318
  66. data/lib/welaika_suspenders/version.rb +0 -4
  67. data/lib/welaika_suspenders/version_check.rb +0 -26
  68. data/templates/.DS_Store +0 -0
  69. data/templates/Gemfile_clean +0 -56
  70. data/templates/bin_setup +0 -11
  71. data/templates/capybara_selectors.rb +0 -29
  72. data/templates/config_locales_en.yml +0 -11
  73. data/templates/create_dragonfly_jobs.rb +0 -9
  74. data/templates/dragonfly.rb +0 -9
  75. data/templates/dragonfly_initializer.rb +0 -47
  76. data/templates/exist_in_db.rb +0 -6
  77. data/templates/factories_spec.rb +0 -14
  78. data/templates/factories_spec_rake_task.rb +0 -9
  79. data/templates/import_common_javascripts +0 -4
  80. data/templates/model_spec_helper.rb +0 -38
  81. data/templates/presenters.rb +0 -3
  82. data/templates/rails_root_definition.rb +0 -2
  83. data/templates/rspec +0 -2
  84. data/templates/rspec_config.rb +0 -16
  85. data/templates/simplecov_init.rb +0 -3
  86. data/templates/suspenders_layout.html.slim.erb +0 -12
  87. data/templates/unit_spec_helper.rb +0 -15
  88. 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
@@ -0,0 +1,13 @@
1
+ search:
2
+ paths:
3
+ - "app/controllers"
4
+ - "app/helpers"
5
+ - "app/presenters"
6
+ - "app/views"
7
+
8
+ ignore_unused:
9
+ - activerecord.*
10
+ - date.*
11
+ - simple_form.*
12
+ - time.*
13
+ - titles.*
@@ -0,0 +1,19 @@
1
+ en:
2
+ date:
3
+ formats:
4
+ default:
5
+ "%m/%d/%Y"
6
+ with_weekday:
7
+ "%a %m/%d/%y"
8
+
9
+ time:
10
+ formats:
11
+ default:
12
+ "%a, %b %-d, %Y at %r"
13
+ date:
14
+ "%b %-d, %Y"
15
+ short:
16
+ "%B %d"
17
+
18
+ titles:
19
+ application: <%= app_name.humanize %>
@@ -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: true) do
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 'net/http'
2
- require 'net/smtp'
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 = [Timeout::Error,
12
- Errno::EINVAL,
13
- Errno::ECONNRESET,
14
- EOFError,
15
- Net::HTTPBadResponse,
16
- Net::HTTPHeaderSyntaxError,
17
- Net::ProtocolError]
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 = [TimeoutError,
20
- IOError,
21
- Net::SMTPUnknownError,
22
- Net::SMTPServerBusy,
23
- Net::SMTPAuthenticationError]
21
+ SMTP_SERVER_ERRORS = [
22
+ IOError,
23
+ Net::SMTPAuthenticationError,
24
+ Net::SMTPServerBusy,
25
+ Net::SMTPUnknownError,
26
+ TimeoutError
27
+ ]
24
28
 
25
- SMTP_CLIENT_ERRORS = [Net::SMTPFatalError,
26
- Net::SMTPSyntaxError]
29
+ SMTP_CLIENT_ERRORS = [
30
+ Net::SMTPFatalError,
31
+ Net::SMTPSyntaxError
32
+ ]
27
33
 
28
34
  SMTP_ERRORS = SMTP_SERVER_ERRORS + SMTP_CLIENT_ERRORS
data/templates/i18n.rb ADDED
@@ -0,0 +1,3 @@
1
+ RSpec.configure do |config|
2
+ config.include AbstractController::Translation
3
+ end
@@ -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
@@ -3,7 +3,7 @@ development: &default
3
3
  database: <%= app_name %>_development
4
4
  encoding: utf8
5
5
  min_messages: warning
6
- pool: 5
6
+ pool: 2
7
7
  timeout: 5000
8
8
 
9
9
  test:
@@ -1 +1 @@
1
- Rack::Timeout.timeout = (ENV['TIMEOUT_IN_SECONDS'] || 5).to_i
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
- PORT=3000
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
@@ -0,0 +1,14 @@
1
+ default: &default
2
+ secret_key_base: <%%= ENV["SECRET_KEY_BASE"] %>
3
+
4
+ development:
5
+ <<: *default
6
+
7
+ test:
8
+ <<: *default
9
+
10
+ staging:
11
+ <<: *default
12
+
13
+ production:
14
+ <<: *default
data/templates/smtp.rb CHANGED
@@ -1,10 +1,9 @@
1
- if Rails.env.staging? || Rails.env.production?
2
- SMTP_SETTINGS = {
3
- address: ENV['SMTP_ADDRESS'], # example: 'smtp.sendgrid.net'
4
- authentication: :plain,
5
- domain: ENV['SMTP_DOMAIN'], # example: 'this-app.com'
6
- password: ENV['SMTP_PASSWORD'],
7
- port: '587',
8
- user_name: ENV['SMTP_USERNAME']
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)
@@ -0,0 +1,5 @@
1
+ require_relative "production"
2
+
3
+ Mail.register_interceptor(
4
+ RecipientInterceptor.new(ENV.fetch("EMAIL_RECIPIENTS"))
5
+ )
@@ -1,12 +1,13 @@
1
1
  !.keep
2
2
  *.DS_Store
3
+ *.swo
3
4
  *.swp
4
- .env
5
- bin/stubs
6
- coverage/*
7
- log/*
8
- public/system
9
- rerun.txt
10
- tags
11
- tmp/*
12
- vendor/bundler_gems
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['WEB_CONCURRENCY'] || 3).to_i
4
- timeout (ENV['WEB_TIMEOUT'] || 5).to_i
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 'TERM' do
9
- puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
10
- Process.kill 'QUIT', Process.pid
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 'TERM' do
20
- puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to sent QUIT'
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.establish_connection
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
-