brace 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.
Files changed (65) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -0
  3. data/.ruby-version +1 -0
  4. data/CONTRIBUTING.md +43 -0
  5. data/Gemfile +3 -0
  6. data/Gemfile.lock +139 -0
  7. data/LICENSE +21 -0
  8. data/NEWS.md +351 -0
  9. data/README.md +166 -0
  10. data/Rakefile +8 -0
  11. data/bin/brace +18 -0
  12. data/bin/rake +16 -0
  13. data/bin/rspec +16 -0
  14. data/bin/setup +13 -0
  15. data/brace.gemspec +35 -0
  16. data/lib/brace.rb +4 -0
  17. data/lib/brace/actions.rb +25 -0
  18. data/lib/brace/app_builder.rb +469 -0
  19. data/lib/brace/generators/app_generator.rb +248 -0
  20. data/lib/brace/version.rb +6 -0
  21. data/spec/fakes/bin/heroku +5 -0
  22. data/spec/fakes/bin/hub +5 -0
  23. data/spec/features/github_spec.rb +10 -0
  24. data/spec/features/heroku_spec.rb +40 -0
  25. data/spec/features/new_project_spec.rb +115 -0
  26. data/spec/spec_helper.rb +24 -0
  27. data/spec/support/braces.rb +49 -0
  28. data/spec/support/fake_github.rb +21 -0
  29. data/spec/support/fake_heroku.rb +43 -0
  30. data/templates/Gemfile.erb +88 -0
  31. data/templates/Procfile +2 -0
  32. data/templates/README.md.erb +32 -0
  33. data/templates/_analytics.html.erb +7 -0
  34. data/templates/_javascript.html.erb +12 -0
  35. data/templates/action_mailer.rb +5 -0
  36. data/templates/application.css.scss +8 -0
  37. data/templates/bin_deploy +12 -0
  38. data/templates/bin_setup.erb +36 -0
  39. data/templates/brace_gitignore +14 -0
  40. data/templates/brace_layout.html.slim.erb +15 -0
  41. data/templates/bundler_audit.rake +12 -0
  42. data/templates/config_i18n_tasks.yml +13 -0
  43. data/templates/config_locales_en.yml.erb +19 -0
  44. data/templates/database_cleaner_rspec.rb +21 -0
  45. data/templates/development_seeds.rb +12 -0
  46. data/templates/devise_rspec.rb +3 -0
  47. data/templates/disable_xml_params.rb +3 -0
  48. data/templates/errors.rb +34 -0
  49. data/templates/factory_girl_rspec.rb +3 -0
  50. data/templates/i18n.rb +3 -0
  51. data/templates/json_encoding.rb +1 -0
  52. data/templates/newrelic.yml.erb +34 -0
  53. data/templates/postgresql_database.yml.erb +12 -0
  54. data/templates/rack_timeout.rb +1 -0
  55. data/templates/rails_helper.rb +22 -0
  56. data/templates/redis.rb +10 -0
  57. data/templates/sample.env +5 -0
  58. data/templates/secrets.yml +14 -0
  59. data/templates/sidekiq.rb +7 -0
  60. data/templates/sidekiq_rspec.rb +7 -0
  61. data/templates/smtp.rb +9 -0
  62. data/templates/spec_helper.rb +16 -0
  63. data/templates/stripe.rb +1 -0
  64. data/templates/vcr_helper.rb +12 -0
  65. metadata +197 -0
@@ -0,0 +1,49 @@
1
+ module BraceTestHelpers
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_brace(arguments = nil)
13
+ Dir.chdir(tmp_path) do
14
+ Bundler.with_clean_env do
15
+ ENV['TESTING'] = '1'
16
+
17
+ %x(#{brace_bin} #{APP_NAME} #{arguments})
18
+ end
19
+ end
20
+ end
21
+
22
+ def drop_dummy_database
23
+ if File.exist?(project_path)
24
+ Dir.chdir(project_path) do
25
+ Bundler.with_clean_env do
26
+ `rake db:drop`
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ def project_path
33
+ @project_path ||= Pathname.new("#{tmp_path}/#{APP_NAME}")
34
+ end
35
+
36
+ private
37
+
38
+ def tmp_path
39
+ @tmp_path ||= Pathname.new("#{root_path}/tmp")
40
+ end
41
+
42
+ def brace_bin
43
+ File.join(root_path, 'bin', 'brace')
44
+ end
45
+
46
+ def root_path
47
+ File.expand_path('../../../', __FILE__)
48
+ end
49
+ 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,43 @@
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_gem_included?(project_path, gem_name)
19
+ gemfile = File.open(File.join(project_path, 'Gemfile'), 'a')
20
+
21
+ File.foreach(gemfile).any? do |line|
22
+ line.match(/#{Regexp.quote(gem_name)}/)
23
+ end
24
+ end
25
+
26
+ def self.has_created_app_for?(remote_name, flags = nil)
27
+ app_name = "#{BraceTestHelpers::APP_NAME}-#{remote_name}"
28
+
29
+ expected_line = if flags
30
+ "create #{app_name} #{flags} --remote #{remote_name}\n"
31
+ else
32
+ "create #{app_name} --remote #{remote_name}\n"
33
+ end
34
+
35
+ File.foreach(RECORDER).any? { |line| line == expected_line }
36
+ end
37
+
38
+ def self.has_configured_vars?(remote_name, var)
39
+ File.foreach(RECORDER).any? do |line|
40
+ line =~ /^config:add #{var}=.+ --remote #{remote_name}\n$/
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,88 @@
1
+ source 'https://rubygems.org'
2
+
3
+ ruby '<%= Brace::RUBY_VERSION %>'
4
+
5
+ gem 'rails-api', '~> <%= Brace::RAILS_API_VERSION %>'
6
+
7
+ # Datastores
8
+ gem 'pg'
9
+
10
+ # Sysadmin
11
+ gem 'puma'
12
+ gem 'dotenv-rails'
13
+
14
+ # Asset Pipeline
15
+ gem 'uglifier'
16
+ gem 'therubyracer'
17
+
18
+ # Frontend JS
19
+ gem 'react-rails'
20
+ gem 'jquery-rails'
21
+
22
+ # Frontend HTML/CSS
23
+ gem 'slim-rails'
24
+ gem 'high_voltage'
25
+ gem 'bourbon', '~> 4.1.0'
26
+ gem 'neat', '~> 1.7.0'
27
+ gem 'refills'
28
+ gem 'normalize-rails', '~> 3.0.0'
29
+ gem 'sass-rails', '~> 5.0'
30
+
31
+ # Jobs
32
+ gem 'sidekiq'
33
+ gem 'clockwork'
34
+
35
+ # API
36
+ gem 'responders'
37
+
38
+ # Monitoring
39
+ gem 'rollbar'
40
+ gem 'newrelic_rpm'
41
+
42
+ # i18n
43
+ gem 'i18n-tasks'
44
+ gem 'title'
45
+
46
+ # Network
47
+ gem 'rack-timeout'
48
+
49
+ # Utilities
50
+ gem 'email_validator'
51
+
52
+ # Payments
53
+ gem 'stripe'
54
+
55
+ # Authentication
56
+ gem 'devise'
57
+
58
+ group :development, :test do
59
+ gem 'rspec-rails', '~> 3.1.0'
60
+ gem 'factory_girl_rails'
61
+ gem 'bundler-audit', require: false
62
+ gem 'faker'
63
+ gem 'pry-byebug'
64
+ gem 'pry-rails'
65
+ gem 'awesome_print'
66
+ end
67
+
68
+ group :development do
69
+ gem 'spring'
70
+ gem 'spring-commands-rspec'
71
+ gem 'better_errors'
72
+ gem 'binding_of_caller'
73
+ gem 'quiet_assets'
74
+ gem 'meta_request'
75
+ end
76
+
77
+ group :test do
78
+ gem 'database_cleaner'
79
+ gem 'mock_redis'
80
+ gem 'webmock'
81
+ gem 'vcr'
82
+ gem 'timecop'
83
+ gem 'test_after_commit'
84
+ gem 'shoulda-matchers', require: false
85
+ end
86
+
87
+ group :staging, :production do
88
+ end
@@ -0,0 +1,2 @@
1
+ web: bundle exec puma -p $PORT
2
+ worker: bundle exec sidekiq --concurrency 2 -q default
@@ -0,0 +1,32 @@
1
+ # <%= app_name.humanize %>
2
+
3
+ ## Getting Started
4
+
5
+ After you have cloned this repo, run this setup script to set up your machine
6
+ with the necessary dependencies to run and test this app:
7
+
8
+ % ./bin/setup
9
+
10
+ It assumes you have a machine equipped with Ruby, Postgres, etc. If not, set up
11
+ your machine with [this script].
12
+
13
+ [this script]: https://github.com/thoughtbot/laptop
14
+
15
+ After setting up, you can run the application using [foreman]:
16
+
17
+ % foreman start
18
+
19
+ If you don't have `foreman`, see [Foreman's install instructions][foreman]. It
20
+ is [purposefully excluded from the project's `Gemfile`][exclude].
21
+
22
+ [foreman]: https://github.com/ddollar/foreman
23
+ [exclude]: https://github.com/ddollar/foreman/pull/437#issuecomment-41110407
24
+
25
+ ## Guidelines
26
+
27
+ Use the following guides for getting things done, programming well, and
28
+ programming in style.
29
+
30
+ * [Protocol](http://github.com/thoughtbot/guides/blob/master/protocol)
31
+ * [Best Practices](http://github.com/thoughtbot/guides/blob/master/best-practices)
32
+ * [Style](http://github.com/thoughtbot/guides/blob/master/style)
@@ -0,0 +1,7 @@
1
+ <% if ENV["SEGMENT_IO_KEY"] %>
2
+ <script type="text/javascript">
3
+ window.analytics=window.analytics||[],window.analytics.methods=["identify","group","track","page","pageview","alias","ready","on","once","off","trackLink","trackForm","trackClick","trackSubmit"],window.analytics.factory=function(t){return function(){var a=Array.prototype.slice.call(arguments);return a.unshift(t),window.analytics.push(a),window.analytics}};for(var i=0;i<window.analytics.methods.length;i++){var key=window.analytics.methods[i];window.analytics[key]=window.analytics.factory(key)}window.analytics.load=function(t){if(!document.getElementById("analytics-js")){var a=document.createElement("script");a.type="text/javascript",a.id="analytics-js",a.async=!0,a.src=("https:"===document.location.protocol?"https://":"http://")+"cdn.segment.io/analytics.js/v1/"+t+"/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(a,n)}},window.analytics.SNIPPET_VERSION="2.0.9",
4
+ window.analytics.load("<%= ENV["SEGMENT_IO_KEY"] %>");
5
+ window.analytics.page();
6
+ </script>
7
+ <% end %>
@@ -0,0 +1,12 @@
1
+ <%= javascript_include_tag :application %>
2
+
3
+ <%= yield :javascript %>
4
+
5
+ <%= render "analytics" %>
6
+
7
+ <% if Rails.env.test? %>
8
+ <%= javascript_tag do %>
9
+ $.fx.off = true;
10
+ $.ajaxSetup({ async: false });
11
+ <% end %>
12
+ <% end %>
@@ -0,0 +1,5 @@
1
+ RSpec.configure do |config|
2
+ config.before(:each) do
3
+ ActionMailer::Base.deliveries.clear
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ @charset "utf-8";
2
+
3
+ @import "normalize-rails";
4
+ @import "bourbon";
5
+ @import "base/grid-settings";
6
+ @import "neat";
7
+ @import "base/base";
8
+ @import "refills/flashes";
@@ -0,0 +1,12 @@
1
+ #!/bin/sh
2
+
3
+ # Run this script to deploy the app to Heroku.
4
+
5
+ set -e
6
+
7
+ branch="$(git symbolic-ref HEAD --short)"
8
+ target="${1:-staging}"
9
+
10
+ git push "$target" "$branch:master"
11
+ heroku run rake db:migrate --remote "$target"
12
+ heroku restart --remote "$target"
@@ -0,0 +1,36 @@
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
+ gem install bundler --conservative
11
+ bundle check || 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 db:setup 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 --quiet --no-messages --fixed-strings 'port' .foreman; then
26
+ printf 'port: <%= config[:port_number] %>\n' >> .foreman
27
+ fi
28
+
29
+ if ! command -v foreman > /dev/null; then
30
+ printf 'Foreman is not installed.\n'
31
+ printf 'See https://github.com/ddollar/foreman for install instructions.\n'
32
+ fi
33
+
34
+ # Only if this isn't CI
35
+ # if [ -z "$CI" ]; then
36
+ # fi
@@ -0,0 +1,14 @@
1
+ !.keep
2
+ *.DS_Store
3
+ *.swo
4
+ *.swp
5
+ /.bundle
6
+ /.env
7
+ /.foreman
8
+ /coverage/*
9
+ /db/*.sqlite3
10
+ /log/*
11
+ /public/system
12
+ /public/assets
13
+ /tags
14
+ /tmp/*
@@ -0,0 +1,15 @@
1
+ doctype html
2
+ html
3
+ head
4
+ meta name="ROBOTS" content="NOODP"
5
+ meta name="viewport" content="width=device-width, initial-scale=1.0"
6
+ / Configure default and controller-, and view-specific titles in
7
+ / config/locales/en.yml. For more see:
8
+ / https://github.com/calebthompson/title#usage
9
+ title = title
10
+ = stylesheet_link_tag "application", media: 'all', 'data-turbolinks-track' => true
11
+ = csrf_meta_tags
12
+
13
+ body class=#{body_class}
14
+ = yield
15
+ == render 'javascript'
@@ -0,0 +1,12 @@
1
+ if Rails.env.development? || Rails.env.test?
2
+ require "bundler/audit/cli"
3
+
4
+ namespace :bundler do
5
+ desc "Updates the ruby-advisory-db and runs audit"
6
+ task :audit do
7
+ %w(update check).each do |command|
8
+ Bundler::Audit::CLI.start [command]
9
+ end
10
+ end
11
+ end
12
+ end
@@ -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 %>
@@ -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
@@ -0,0 +1,12 @@
1
+ if Rails.env.development? || Rails.env.test?
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