voyage 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.
Files changed (93) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +5 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +11 -0
  5. data/CONTRIBUTING.md +54 -0
  6. data/Gemfile +3 -0
  7. data/LICENSE +21 -0
  8. data/NEWS.md +510 -0
  9. data/README.md +233 -0
  10. data/RELEASING.md +19 -0
  11. data/Rakefile +8 -0
  12. data/USAGE +13 -0
  13. data/bin/rake +16 -0
  14. data/bin/rspec +16 -0
  15. data/bin/setup +13 -0
  16. data/bin/suspenders +23 -0
  17. data/bin/voyage +20 -0
  18. data/lib/suspenders.rb +6 -0
  19. data/lib/suspenders/actions.rb +33 -0
  20. data/lib/suspenders/adapters/heroku.rb +127 -0
  21. data/lib/suspenders/app_builder.rb +486 -0
  22. data/lib/suspenders/generators/app_generator.rb +287 -0
  23. data/lib/suspenders/generators/static_generator.rb +9 -0
  24. data/lib/suspenders/version.rb +8 -0
  25. data/lib/voyage.rb +9 -0
  26. data/lib/voyage/app_builder.rb +469 -0
  27. data/lib/voyage/generators/app_generator.rb +118 -0
  28. data/lib/voyage/templates/Gemfile.erb +118 -0
  29. data/lib/voyage/templates/README.md.erb +28 -0
  30. data/lib/voyage/templates/about.html.erb +1 -0
  31. data/lib/voyage/templates/application.js +19 -0
  32. data/lib/voyage/templates/config_locales_en.yml.erb +25 -0
  33. data/lib/voyage/templates/controller_helpers.rb +14 -0
  34. data/lib/voyage/templates/custom_cancan_matchers.rb +54 -0
  35. data/lib/voyage/templates/rails_helper.rb.erb +99 -0
  36. data/lib/voyage/templates/seeder.rb.erb +46 -0
  37. data/lib/voyage/templates/seeds.rb.erb +50 -0
  38. data/lib/voyage/templates/simplecov.rb +31 -0
  39. data/lib/voyage/templates/users_index.html.slim.erb +25 -0
  40. data/lib/voyage/templates/welcome.html.erb +11 -0
  41. data/lib/voyage/version.rb +8 -0
  42. data/spec/adapters/heroku_spec.rb +57 -0
  43. data/spec/fakes/bin/heroku +5 -0
  44. data/spec/fakes/bin/hub +5 -0
  45. data/spec/features/cli_help_spec.rb +36 -0
  46. data/spec/features/github_spec.rb +16 -0
  47. data/spec/features/heroku_spec.rb +75 -0
  48. data/spec/features/new_project_spec.rb +270 -0
  49. data/spec/spec_helper.rb +20 -0
  50. data/spec/support/fake_github.rb +21 -0
  51. data/spec/support/fake_heroku.rb +53 -0
  52. data/spec/support/suspenders.rb +83 -0
  53. data/suspenders.gemspec +34 -0
  54. data/templates/Gemfile.erb +64 -0
  55. data/templates/Procfile +2 -0
  56. data/templates/README.md.erb +28 -0
  57. data/templates/_analytics.html.erb +7 -0
  58. data/templates/_css_overrides.html.erb +7 -0
  59. data/templates/_flashes.html.erb +7 -0
  60. data/templates/_javascript.html.erb +12 -0
  61. data/templates/action_mailer.rb +5 -0
  62. data/templates/app.json.erb +42 -0
  63. data/templates/application.scss +9 -0
  64. data/templates/bin_deploy +12 -0
  65. data/templates/bin_setup +21 -0
  66. data/templates/bin_setup_review_app.erb +19 -0
  67. data/templates/browserslist +3 -0
  68. data/templates/bundler_audit.rake +12 -0
  69. data/templates/capybara_webkit.rb +5 -0
  70. data/templates/circle.yml.erb +6 -0
  71. data/templates/config_locales_en.yml.erb +19 -0
  72. data/templates/database_cleaner_rspec.rb +21 -0
  73. data/templates/dev.rake +12 -0
  74. data/templates/dotfiles/.ctags +2 -0
  75. data/templates/dotfiles/.env +13 -0
  76. data/templates/errors.rb +34 -0
  77. data/templates/factories.rb +2 -0
  78. data/templates/factory_girl_rspec.rb +3 -0
  79. data/templates/flashes_helper.rb +5 -0
  80. data/templates/hound.yml +14 -0
  81. data/templates/i18n.rb +3 -0
  82. data/templates/json_encoding.rb +1 -0
  83. data/templates/postgresql_database.yml.erb +21 -0
  84. data/templates/puma.rb +28 -0
  85. data/templates/rack_mini_profiler.rb +5 -0
  86. data/templates/rails_helper.rb +22 -0
  87. data/templates/secrets.yml +14 -0
  88. data/templates/shoulda_matchers_config_rspec.rb +6 -0
  89. data/templates/smtp.rb +13 -0
  90. data/templates/spec_helper.rb +29 -0
  91. data/templates/suspenders_gitignore +13 -0
  92. data/templates/suspenders_layout.html.erb.erb +22 -0
  93. metadata +207 -0
@@ -0,0 +1,118 @@
1
+ module Suspenders
2
+ class AppGenerator < Rails::Generators::AppGenerator
3
+ class_option :skip_turbolinks, type: :boolean, default: false,
4
+ desc: "Skip turbolinks gem"
5
+
6
+ class_option :skip_bundle, type: :boolean, aliases: "-B", default: true,
7
+ desc: "Don't run bundle install"
8
+
9
+ def self.start
10
+ preflight_check
11
+ accept_defaults
12
+
13
+ super
14
+ end
15
+
16
+ def self.preflight_check
17
+ puts '"bundle install" will be run for the current ruby version and gemset. Press enter to continue...'
18
+ prompt = STDIN.gets.chomp
19
+
20
+ unless prompt.empty?
21
+ puts "Skipping install. Please create a ruby gemset first!"
22
+ exit 1
23
+ end
24
+ end
25
+
26
+ def self.accept_defaults
27
+ Suspenders::AppBuilder.new.accept_defaults
28
+ end
29
+
30
+ def finish_template
31
+ invoke :suspenders_customization
32
+ invoke :use_slim
33
+ invoke :install_devise
34
+ invoke :customize_application_js
35
+ invoke :require_files_in_lib
36
+ invoke :generate_ruby_version_and_gemset
37
+ invoke :generate_data_migrations
38
+ invoke :add_high_voltage_static_pages
39
+ invoke :generate_refills
40
+ invoke :generate_test_environment
41
+ invoke :update_test_environment
42
+
43
+
44
+ # Do these last
45
+ invoke :rake_db_setup
46
+ invoke :configure_rvm_prepend_bin_to_path
47
+ invoke :actually_setup_spring
48
+ invoke :bon_voyage
49
+ super
50
+ end
51
+
52
+ def use_slim
53
+ build :use_slim
54
+ end
55
+
56
+ def install_devise
57
+ build :install_devise
58
+ end
59
+
60
+ def customize_application_js
61
+ build :customize_application_js
62
+ end
63
+
64
+ def require_files_in_lib
65
+ build :require_files_in_lib
66
+ end
67
+
68
+ def generate_ruby_version_and_gemset
69
+ build :generate_ruby_version_and_gemset
70
+ end
71
+
72
+ def generate_data_migrations
73
+ build :generate_data_migrations
74
+ end
75
+
76
+ def add_high_voltage_static_pages
77
+ build :add_high_voltage_static_pages
78
+ end
79
+
80
+ def generate_refills
81
+ build :generate_refills
82
+ end
83
+
84
+ def generate_test_environment
85
+ build :generate_test_environment
86
+ end
87
+
88
+ def update_test_environment
89
+ build :update_test_environment
90
+ end
91
+
92
+ def rake_db_setup
93
+ build :rake_db_setup
94
+ end
95
+
96
+ def configure_rvm_prepend_bin_to_path
97
+ build :configure_rvm_prepend_bin_to_path
98
+ end
99
+
100
+ def setup_spring
101
+ # do nothing so we can run generators after suspenders_customization runs
102
+ end
103
+
104
+ def actually_setup_spring
105
+ say "Springifying binstubs"
106
+ build :setup_spring
107
+ end
108
+
109
+ def outro
110
+ # need this to be nothing so it doesn't output any text when
111
+ # :suspenders_customization runs and it invokes this method
112
+ end
113
+
114
+ def bon_voyage
115
+ say 'Congratulations! You just pulled our suspenders, Headway style!'
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,118 @@
1
+ # rubocop:disable Metrics/LineLength
2
+ source "https://rubygems.org"
3
+
4
+ ruby "<%= Voyage::RUBY_VERSION %>"
5
+ #ruby-gemset=<%= @app_name %>
6
+
7
+ gem "autoprefixer-rails"
8
+ gem "bourbon", "~> 4.2.0"
9
+ gem "coffee-rails", "~> 4.1.0"
10
+ gem "delayed_job_active_record"
11
+ gem "flutie"
12
+ gem "high_voltage"
13
+ gem "jquery-rails"
14
+ gem "neat", "~> 1.7.0"
15
+ gem "normalize-rails", "~> 3.0.0"
16
+ gem "pg"
17
+ gem "rack-canonical-host"
18
+ gem "rails", "<%= Voyage::RAILS_VERSION %>"
19
+ gem "recipient_interceptor"
20
+ gem "sass-rails", "~> 5.0"
21
+ gem "simple_form"
22
+ gem "title"
23
+ gem "uglifier"
24
+
25
+ # Customizations
26
+ gem 'responders' # respond to json/html/js more easily in controllers
27
+ gem 'slim-rails' # templating
28
+ gem 'font-awesome-rails'
29
+ gem 'dynamic_form' # for custom messages without the database column
30
+ gem 'nested_form_fields' # Dynamically add and remove nested has_many association fields in a Ruby on Rails form
31
+ gem 'devise'
32
+
33
+ gem 'turbolinks'
34
+ gem 'jquery-turbolinks'
35
+ gem 'jquery-ui-rails'
36
+ gem 'nprogress-rails' # Show request progress when a link is clicked
37
+ gem 'gon' # pass variables betwween rails and javascript. Several examples in the application_controller.rb
38
+
39
+ gem 'cancancan' # authorization library
40
+ gem 'canard', git: 'https://github.com/james2m/canard.git' # ties into cancancan, adds roles for the user
41
+
42
+ gem 'friendly_id' # slugs in the url auto-generated
43
+ gem 'paper_trail'
44
+ gem 'settingslogic' # yaml settings (project wide, non-editable), this is implemented with the model Settings.rb
45
+
46
+ # Want these here for debugging on production
47
+ gem 'pry-rails' # better REPL than irb
48
+ gem 'pry-awesome_print'
49
+ gem 'pry-byebug'
50
+ gem 'pry-remote'
51
+
52
+ gem 'librato-rails' # general monitoring of things
53
+ gem 'nondestructive_migrations'
54
+ gem 'carrierwave'
55
+ gem 'mini_magick'
56
+ gem 'fog'
57
+ gem 'whenever', require: false # provides a clear syntax for writing and deploying cron jobs
58
+ gem 'whenever-web'
59
+
60
+ group :development do
61
+ gem "quiet_assets"
62
+ gem "refills"
63
+ gem "spring"
64
+ gem "spring-commands-rspec"
65
+ gem "web-console"
66
+
67
+ # Customizations
68
+ gem 'annotate' # annotate models automatically when rake db:migrate is called
69
+ gem 'rails-erd' # auto gen ERD Diagram of models in the app on rake db:migrate
70
+ gem 'zenflow', github: 'zencoder/zenflow'
71
+ gem 'better_errors' # A better error page for rails when a local 500 (or similar) is thrown
72
+ gem 'binding_of_caller' # REPL in better_errors to debug in the browser at the point at which it failed
73
+ gem 'meta_request' # for chrome rails console plugin found here: https://chrome.google.com/webstore/detail/railspanel/gjpfobpafnhjhbajcjgccbbdofdckggg?hl=en-US
74
+ gem 'bitters', '~> 1.2'
75
+ gem 'redcarpet' # used to render the readme inside a static welcome page from the high_voltage gem
76
+ end
77
+
78
+ group :development, :test do
79
+ gem "awesome_print"
80
+ gem "bullet"
81
+ gem "bundler-audit", require: false
82
+ gem "dotenv-rails"
83
+ gem "factory_girl_rails"
84
+ gem "rspec-rails", "~> 3.4.0"
85
+
86
+ # Customizations
87
+ gem 'faker' # provides auto generated names for factories, can be customized
88
+
89
+ gem 'rubocop', '0.36.0', require: false # lock to keep in sync with Hound
90
+ gem 'rubocop-rspec', require: false
91
+
92
+ gem 'letter_opener' # auto-open emails when they're sent
93
+ end
94
+
95
+ group :development, :staging do
96
+ gem "rack-mini-profiler", require: false
97
+ end
98
+
99
+ group :test do
100
+ gem "database_cleaner"
101
+ gem "formulaic"
102
+ gem "launchy"
103
+ gem "shoulda-matchers"
104
+ gem "simplecov", require: false
105
+ gem "timecop"
106
+ gem "webmock"
107
+
108
+ # Customizations
109
+ gem 'cadre' # highlights code coverage in vim
110
+
111
+ gem 'capybara'
112
+ gem 'poltergeist'
113
+ gem 'selenium-webdriver' # brew install chromedriver
114
+ end
115
+
116
+ group :staging, :production do
117
+ gem "rack-timeout"
118
+ end
@@ -0,0 +1,28 @@
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 [Heroku Local]:
16
+
17
+ % heroku local
18
+
19
+ [Heroku Local]: https://devcenter.heroku.com/articles/heroku-local
20
+
21
+ ## Guidelines
22
+
23
+ Use the following guides for getting things done, programming well, and
24
+ programming in style.
25
+
26
+ * [Protocol](http://github.com/thoughtbot/guides/blob/master/protocol)
27
+ * [Best Practices](http://github.com/thoughtbot/guides/blob/master/best-practices)
28
+ * [Style](http://github.com/thoughtbot/guides/blob/master/style)
@@ -0,0 +1 @@
1
+ <h1>Customize me, please!</h1>
@@ -0,0 +1,19 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require jquery
14
+ //= require jquery.turbolinks
15
+ //= require jquery_ujs
16
+ //
17
+ // ... your other scripts here ...
18
+ //
19
+ //= require turbolinks
@@ -0,0 +1,25 @@
1
+ en:
2
+ date:
3
+ formats:
4
+ default:
5
+ '%m/%d/%Y'
6
+ short:
7
+ '%m/%d/%y'
8
+ with_weekday:
9
+ '%a %m/%d/%y'
10
+
11
+ time:
12
+ formats:
13
+ default:
14
+ '%a, %b %-d, %Y at %r'
15
+ date:
16
+ '%b %-d, %Y'
17
+ short:
18
+ '%B %d'
19
+ time_with_period:
20
+ '%-l:%M %p'
21
+ date_and_time_with_period:
22
+ '%m/%d/%Y - %-l:%M %p'
23
+
24
+ titles:
25
+ application: <%= app_name.humanize %>
@@ -0,0 +1,14 @@
1
+ module ControllerHelpers
2
+ def sign_in(user = double('user'))
3
+ if user.nil?
4
+ allow(request.env['warden'])
5
+ .to receive(:authenticate!)
6
+ .and_throw(:warden, { scope: :user })
7
+
8
+ allow(controller).to receive(:current_user).and_return(nil)
9
+ else
10
+ allow(request.env['warden']).to receive(:authenticate!).and_return(user)
11
+ allow(controller).to receive(:current_user).and_return(user)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,54 @@
1
+ rspec_module = defined?(RSpec::Core) ? 'RSpec' : 'Spec' # RSpec 1 compatability
2
+
3
+ if rspec_module == 'RSpec'
4
+ require 'rspec/core'
5
+ require 'rspec/expectations'
6
+ else
7
+ ActiveSupport::Deprecation
8
+ .warn('RSpec < 3 will not be supported in the CanCanCan >= 2.0.0')
9
+ end
10
+
11
+ # Allow passing args like
12
+ #
13
+ # be_able_to :read, thing
14
+ #
15
+ # or
16
+ #
17
+ # be_able_to [:read, :update], thing
18
+ #
19
+ Kernel.const_get(rspec_module)::Matchers.define :be_able_to do |*args|
20
+ match do |ability|
21
+ actions = Array.wrap(args[0])
22
+ actions.all? { |action| ability.can?(action, *args[1..-1]) }
23
+ end
24
+
25
+ # Check that RSpec is < 2.99
26
+ if !respond_to?(:failure_message) && respond_to?(:failure_message_for_should)
27
+ alias :failure_message :failure_message_for_should
28
+ alias :failure_message_when_negated :failure_message_for_should_not
29
+ end
30
+
31
+ failure_message do
32
+ resource = args[1]
33
+ if resource.instance_of?(Class)
34
+ "expected to be able to #{args.map(&:to_s).join(' ')}"
35
+ else
36
+ "expected to be able to #{args.map(&:inspect).join(' ')}"
37
+ end
38
+ end
39
+
40
+ failure_message_when_negated do
41
+ resource = args[1]
42
+ if resource.instance_of?(Class)
43
+ "expected not to be able to #{args.map(&:to_s).join(' ')}"
44
+ else
45
+ "expected not to be able to #{args.map(&:inspect).join(' ')}"
46
+ end
47
+ end
48
+
49
+ description do
50
+ action = args[0].to_s
51
+ resource = args[1].class.name
52
+ "be able to #{action} #{resource}"
53
+ end
54
+ end
@@ -0,0 +1,99 @@
1
+ require 'simplecov'
2
+ SimpleCov.command_name 'Rspec'
3
+
4
+ ENV["RAILS_ENV"] = "test"
5
+
6
+ require File.expand_path("../../config/environment", __FILE__)
7
+ abort("DATABASE_URL environment variable is set") if ENV["DATABASE_URL"]
8
+
9
+ require 'spec_helper'
10
+ require "rspec/rails"
11
+ require 'factory_girl'
12
+ require 'capybara/rspec'
13
+ require 'capybara/poltergeist'
14
+ require 'shoulda/matchers'
15
+ require 'database_cleaner'
16
+ require 'cadre/rspec3'
17
+ # require 'sidekiq/testing'
18
+ # require 'paperclip/matchers'
19
+
20
+ # Checks for pending migrations before tests are run.
21
+ # If you are not using ActiveRecord, you can remove this line.
22
+ ActiveRecord::Migration.maintain_test_schema!
23
+
24
+ # Requires supporting ruby files with custom matchers and macros, etc,
25
+ # in spec/support/ and its subdirectories.
26
+ Dir[Rails.root.join("spec/support/**/*.rb")].sort.each { |file| require file }
27
+
28
+ module Features
29
+ # Extend this module in spec/support/features/*.rb
30
+ include Formulaic::Dsl
31
+ end
32
+
33
+ RSpec.configure do |config|
34
+ config.include Features, type: :feature # not sure what this does: https://github.com/thoughtbot/suspenders/issues/142
35
+ config.infer_base_class_for_anonymous_controllers = false # not sure what this does: https://www.relishapp.com/rspec/rspec-rails/docs/controller-specs/anonymous-controller
36
+
37
+ config.use_transactional_fixtures = false
38
+
39
+ config.include Devise::TestHelpers, type: :controller
40
+ config.include ControllerHelpers, type: :controller
41
+ # config.include Paperclip::Shoulda::Matchers
42
+
43
+ Capybara.javascript_driver = :poltergeist
44
+ Capybara.asset_host = 'http://localhost:3000'
45
+
46
+ # Can be used by passing driver: :selenium_chrome to a test
47
+ Capybara.register_driver :selenium_chrome do |app|
48
+ Capybara::Selenium::Driver.new(app, browser: :chrome)
49
+ end
50
+
51
+ config.after(:each) do
52
+ Capybara.current_driver = Capybara.default_driver
53
+ end
54
+
55
+ config.before(:each) do |spec|
56
+ Capybara.current_driver = :selenium_chrome if spec.metadata[:browser]
57
+
58
+ # Sidekiq::Testing.fake!
59
+ # # This runs jobs immediately in the same thread
60
+ # Sidekiq::Testing.inline! if spec.metadata[:inline]
61
+ end
62
+
63
+ config.before(:suite) do
64
+ # Load seed data to bootstrap the app with things the real app will have at
65
+ # launch like States, roles, etc.
66
+ require_relative '../lib/seeder'
67
+ require 'rake'
68
+ <%= "#{app_name.camelize}::Application.load_tasks" %>
69
+ Rake::Task['db:seed'].invoke
70
+ end
71
+
72
+ config.after(:each) do
73
+ if Rails.env.test? || Rails.env.cucumber?
74
+ FileUtils.rm_rf(Dir["#{Rails.root}/spec/support/uploads"])
75
+ end
76
+ end
77
+
78
+ # Cadre (code coverage)
79
+ config.add_formatter(Cadre::RSpec3::NotifyOnCompleteFormatter)
80
+ config.add_formatter(Cadre::RSpec3::QuickfixFormatter)
81
+ end
82
+
83
+ # RSpec::Sidekiq.configure do |config|
84
+ # # Clears all job queues before each example
85
+ # config.clear_all_enqueued_jobs = true # default => true
86
+
87
+ # # Whether to use terminal colours when outputting messages
88
+ # config.enable_terminal_colours = true # default => true
89
+
90
+ # # Warn when jobs are not enqueued to Redis but to a job array
91
+ # config.warn_when_jobs_not_processed_by_sidekiq = true # default => true
92
+ # end
93
+
94
+ Shoulda::Matchers.configure do |config|
95
+ config.integrate do |with|
96
+ with.test_framework :rspec
97
+ with.library :rails
98
+ end
99
+ end