mj-suspenders 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/.travis.yml +12 -0
- data/CONTRIBUTING.md +38 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +136 -0
- data/LICENSE +21 -0
- data/README.md +60 -0
- data/Rakefile +8 -0
- data/TODO.md +19 -0
- data/bin/mj-suspenders +18 -0
- data/bin/rspec +16 -0
- data/lib/suspenders/actions.rb +35 -0
- data/lib/suspenders/app_builder.rb +251 -0
- data/lib/suspenders/generators/app_generator.rb +165 -0
- data/lib/suspenders/version.rb +3 -0
- data/lib/suspenders.rb +3 -0
- data/mj-suspenders.gemspec +34 -0
- data/spec/features/new_project_spec.rb +38 -0
- data/spec/spec_helper.rb +27 -0
- data/spec/support/suspenders.rb +50 -0
- data/templates/Gemfile.erb +43 -0
- data/templates/README.md.erb +36 -0
- data/templates/_flashes.html.erb +5 -0
- data/templates/_javascript.html.erb +10 -0
- data/templates/application.css.scss +4 -0
- data/templates/config_locales_en.yml +11 -0
- data/templates/database_cleaner_rspec.rb +21 -0
- data/templates/disable_xml_params.rb +3 -0
- data/templates/errors.rb +28 -0
- data/templates/i18n.rb +3 -0
- data/templates/ruby-version.erb +1 -0
- data/templates/secret_token.rb +10 -0
- data/templates/spec_helper.rb +29 -0
- data/templates/staging.rb +6 -0
- data/templates/suspenders_gitignore +13 -0
- data/templates/suspenders_layout.html.erb.erb +15 -0
- data/templates/travis.yml.erb +23 -0
- data/templates/unicorn.rb +29 -0
- metadata +186 -0
@@ -0,0 +1,165 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/rails/app/app_generator'
|
3
|
+
|
4
|
+
module Suspenders
|
5
|
+
class AppGenerator < Rails::Generators::AppGenerator
|
6
|
+
class_option :database, :type => :string, :aliases => '-d', :default => 'mysql',
|
7
|
+
:desc => "Preconfigure for selected database (options: #{DATABASES.join('/')})"
|
8
|
+
|
9
|
+
class_option :skip_test_unit, :type => :boolean, :aliases => '-T', :default => true,
|
10
|
+
:desc => 'Skip Test::Unit files'
|
11
|
+
|
12
|
+
def finish_template
|
13
|
+
invoke :suspenders_customization
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
def suspenders_customization
|
18
|
+
invoke :customize_gemfile
|
19
|
+
invoke :setup_development_environment
|
20
|
+
invoke :setup_test_environment
|
21
|
+
invoke :setup_production_environment
|
22
|
+
invoke :setup_staging_environment
|
23
|
+
invoke :setup_secret_token
|
24
|
+
invoke :create_suspenders_views
|
25
|
+
invoke :setup_coffeescript
|
26
|
+
invoke :configure_app
|
27
|
+
invoke :setup_stylesheets
|
28
|
+
invoke :copy_miscellaneous_files
|
29
|
+
invoke :customize_error_pages
|
30
|
+
invoke :remove_routes_comment_lines
|
31
|
+
invoke :setup_git
|
32
|
+
invoke :setup_database
|
33
|
+
end
|
34
|
+
|
35
|
+
def customize_gemfile
|
36
|
+
build :replace_gemfile
|
37
|
+
build :set_ruby_to_version_being_used
|
38
|
+
|
39
|
+
bundle_command 'install'
|
40
|
+
end
|
41
|
+
|
42
|
+
def setup_database
|
43
|
+
say 'Setting up database'
|
44
|
+
build :create_database
|
45
|
+
end
|
46
|
+
|
47
|
+
def setup_development_environment
|
48
|
+
say 'Setting up the development environment'
|
49
|
+
build :raise_on_delivery_errors
|
50
|
+
build :raise_on_unpermitted_parameters
|
51
|
+
build :configure_generators
|
52
|
+
end
|
53
|
+
|
54
|
+
def setup_test_environment
|
55
|
+
say 'Setting up the test environment'
|
56
|
+
build :generate_rspec
|
57
|
+
build :configure_rspec
|
58
|
+
build :use_spring_binstubs
|
59
|
+
build :enable_database_cleaner
|
60
|
+
build :configure_spec_support_features
|
61
|
+
build :configure_travis
|
62
|
+
build :configure_i18n_in_specs
|
63
|
+
end
|
64
|
+
|
65
|
+
def setup_production_environment
|
66
|
+
say 'Setting up the production environment'
|
67
|
+
build :enable_rack_deflater
|
68
|
+
end
|
69
|
+
|
70
|
+
def setup_staging_environment
|
71
|
+
say 'Setting up the staging environment'
|
72
|
+
build :setup_staging_environment
|
73
|
+
end
|
74
|
+
|
75
|
+
def setup_secret_token
|
76
|
+
say 'Moving secret token out of version control'
|
77
|
+
build :setup_secret_token
|
78
|
+
end
|
79
|
+
|
80
|
+
def create_suspenders_views
|
81
|
+
say 'Creating suspenders views'
|
82
|
+
build :create_partials_directory
|
83
|
+
build :create_shared_flashes
|
84
|
+
build :create_shared_javascripts
|
85
|
+
build :create_application_layout
|
86
|
+
end
|
87
|
+
|
88
|
+
def setup_coffeescript
|
89
|
+
say 'Setting up CoffeeScript defaults'
|
90
|
+
build :remove_turbolinks
|
91
|
+
end
|
92
|
+
|
93
|
+
def configure_app
|
94
|
+
say 'Configuring app'
|
95
|
+
build :configure_action_mailer
|
96
|
+
build :configure_time_zone
|
97
|
+
build :configure_time_formats
|
98
|
+
build :disable_xml_params
|
99
|
+
build :fix_i18n_deprecation_warning
|
100
|
+
build :setup_default_rake_task
|
101
|
+
build :configure_unicorn
|
102
|
+
end
|
103
|
+
|
104
|
+
def setup_stylesheets
|
105
|
+
say 'Set up stylesheets'
|
106
|
+
build :setup_stylesheets
|
107
|
+
end
|
108
|
+
|
109
|
+
def setup_git
|
110
|
+
if !options[:skip_git]
|
111
|
+
say 'Initializing git'
|
112
|
+
invoke :setup_gitignore
|
113
|
+
invoke :init_git
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def setup_gitignore
|
118
|
+
build :gitignore_files
|
119
|
+
end
|
120
|
+
|
121
|
+
def init_git
|
122
|
+
build :init_git
|
123
|
+
end
|
124
|
+
|
125
|
+
def copy_miscellaneous_files
|
126
|
+
say 'Copying miscellaneous support files'
|
127
|
+
build :copy_miscellaneous_files
|
128
|
+
end
|
129
|
+
|
130
|
+
def customize_error_pages
|
131
|
+
say 'Customizing the 500/404/422 pages'
|
132
|
+
build :customize_error_pages
|
133
|
+
end
|
134
|
+
|
135
|
+
def remove_routes_comment_lines
|
136
|
+
build :remove_routes_comment_lines
|
137
|
+
end
|
138
|
+
|
139
|
+
def run_bundle
|
140
|
+
# Let's not: We'll bundle manually at the right spot
|
141
|
+
end
|
142
|
+
|
143
|
+
def ruby_version_with_patch_level
|
144
|
+
"#{RUBY_VERSION}#{patch_level}"
|
145
|
+
end
|
146
|
+
|
147
|
+
protected
|
148
|
+
|
149
|
+
def get_builder_class
|
150
|
+
Suspenders::AppBuilder
|
151
|
+
end
|
152
|
+
|
153
|
+
def using_active_record?
|
154
|
+
!options[:skip_active_record]
|
155
|
+
end
|
156
|
+
|
157
|
+
def patch_level
|
158
|
+
if RUBY_PATCHLEVEL == 0 && RUBY_VERSION >= '2.1.0'
|
159
|
+
''
|
160
|
+
else
|
161
|
+
"-p#{RUBY_PATCHLEVEL}"
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
data/lib/suspenders.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'suspenders/version'
|
4
|
+
require 'date'
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.required_ruby_version = '>= 1.9.2'
|
8
|
+
s.add_dependency 'bundler', '~> 1.3'
|
9
|
+
s.add_dependency 'rails', '4.0.3'
|
10
|
+
s.add_development_dependency 'aruba', '~> 0.5.2'
|
11
|
+
s.add_development_dependency 'cucumber', '~> 1.2'
|
12
|
+
s.authors = ['thoughtbot', 'Marcelo Jacobus']
|
13
|
+
s.date = Date.today.strftime('%Y-%m-%d')
|
14
|
+
|
15
|
+
s.description = <<-HERE
|
16
|
+
MJ-Suspenders is a base Rails project used by the author of this gem.
|
17
|
+
HERE
|
18
|
+
|
19
|
+
s.email = 'marcelo.jacobus@gmail.com'
|
20
|
+
s.executables = ['mj-suspenders']
|
21
|
+
s.extra_rdoc_files = %w[README.md LICENSE]
|
22
|
+
s.files = `git ls-files`.split("\n")
|
23
|
+
s.homepage = 'http://github.com/mjacobus/mg-suspenders'
|
24
|
+
s.license = 'MIT'
|
25
|
+
s.name = 'mj-suspenders'
|
26
|
+
s.rdoc_options = ['--charset=UTF-8']
|
27
|
+
s.require_paths = ['lib']
|
28
|
+
s.summary = "Generate a Rails app using thoughtbot's best practices. Plus Marcelo Jacobus favorites"
|
29
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
30
|
+
s.version = Suspenders::VERSION
|
31
|
+
s.add_development_dependency 'rspec'
|
32
|
+
s.add_development_dependency 'simplecov', '~> 0.7.1'
|
33
|
+
s.add_development_dependency 'capybara'
|
34
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature 'Suspend a new project with default configuration' do
|
4
|
+
scenario 'specs pass' do
|
5
|
+
run_suspenders
|
6
|
+
|
7
|
+
Dir.chdir(project_path) do
|
8
|
+
Bundler.with_clean_env do
|
9
|
+
expect(`rake`).to include('0 failures')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
scenario 'staging config is inherited from production' do
|
15
|
+
run_suspenders
|
16
|
+
|
17
|
+
staging_file = IO.read("#{project_path}/config/environments/staging.rb")
|
18
|
+
config_stub = "Dummy::Application.configure do"
|
19
|
+
expect(staging_file).to match(/^require_relative 'production'/)
|
20
|
+
expect(staging_file).to match(/#{config_stub}/), staging_file
|
21
|
+
end
|
22
|
+
|
23
|
+
if RUBY_PATCHLEVEL == 0 && RUBY_VERSION >= '2.1.0'
|
24
|
+
scenario '.ruby-version does not include patchlevel for Ruby 2.1.0+' do
|
25
|
+
run_suspenders
|
26
|
+
|
27
|
+
ruby_version_file = IO.read("#{project_path}/.ruby-version")
|
28
|
+
expect(ruby_version_file).to eq "#{RUBY_VERSION}\n"
|
29
|
+
end
|
30
|
+
else
|
31
|
+
scenario '.ruby-version includes patchlevel for all pre-Ruby 2.1.0 versions' do
|
32
|
+
run_suspenders
|
33
|
+
|
34
|
+
ruby_version_file = IO.read("#{project_path}/.ruby-version")
|
35
|
+
expect(ruby_version_file).to eq "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}\n"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'capybara/rspec'
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'simplecov'
|
4
|
+
|
5
|
+
SimpleCov.start do
|
6
|
+
add_filter 'bin'
|
7
|
+
add_filter 'spec'
|
8
|
+
end
|
9
|
+
|
10
|
+
Bundler.require(:default, :test)
|
11
|
+
|
12
|
+
require (Pathname.new(__FILE__).dirname + '../lib/suspenders').expand_path
|
13
|
+
|
14
|
+
Dir['./spec/support/**/*.rb'].each { |file| require file }
|
15
|
+
|
16
|
+
RSpec.configure do |config|
|
17
|
+
config.include SuspendersTestHelpers
|
18
|
+
|
19
|
+
config.before(:all) do
|
20
|
+
create_tmp_directory
|
21
|
+
end
|
22
|
+
|
23
|
+
config.before(:each) do
|
24
|
+
drop_dummy_database
|
25
|
+
remove_project_directory
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module SuspendersTestHelpers
|
2
|
+
APP_NAME = 'dummy'
|
3
|
+
|
4
|
+
def remove_project_directory
|
5
|
+
FileUtils.rm_rf(project_path)
|
6
|
+
end
|
7
|
+
|
8
|
+
def create_tmp_directory
|
9
|
+
FileUtils.mkdir_p(tmp_path)
|
10
|
+
end
|
11
|
+
|
12
|
+
def run_suspenders(arguments = nil)
|
13
|
+
Dir.chdir(tmp_path) do
|
14
|
+
Bundler.with_clean_env do
|
15
|
+
ENV['TESTING'] = '1'
|
16
|
+
ENV['DISABLE_SPRING'] = '1'
|
17
|
+
|
18
|
+
%x(#{suspenders_bin} #{APP_NAME} #{arguments})
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def drop_dummy_database
|
24
|
+
if File.exists?(project_path)
|
25
|
+
Dir.chdir(project_path) do
|
26
|
+
Bundler.with_clean_env do
|
27
|
+
`rake db:drop`
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def project_path
|
34
|
+
@project_path ||= Pathname.new("#{tmp_path}/#{APP_NAME}")
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def tmp_path
|
40
|
+
@tmp_path ||= Pathname.new("#{root_path}/tmp")
|
41
|
+
end
|
42
|
+
|
43
|
+
def suspenders_bin
|
44
|
+
File.join(root_path, 'bin', 'mj-suspenders')
|
45
|
+
end
|
46
|
+
|
47
|
+
def root_path
|
48
|
+
File.expand_path('../../../', __FILE__)
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
ruby '<%= RUBY_VERSION %>'
|
4
|
+
|
5
|
+
gem 'coffee-rails'
|
6
|
+
gem 'email_validator'
|
7
|
+
gem 'high_voltage'
|
8
|
+
gem 'jquery-rails'
|
9
|
+
gem 'mysql2'
|
10
|
+
gem 'rack-timeout'
|
11
|
+
gem 'rails', '>= 4.0.3'
|
12
|
+
gem 'recipient_interceptor'
|
13
|
+
gem 'sass-rails'
|
14
|
+
gem 'simple_form'
|
15
|
+
gem 'title'
|
16
|
+
gem 'uglifier'
|
17
|
+
gem 'unicorn'
|
18
|
+
|
19
|
+
group :development do
|
20
|
+
gem 'spring'
|
21
|
+
gem 'spring-commands-rspec'
|
22
|
+
end
|
23
|
+
|
24
|
+
group :development, :test do
|
25
|
+
gem 'awesome_print'
|
26
|
+
# gem 'dotenv-rails'
|
27
|
+
gem 'pry-rails'
|
28
|
+
gem 'rspec-rails', '>= 2.14'
|
29
|
+
end
|
30
|
+
|
31
|
+
group :test do
|
32
|
+
# gem 'capybara-webkit', '>= 1.0.0'
|
33
|
+
gem 'database_cleaner'
|
34
|
+
# gem 'launchy'
|
35
|
+
gem 'shoulda-matchers'
|
36
|
+
gem 'simplecov', require: false
|
37
|
+
gem 'timecop'
|
38
|
+
gem 'webmock'
|
39
|
+
end
|
40
|
+
|
41
|
+
group :staging, :production do
|
42
|
+
# gem 'newrelic_rpm', '>= 3.7.3'
|
43
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<%= app_name.humanize %>
|
2
|
+
<%= '=' * app_name.humanize.length %>
|
3
|
+
|
4
|
+
[](https://travis-ci.org/mjacobus/<%= app_name %>)
|
5
|
+
[](https://coveralls.io/r/mjacobus/<%= app_name %>)
|
6
|
+
[](https://codeclimate.com/github/mjacobus/<%= app_name %>)
|
7
|
+
|
8
|
+
Getting Started
|
9
|
+
---------------
|
10
|
+
|
11
|
+
TODO:
|
12
|
+
|
13
|
+
Guidelines
|
14
|
+
----------
|
15
|
+
|
16
|
+
Use the following guides for getting things done, programming well, and
|
17
|
+
programming in style.
|
18
|
+
|
19
|
+
* [Protocol](http://github.com/thoughtbot/guides/blob/master/protocol)
|
20
|
+
* [Best Practices](http://github.com/thoughtbot/guides/blob/master/best-practices)
|
21
|
+
* [Style](http://github.com/thoughtbot/guides/blob/master/style)
|
22
|
+
|
23
|
+
Authors
|
24
|
+
-------
|
25
|
+
|
26
|
+
- [Marcelo Jacobus](https://github.com/mjacobus)
|
27
|
+
|
28
|
+
## Contributing
|
29
|
+
|
30
|
+
1. Fork it
|
31
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
32
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
33
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
34
|
+
5. Create new Pull Request
|
35
|
+
|
36
|
+
** Do not forget to write tests**
|
@@ -0,0 +1,21 @@
|
|
1
|
+
RSpec.configure do |config|
|
2
|
+
config.before(:suite) do
|
3
|
+
DatabaseCleaner.clean_with(:deletion)
|
4
|
+
end
|
5
|
+
|
6
|
+
config.before(:each) do
|
7
|
+
DatabaseCleaner.strategy = :transaction
|
8
|
+
end
|
9
|
+
|
10
|
+
config.before(:each, :js => true) do
|
11
|
+
DatabaseCleaner.strategy = :deletion
|
12
|
+
end
|
13
|
+
|
14
|
+
config.before(:each) do
|
15
|
+
DatabaseCleaner.start
|
16
|
+
end
|
17
|
+
|
18
|
+
config.after(:each) do
|
19
|
+
DatabaseCleaner.clean
|
20
|
+
end
|
21
|
+
end
|
data/templates/errors.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'net/smtp'
|
3
|
+
|
4
|
+
# Example:
|
5
|
+
# begin
|
6
|
+
# some http call
|
7
|
+
# rescue *HTTP_ERRORS => error
|
8
|
+
# notify_hoptoad error
|
9
|
+
# end
|
10
|
+
|
11
|
+
HTTP_ERRORS = [Timeout::Error,
|
12
|
+
Errno::EINVAL,
|
13
|
+
Errno::ECONNRESET,
|
14
|
+
EOFError,
|
15
|
+
Net::HTTPBadResponse,
|
16
|
+
Net::HTTPHeaderSyntaxError,
|
17
|
+
Net::ProtocolError]
|
18
|
+
|
19
|
+
SMTP_SERVER_ERRORS = [TimeoutError,
|
20
|
+
IOError,
|
21
|
+
Net::SMTPUnknownError,
|
22
|
+
Net::SMTPServerBusy,
|
23
|
+
Net::SMTPAuthenticationError]
|
24
|
+
|
25
|
+
SMTP_CLIENT_ERRORS = [Net::SMTPFatalError,
|
26
|
+
Net::SMTPSyntaxError]
|
27
|
+
|
28
|
+
SMTP_ERRORS = SMTP_SERVER_ERRORS + SMTP_CLIENT_ERRORS
|
data/templates/i18n.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
<%= ruby_version_with_patch_level %>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Your secret key is used for verifying the integrity of signed cookies.
|
2
|
+
# If you change this key, all old signed cookies will become invalid!
|
3
|
+
|
4
|
+
# Make sure the secret is at least 30 characters and all random,
|
5
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
6
|
+
# You can use `rake secret` to generate a secure secret key.
|
7
|
+
|
8
|
+
# Make sure your secret_key_base is kept private
|
9
|
+
# if you're sharing your code publicly.
|
10
|
+
<%= app_const %>.config.secret_key_base = ENV['SECRET_KEY_BASE']
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
SimpleCov.start 'rails'
|
3
|
+
|
4
|
+
ENV['RAILS_ENV'] = 'test'
|
5
|
+
|
6
|
+
require File.expand_path('../../config/environment', __FILE__)
|
7
|
+
|
8
|
+
require 'rspec/rails'
|
9
|
+
require 'webmock/rspec'
|
10
|
+
|
11
|
+
Dir[Rails.root.join('spec/support/**/*.rb')].each { |file| require file }
|
12
|
+
|
13
|
+
module Features
|
14
|
+
# Extend this module in spec/support/features/*.rb
|
15
|
+
end
|
16
|
+
|
17
|
+
RSpec.configure do |config|
|
18
|
+
config.expect_with :rspec do |c|
|
19
|
+
c.syntax = :expect
|
20
|
+
end
|
21
|
+
|
22
|
+
config.include Features, type: :feature
|
23
|
+
config.infer_base_class_for_anonymous_controllers = false
|
24
|
+
config.order = 'random'
|
25
|
+
config.use_transactional_fixtures = false
|
26
|
+
end
|
27
|
+
|
28
|
+
# Capybara.javascript_driver = :webkit
|
29
|
+
WebMock.disable_net_connect!(allow_localhost: true)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8" />
|
5
|
+
<meta name="ROBOTS" content="NOODP" />
|
6
|
+
<title><%%= title %></title>
|
7
|
+
<%%= stylesheet_link_tag :application, :media => 'all' %>
|
8
|
+
<%%= csrf_meta_tags %>
|
9
|
+
</head>
|
10
|
+
<body class="<%%= body_class %>">
|
11
|
+
<%%= render 'flashes' -%>
|
12
|
+
<%%= yield %>
|
13
|
+
<%%= render 'javascript' %>
|
14
|
+
</body>
|
15
|
+
</html>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 1.9.3
|
4
|
+
- 2.0.0
|
5
|
+
- 2.1.0
|
6
|
+
- 2.1.1
|
7
|
+
env:
|
8
|
+
- DB=sqlite
|
9
|
+
- DB=mysql
|
10
|
+
- DB=postgresql
|
11
|
+
script:
|
12
|
+
- RAILS_ENV=test bundle exec rake db:migrate --trace
|
13
|
+
- bundle exec rake db:test:prepare
|
14
|
+
- bundle exec rspec spec/
|
15
|
+
before_script:
|
16
|
+
- mysql -e 'create database <%= app_name %>_test'
|
17
|
+
- psql -c 'create database <%= app_name %>_test' -U postgres
|
18
|
+
branches:
|
19
|
+
only: master
|
20
|
+
notifications:
|
21
|
+
email:
|
22
|
+
on_failure: change
|
23
|
+
on_failure: always
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# https://devcenter.heroku.com/articles/rails-unicorn
|
2
|
+
|
3
|
+
worker_processes (ENV['WEB_CONCURRENCY'] || 3).to_i
|
4
|
+
timeout (ENV['WEB_TIMEOUT'] || 5).to_i
|
5
|
+
preload_app true
|
6
|
+
|
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
|
11
|
+
end
|
12
|
+
|
13
|
+
if defined? ActiveRecord::Base
|
14
|
+
ActiveRecord::Base.connection.disconnect!
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
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'
|
21
|
+
end
|
22
|
+
|
23
|
+
if defined? ActiveRecord::Base
|
24
|
+
config = Rails.application.config.database_configuration[Rails.env]
|
25
|
+
config['reaping_frequency'] = (ENV['DB_REAPING_FREQUENCY'] || 10).to_i
|
26
|
+
config['pool'] = (ENV['DB_POOL'] || 2).to_i
|
27
|
+
ActiveRecord::Base.establish_connection(config)
|
28
|
+
end
|
29
|
+
end
|