re-rails 0.1.0
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 +4 -0
- data/CONTRIBUTING.md +38 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +133 -0
- data/LICENSE +21 -0
- data/README.md +181 -0
- data/Rakefile +13 -0
- data/bin/suspenders +18 -0
- data/lib/suspenders.rb +3 -0
- data/lib/suspenders/actions.rb +35 -0
- data/lib/suspenders/app_builder.rb +323 -0
- data/lib/suspenders/generators/app_generator.rb +199 -0
- data/lib/suspenders/version.rb +3 -0
- data/re-rails.gemspec +32 -0
- data/spec/fakes/bin/heroku +5 -0
- data/spec/fakes/bin/hub +5 -0
- data/spec/features/github_spec.rb +10 -0
- data/spec/features/heroku_spec.rb +12 -0
- data/spec/features/new_project_spec.rb +23 -0
- data/spec/spec_helper.rb +24 -0
- data/spec/support/fake_github.rb +21 -0
- data/spec/support/fake_heroku.rb +30 -0
- data/spec/support/suspenders.rb +50 -0
- data/templates/Gemfile_clean +49 -0
- data/templates/Procfile +2 -0
- data/templates/README.md.erb +25 -0
- data/templates/_flashes.html.erb +5 -0
- data/templates/_javascript.html.erb +10 -0
- data/templates/application.css.scss +8 -0
- data/templates/background_jobs_rspec.rb +19 -0
- data/templates/bin_setup +29 -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/factories_spec.rb +13 -0
- data/templates/factories_spec_rake_task.rb +9 -0
- data/templates/factory_girl_syntax_rspec.rb +3 -0
- data/templates/postgresql_database.yml.erb +11 -0
- data/templates/rack_timeout.rb +1 -0
- data/templates/sample.env +3 -0
- data/templates/secret_token.rb +10 -0
- data/templates/smtp.rb +10 -0
- data/templates/spec_helper.rb +30 -0
- data/templates/staging.rb +3 -0
- data/templates/suspenders_gitignore +13 -0
- data/templates/suspenders_layout.html.erb.erb +15 -0
- data/templates/unicorn.rb +29 -0
- metadata +190 -0
data/re-rails.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
$:.push File.expand_path('../lib', __FILE__)
|
2
|
+
require 'suspenders/version'
|
3
|
+
require 'date'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.required_ruby_version = '>= 1.9.2'
|
7
|
+
s.add_dependency 'bundler', '~> 1.3'
|
8
|
+
s.add_dependency 'rails', '4.0.0'
|
9
|
+
s.add_development_dependency 'aruba', '~> 0.5.2'
|
10
|
+
s.add_development_dependency 'cucumber', '~> 1.2'
|
11
|
+
s.authors = ['thoughtbot', 're-anayltics']
|
12
|
+
s.date = Date.today.strftime('%Y-%m-%d')
|
13
|
+
|
14
|
+
s.description = <<-HERE
|
15
|
+
Base rails application template generator based off suspenders by thoughtbot
|
16
|
+
HERE
|
17
|
+
|
18
|
+
s.email = 'admin@joshburns.cu.cc'
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |file| File.basename(file) }
|
20
|
+
s.extra_rdoc_files = %w[README.md LICENSE]
|
21
|
+
s.files = `git ls-files`.split("\n")
|
22
|
+
s.homepage = 'http://github.com/re-anayltics/re-rails'
|
23
|
+
s.license = 'MIT'
|
24
|
+
s.name = 're-rails'
|
25
|
+
s.rdoc_options = ['--charset=UTF-8']
|
26
|
+
s.require_paths = ['lib']
|
27
|
+
s.summary = "Generate a Rails app using thoughtbot's best practices."
|
28
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
29
|
+
s.version = Suspenders::VERSION
|
30
|
+
s.add_development_dependency 'rspec'
|
31
|
+
s.add_development_dependency 'capybara'
|
32
|
+
end
|
data/spec/fakes/bin/hub
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature 'Heroku' do
|
4
|
+
scenario 'Suspend a project with --heroku=true' do
|
5
|
+
run_suspenders('--heroku=true')
|
6
|
+
|
7
|
+
expect(FakeHeroku).to have_created_app_for('staging')
|
8
|
+
expect(FakeHeroku).to have_created_app_for('production')
|
9
|
+
expect(FakeHeroku).to have_configured_vars('staging', 'SECRET_KEY_BASE')
|
10
|
+
expect(FakeHeroku).to have_configured_vars('production', 'SECRET_KEY_BASE')
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,23 @@
|
|
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
|
+
|
20
|
+
expect(staging_file).to match(/^require_relative 'production'/)
|
21
|
+
expect(staging_file).to match(/#{config_stub}/), staging_file
|
22
|
+
end
|
23
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'capybara/rspec'
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
Bundler.require(:default, :test)
|
5
|
+
|
6
|
+
require (Pathname.new(__FILE__).dirname + '../lib/suspenders').expand_path
|
7
|
+
|
8
|
+
Dir['./spec/support/**/*.rb'].each { |file| require file }
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.include SuspendersTestHelpers
|
12
|
+
|
13
|
+
config.before(:all) do
|
14
|
+
create_tmp_directory
|
15
|
+
end
|
16
|
+
|
17
|
+
config.before(:each) do
|
18
|
+
drop_dummy_database
|
19
|
+
remove_project_directory
|
20
|
+
|
21
|
+
FakeHeroku.clear!
|
22
|
+
FakeGithub.clear!
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class FakeGithub
|
2
|
+
RECORDER = File.expand_path(File.join('..', '..', 'tmp', 'hub_commands'), File.dirname(__FILE__))
|
3
|
+
|
4
|
+
def initialize(args)
|
5
|
+
@args = args
|
6
|
+
end
|
7
|
+
|
8
|
+
def run!
|
9
|
+
File.open(RECORDER, 'a') do |file|
|
10
|
+
file.write @args.join(' ')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.clear!
|
15
|
+
FileUtils.rm_rf RECORDER
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.has_created_repo?(repo_name)
|
19
|
+
File.read(RECORDER) == "create #{repo_name}"
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class FakeHeroku
|
2
|
+
RECORDER = File.expand_path(File.join('..', '..', 'tmp', 'heroku_commands'), File.dirname(__FILE__))
|
3
|
+
|
4
|
+
def initialize(args)
|
5
|
+
@args = args
|
6
|
+
end
|
7
|
+
|
8
|
+
def run!
|
9
|
+
File.open(RECORDER, 'a') do |file|
|
10
|
+
file.puts @args.join(' ')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.clear!
|
15
|
+
FileUtils.rm_rf RECORDER
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.has_created_app_for?(remote_name)
|
19
|
+
app_name = "#{SuspendersTestHelpers::APP_NAME}-#{remote_name}"
|
20
|
+
expected_line = "create #{app_name} --remote=#{remote_name}\n"
|
21
|
+
|
22
|
+
File.foreach(RECORDER).any? { |line| line == expected_line }
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.has_configured_vars?(remote_name, var)
|
26
|
+
File.foreach(RECORDER).any? do |line|
|
27
|
+
line =~ /^config:add #{var}=.+ --remote=#{remote_name}\n$/
|
28
|
+
end
|
29
|
+
end
|
30
|
+
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', 'suspenders')
|
45
|
+
end
|
46
|
+
|
47
|
+
def root_path
|
48
|
+
File.expand_path('../../../', __FILE__)
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem 'bourbon'
|
4
|
+
gem 'coffee-rails'
|
5
|
+
gem 'delayed_job_active_record', '>= 4.0.0'
|
6
|
+
gem 'email_validator'
|
7
|
+
gem 'flutie'
|
8
|
+
gem 'high_voltage'
|
9
|
+
gem 'jquery-rails'
|
10
|
+
gem 'neat'
|
11
|
+
gem 'pg'
|
12
|
+
gem 'rack-timeout'
|
13
|
+
gem 'rails', '>= 4.0.0'
|
14
|
+
gem 'recipient_interceptor'
|
15
|
+
gem 'sass-rails'
|
16
|
+
gem 'simple_form'
|
17
|
+
gem 'uglifier'
|
18
|
+
gem 'unicorn'
|
19
|
+
gem 'cancan'
|
20
|
+
gem 'devise'
|
21
|
+
|
22
|
+
group :development do
|
23
|
+
gem 'better_errors'
|
24
|
+
gem 'binding_of_caller'
|
25
|
+
gem 'foreman'
|
26
|
+
gem 'spring'
|
27
|
+
gem 'spring-commands-rspec'
|
28
|
+
end
|
29
|
+
|
30
|
+
group :development, :test do
|
31
|
+
gem 'dotenv-rails'
|
32
|
+
gem 'factory_girl_rails'
|
33
|
+
gem 'pry-rails'
|
34
|
+
gem 'rspec-rails', '>= 2.14'
|
35
|
+
end
|
36
|
+
|
37
|
+
group :test do
|
38
|
+
gem 'capybara-webkit', '>= 1.0.0'
|
39
|
+
gem 'database_cleaner'
|
40
|
+
gem 'launchy'
|
41
|
+
gem 'shoulda-matchers'
|
42
|
+
gem 'simplecov', require: false
|
43
|
+
gem 'timecop'
|
44
|
+
gem 'webmock'
|
45
|
+
end
|
46
|
+
|
47
|
+
group :staging, :production do
|
48
|
+
gem 'rails_12factor'
|
49
|
+
end
|
data/templates/Procfile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
<%= app_name.humanize %>
|
2
|
+
<%= '=' * app_name.humanize.length %>
|
3
|
+
|
4
|
+
Getting Started
|
5
|
+
---------------
|
6
|
+
|
7
|
+
This repository comes equipped with a self-setup script!
|
8
|
+
|
9
|
+
% ./bin/setup
|
10
|
+
|
11
|
+
After setting up, you can run the application using [foreman]:
|
12
|
+
|
13
|
+
% foreman start
|
14
|
+
|
15
|
+
[foreman]: http://ddollar.github.io/foreman/
|
16
|
+
|
17
|
+
Guidelines
|
18
|
+
----------
|
19
|
+
|
20
|
+
Use the following guides for getting things done, programming well, and
|
21
|
+
programming in style.
|
22
|
+
|
23
|
+
* [Protocol](http://github.com/thoughtbot/guides/blob/master/protocol)
|
24
|
+
* [Best Practices](http://github.com/thoughtbot/guides/blob/master/best-practices)
|
25
|
+
* [Style](http://github.com/thoughtbot/guides/blob/master/style)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module BackgroundJobs
|
2
|
+
def run_background_jobs_immediately
|
3
|
+
delay_jobs = Delayed::Worker.delay_jobs
|
4
|
+
Delayed::Worker.delay_jobs = false
|
5
|
+
yield
|
6
|
+
ensure
|
7
|
+
Delayed::Worker.delay_jobs = delay_jobs
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.around(:each, type: :feature) do |example|
|
13
|
+
run_background_jobs_immediately do
|
14
|
+
example.run
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
config.include BackgroundJobs
|
19
|
+
end
|
data/templates/bin_setup
ADDED
@@ -0,0 +1,29 @@
|
|
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 install
|
11
|
+
|
12
|
+
# Set up the database
|
13
|
+
bundle exec rake db:setup
|
14
|
+
|
15
|
+
# Set up configurable environment variables
|
16
|
+
if [ ! -f .env ]; then
|
17
|
+
cp .sample.env .env
|
18
|
+
fi
|
19
|
+
|
20
|
+
# Pick a port for Foreman
|
21
|
+
echo "port: 7000" > .foreman
|
22
|
+
|
23
|
+
# Set up DNS via Pow
|
24
|
+
if [ -d ~/.pow ]
|
25
|
+
then
|
26
|
+
echo 7000 > ~/.pow/`basename $PWD`
|
27
|
+
else
|
28
|
+
echo "Pow not set up but the team uses it for this project. Setup: http://goo.gl/RaDPO"
|
29
|
+
fi
|
@@ -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
|