roboparts 0.0.1 → 0.5.2

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 (46) hide show
  1. checksums.yaml +4 -4
  2. data/.DS_Store +0 -0
  3. data/.ruby-version +1 -0
  4. data/Gemfile +3 -0
  5. data/Gemfile.lock +108 -0
  6. data/LICENSE.md +21 -0
  7. data/README.md +74 -0
  8. data/bin/rake +16 -0
  9. data/bin/roboparts +13 -0
  10. data/bin/rspec +16 -0
  11. data/bin/setup +13 -0
  12. data/lib/roboparts.rb +4 -0
  13. data/lib/roboparts/actions.rb +25 -0
  14. data/lib/roboparts/app_builder.rb +352 -0
  15. data/lib/roboparts/generators/app_generator.rb +179 -0
  16. data/lib/roboparts/version.rb +5 -0
  17. data/roboparts.gemspec +29 -0
  18. data/templates/Gemfile.erb +38 -0
  19. data/templates/_analytics.html.erb +12 -0
  20. data/templates/_flashes.html.erb +7 -0
  21. data/templates/_javascript.html.erb +12 -0
  22. data/templates/action_mailer.rb +5 -0
  23. data/templates/application.css.scss +7 -0
  24. data/templates/background_jobs_rspec.rb +19 -0
  25. data/templates/bin_setup.erb +31 -0
  26. data/templates/bundler_audit.rake +12 -0
  27. data/templates/config_i18n_tasks.yml +13 -0
  28. data/templates/config_locales_en.yml.erb +17 -0
  29. data/templates/database_cleaner_rspec.rb +21 -0
  30. data/templates/development_seeds.rb +12 -0
  31. data/templates/disable_xml_params.rb +3 -0
  32. data/templates/errors.rb +34 -0
  33. data/templates/factory_girl_rspec.rb +3 -0
  34. data/templates/i18n.rb +3 -0
  35. data/templates/json_encoding.rb +1 -0
  36. data/templates/postgresql_database.yml.erb +12 -0
  37. data/templates/rack_timeout.rb +1 -0
  38. data/templates/rails_helper.rb +23 -0
  39. data/templates/roboparts_gitignore +13 -0
  40. data/templates/roboparts_layout.html.erb.erb +16 -0
  41. data/templates/secrets.yml +14 -0
  42. data/templates/smtp.rb +9 -0
  43. data/templates/spec_helper.rb +15 -0
  44. data/templates/staging.rb +5 -0
  45. data/templates/unicorn.rb +28 -0
  46. metadata +49 -4
@@ -0,0 +1,179 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/rails/app/app_generator'
3
+
4
+ module Roboparts
5
+ class AppGenerator < Rails::Generators::AppGenerator
6
+ class_option :database, :type => :string, :aliases => '-d', :default => 'postgresql', :desc => "Preconfigure for selected database (options: #{DATABASES.join('/')})"
7
+
8
+ class_option :github, :type => :string, :aliases => '-G', :default => nil, :desc => 'Create Github repository and add remote origin pointed to repo'
9
+
10
+ class_option :skip_test_unit, :type => :boolean, :aliases => '-T', :default => true, :desc => 'Skip Test::Unit files'
11
+
12
+ def finish_template
13
+ invoke :roboparts_customization
14
+ super
15
+ end
16
+
17
+ def roboparts_customization
18
+ invoke :customize_gemfile
19
+ invoke :setup_development_environment
20
+ end
21
+
22
+ def customize_gemfile
23
+ build :replace_gemfile
24
+ build :set_ruby_to_version_being_used
25
+
26
+ bundle_command 'install'
27
+ end
28
+
29
+ def setup_development_environment
30
+ say 'Setting up development environment'
31
+ build :raise_on_delivery_errors
32
+ build :raise_on_unpermitted_parameters
33
+ build :provide_setup_script
34
+ build :provide_dev_prime_task
35
+ build :configure_generators
36
+ end
37
+
38
+ def setup_database
39
+ say 'Setting up database'
40
+
41
+ if 'postgresql' == options[:database]
42
+ build :use_postgres_config_template
43
+ end
44
+
45
+ build :create_database
46
+ end
47
+
48
+ def setup_development_environment
49
+ say 'Setting up the development environment'
50
+ build :raise_on_delivery_errors
51
+ build :raise_on_unpermitted_parameters
52
+ build :provide_setup_script
53
+ build :provide_dev_prime_task
54
+ build :configure_generators
55
+ build :configure_i18n_for_missing_translations
56
+ end
57
+
58
+ def setup_test_environment
59
+ say 'Setting up test environment'
60
+ build :setup_factory_girl_for_rspec
61
+ build :generate_rspec
62
+ build :configure_rspec
63
+ build :configure_background_jobs_for_rspec
64
+ build :enable_database_cleaner
65
+ build :configure_spec_support_features
66
+ build :configure_i18n_for_test_environment
67
+ build :configure_i18n_tasks
68
+ build :configure_action_mailer_in_specs
69
+ end
70
+
71
+ def setup_production_environment
72
+ say 'Setting up the production environment'
73
+ build :configure_smtp
74
+ build :enable_rack_deflater
75
+ build :setup_asset_host
76
+ end
77
+
78
+ def setup_staging_environment
79
+ say 'Setting up the staging environment'
80
+ build :setup_staging_environment
81
+ end
82
+
83
+ def setup_secret_token
84
+ say 'Moving secret token out of version control'
85
+ build :setup_secret_token
86
+ end
87
+
88
+ def create_roboparts_views
89
+ say 'Creating roboparts views'
90
+ build :create_partials_directory
91
+ build :create_shared_flashes
92
+ build :create_shared_javascripts
93
+ build :create_application_layout
94
+ end
95
+
96
+ def setup_coffeescript
97
+ say 'Setting up CoffeeScript defaults'
98
+ build :remove_turbolinks
99
+ end
100
+
101
+ def configure_app
102
+ say 'Configuring app'
103
+ build :configure_action_mailer
104
+ build :configure_time_zone
105
+ build :configure_time_formats
106
+ build :configure_rack_timeout
107
+ build :disable_xml_params
108
+ build :fix_i18n_deprecation_warning
109
+ build :setup_default_rake_task
110
+ build :configure_unicorn
111
+ end
112
+
113
+ def setup_stylesheets
114
+ say 'Setting up stylesheets'
115
+ build :setup_stylesheets
116
+ end
117
+
118
+ def setup_git
119
+ if !options[:skip_git]
120
+ say 'Initializing git'
121
+ invoke :setup_gitignore
122
+ invoke :init_git
123
+ end
124
+ end
125
+
126
+ def setup_gitignore
127
+ build :gitignore_files
128
+ end
129
+
130
+ def init_git
131
+ build :init_git
132
+ end
133
+
134
+ def create_github_repo
135
+ if !options[:skip_git] && options[:github]
136
+ say 'Creating GitHub repo'
137
+ build :create_github_repo, options[:github]
138
+ end
139
+ end
140
+
141
+ def setup_google_analytics
142
+ say 'Setting up Google Analytics'
143
+ build :setup_google_analytics
144
+ end
145
+
146
+ def setup_bundler_audit
147
+ say "Setting up bundler-audit"
148
+ build :setup_bundler_audit
149
+ end
150
+
151
+ def copy_miscellaneous_files
152
+ say 'Copying miscellaneous support files'
153
+ build :copy_miscellaneous_files
154
+ end
155
+
156
+ def customize_error_pages
157
+ say 'Customizing the 500/404/422 pages'
158
+ build :customize_error_pages
159
+ end
160
+
161
+ def remove_routes_comment_lines
162
+ build :remove_routes_comment_lines
163
+ end
164
+
165
+ def outro
166
+ say "Nothing more to do... You're all set up!"
167
+ end
168
+
169
+ protected
170
+
171
+ def get_builder_class
172
+ Roboparts::AppBuilder
173
+ end
174
+
175
+ def using_active_record?
176
+ !options[:skip_active_record]
177
+ end
178
+ end
179
+ end
@@ -0,0 +1,5 @@
1
+ module Roboparts
2
+ RAILS_VERSION = "4.1.8"
3
+ RUBY_VERSION = IO.read("#{File.dirname(__FILE__)}/../../.ruby-version").strip
4
+ VERSION = "0.5.2"
5
+ end
data/roboparts.gemspec ADDED
@@ -0,0 +1,29 @@
1
+ $:.push File.expand_path('../lib', __FILE__)
2
+ require 'roboparts/version'
3
+ require 'date'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'roboparts'
7
+ s.date = Date.today.strftime('%Y-%m-%d')
8
+ s.description = <<-RUBY
9
+ Roboparts is a base Rails project that you can upgrade. It is used by SILENTPOST
10
+ to get a jump start on a working app using preferred settings. It is heavily inspired
11
+ by Thoughtbot's Suspenders, but is more tailored to small team development and
12
+ has different preferences.
13
+ RUBY
14
+ s.summary = "A custom Rails project tailored to SILENTPOST's development standards"
15
+ s.authors = ["Daniel Strunk"]
16
+ s.email = 'daniel@silentpost.co'
17
+ s.executables = ['roboparts']
18
+ s.require_paths = ['lib']
19
+ s.files = `git ls-files`.split("\n")
20
+ s.homepage = 'http://silentpost.co/roboparts'
21
+ s.license = 'MIT'
22
+ s.version = Roboparts::VERSION
23
+
24
+ s.add_dependency 'bundler', '~> 1.3'
25
+ s.add_dependency 'rails', Roboparts::RAILS_VERSION
26
+
27
+ s.add_development_dependency 'rspec', '~> 2.0'
28
+ s.add_development_dependency 'capybara', '~> 2.2', '>= 2.2.0'
29
+ end
@@ -0,0 +1,38 @@
1
+ source "https://rubygems.org"
2
+
3
+ ruby "<%= Roboparts::RUBY_VERSION %>"
4
+
5
+ gem "rails", "<%= Roboparts::RAILS_VERSION %>"
6
+ gem "sass-rails"
7
+ gem "coffee-rails"
8
+ gem "jquery-rails"
9
+ gem "uglifier"
10
+
11
+ gem "pg"
12
+
13
+ gem "normalize-rails"
14
+ gem "bourbon"
15
+ gem "neat"
16
+
17
+ gem "delayed_job_active_record"
18
+ gem "simple_form"
19
+ gem "unicorn"
20
+
21
+ gem "devise"
22
+
23
+ group :development do
24
+ gem "spring"
25
+ gem "spring-commands-rspec"
26
+ end
27
+
28
+ group :development, :test do
29
+ gem "bundler-audit", require: false
30
+ gem "dotenv-rails"
31
+ gem "factory_girl_rails"
32
+ gem "rspec-rails"
33
+ end
34
+
35
+ group :test do
36
+ gem "shoulda-matchers"
37
+ gem "timecop"
38
+ end
@@ -0,0 +1,12 @@
1
+ <% if ENV["GOOGLE_ANALYTICS_KEY"] %>
2
+ <script>
3
+ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
4
+ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
5
+ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
6
+ })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
7
+
8
+ ga('create', '<%= ENV["GOOGLE_ANALYTICS_KEY"] %>', 'auto');
9
+ ga('send', 'pageview');
10
+
11
+ </script>
12
+ <% end %>
@@ -0,0 +1,7 @@
1
+ <% if flash.any? %>
2
+ <div id="flash">
3
+ <% flash.each do |key, value| %>
4
+ <div class="flash-<%= key %>"><%= value %></div>
5
+ <% end %>
6
+ </div>
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,7 @@
1
+ @charset 'utf-8';
2
+
3
+ @import 'normalize-rails';
4
+ @import 'bourbon';
5
+ @import 'base/grid-settings';
6
+ @import 'neat';
7
+ @import 'base/base';
@@ -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
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env sh
2
+
3
+ # Set up Rails app. Run this script immediately after cloning the codebase
4
+
5
+ # Exit if any subcommand fails
6
+ set -e
7
+
8
+ # Set up Ruby dependencies via Bundler
9
+ gem list bundler --installed > /dev/null || gem install bundler
10
+ bundle install
11
+
12
+ # Set up configurable environment variables
13
+ if [ ! -f .env ]; then
14
+ cp .sample.env .env
15
+ fi
16
+
17
+ # Set up database and add any development seed data
18
+ bundle exec rake db:setup dev:prime
19
+
20
+ # Add binstubs to PATH via export PATH=".git/safe/../../bin:$PATH"
21
+ mkdir -p .git/safe
22
+
23
+ # Pick a port for Foreman
24
+ if ! grep --quiet --no-messages --fixed-strings 'port' .foreman; then
25
+ printf 'port: <%= config[:port_number] %>\n' >> .foreman
26
+ fi
27
+
28
+ if ! command -v foreman > /dev/null; then
29
+ printf 'Foreman is not installed.\n'
30
+ printf 'See https://github.com/ddollar/foreman for install instructions.\n'
31
+ fi
@@ -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,17 @@
1
+ en:
2
+ date:
3
+ formats:
4
+ default:
5
+ "%m/%d/%Y"
6
+ with_weekday:
7
+ "%a %m/%d/%y"
8
+ time:
9
+ formats:
10
+ default:
11
+ "%a, %b %-d, %Y at %r"
12
+ date:
13
+ "%b %-d, %Y"
14
+ short:
15
+ "%B %d"
16
+ titles:
17
+ 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?
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: "hunter12")
10
+ end
11
+ end
12
+ end