prop_up 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.
@@ -0,0 +1,212 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/rails/app/app_generator'
3
+
4
+ module Prop
5
+ class AppGenerator < Rails::Generators::AppGenerator
6
+ class_option :database,
7
+ type: :string,
8
+ aliases: '-d',
9
+ default: 'postgresql',
10
+ desc: "Preconfigure for selected database (options: #{DATABASES.join('/')})"
11
+
12
+ class_option :heroku,
13
+ type: :boolean,
14
+ aliases: '-H',
15
+ default: true,
16
+ desc: 'Create staging and production Heroku apps'
17
+
18
+ class_option :github,
19
+ type: 'string',
20
+ aliases: '-G',
21
+ default: true,
22
+ desc: 'Create github repo and add remote origin'
23
+
24
+ class_option :skip_test_unit,
25
+ type: :boolean,
26
+ aliases: '-T',
27
+ default: true,
28
+ desc: 'Skip Test::Unit files'
29
+
30
+ def finish_template
31
+ invoke :prop_customizations
32
+ super
33
+ end
34
+
35
+ def prop_customizations
36
+ invoke :remove_garbage_files
37
+ invoke :customize_gemfile
38
+ invoke :setup_database
39
+ invoke :setup_development_environment
40
+ invoke :setup_test_environment
41
+ invoke :setup_production_environment
42
+ invoke :setup_staging_environment
43
+ invoke :create_prop_views
44
+ invoke :setup_coffeescript
45
+ invoke :configure_app
46
+ invoke :setup_stylesheets
47
+ invoke :copy_miscellaneous_files
48
+ invoke :customize_error_pages
49
+ invoke :remove_routes_comment_lines
50
+ invoke :create_guard_file
51
+ invoke :initialize_zeus
52
+ invoke :setup_git
53
+ invoke :create_heroku_apps
54
+ invoke :create_github_repo
55
+ invoke :start_zeus
56
+ invoke :outro
57
+ end
58
+
59
+ def remove_garbage_files
60
+ build :remove_public_index
61
+ build :remove_rails_logo_image
62
+ end
63
+
64
+ def customize_gemfile
65
+ build :replace_gemfile
66
+ build :set_ruby_to_version_being_used
67
+ bundle_command 'install'
68
+ end
69
+
70
+ def setup_database
71
+ say 'Setting up database'
72
+ build :use_postgres_config_template
73
+ build :create_database
74
+ end
75
+
76
+ def setup_development_environment
77
+ say 'Setting up the development environment'
78
+ build :raise_on_delivery_errors
79
+ build :raise_on_unpermitted_parameters
80
+ build :provide_setup_script
81
+ build :configure_generators
82
+ end
83
+
84
+ def setup_test_environment
85
+ say 'Setting up the test environment'
86
+ build :enable_factory_girl_syntax
87
+ build :test_factories_first
88
+ build :generate_rspec
89
+ build :configure_rspec
90
+ build :use_rspec_binstub
91
+ build :conifigure_background_jobs_for_rspec
92
+ build :enable_database_cleaner
93
+ build :configure_capybara_webkit
94
+ end
95
+
96
+ def setup_production_environment
97
+ say 'Setting up the production environment'
98
+ build :configure_smtp
99
+ end
100
+
101
+ def setup_staging_environment
102
+ say 'Setting up the staging environment'
103
+ build :setup_staging_environment
104
+ end
105
+
106
+ def create_prop_views
107
+ say 'Creating prop views'
108
+ build :create_partials_directory
109
+ build :create_shared_flashes
110
+ build :create_shared_javascripts
111
+ build :create_application_layout
112
+ end
113
+
114
+ def setup_coffeescript
115
+ say 'Setting up CoffeeScript defaults'
116
+ build :remove_turbolinks
117
+ build :create_common_javascripts
118
+ end
119
+
120
+ def configure_app
121
+ say 'Configuring app'
122
+ build :configure_action_mailer
123
+ build :blacklist_active_record_attributes
124
+ build :configure_strong_parameters
125
+ build :configure_time_zone
126
+ build :configure_time_formats
127
+ build :configure_rack_timeout
128
+ build :disable_xml_params
129
+ build :setup_default_rake_task
130
+ build :configure_unicorn
131
+ build :setup_foreman
132
+ end
133
+
134
+ def setup_stylesheets
135
+ say 'Setting up stylesheets'
136
+ build :setup_stylesheets
137
+ end
138
+
139
+ def create_guard_file
140
+ say 'Creating Guardfile'
141
+ build :setup_guardfile
142
+ end
143
+
144
+ def initialize_zeus
145
+ build :init_zeus
146
+ end
147
+
148
+ def setup_git
149
+ say 'Initializing git'
150
+ invoke :setup_gitignore
151
+ invoke :init_git
152
+ end
153
+
154
+ def create_heroku_apps
155
+ if options[:heroku]
156
+ say 'Creating Heroku apps'
157
+ build :create_heroku_apps
158
+ build :set_heroku_remotes
159
+ end
160
+ end
161
+
162
+ def create_github_repo
163
+ say 'Creating Github repo'
164
+ build :create_github_repo, "#{app_name}"
165
+ end
166
+
167
+ def setup_gitignore
168
+ build :gitignore_files
169
+ end
170
+
171
+ def init_git
172
+ build :init_git
173
+ end
174
+
175
+ def copy_libraries
176
+ say 'Copying libraries'
177
+ build :copy_libraries
178
+ end
179
+
180
+ def copy_miscellaneous_files
181
+ say 'Copying miscellaneous support files'
182
+ build :copy_miscellaneous_files
183
+ end
184
+
185
+ def customize_error_pages
186
+ say 'Customizing the 500/404/422 pages'
187
+ build :customize_error_pages
188
+ end
189
+
190
+ def remove_routes_comment_lines
191
+ build :remove_routes_comment_lines
192
+ end
193
+
194
+ def start_zeus
195
+ build :start_zeus
196
+ end
197
+
198
+ def outro
199
+ say 'Propped up.'
200
+ end
201
+
202
+ protected
203
+
204
+ def get_builder_class
205
+ Prop::AppBuilder
206
+ end
207
+
208
+ def using_active_record?
209
+ !options[:skip_active_record]
210
+ end
211
+ end
212
+ end
@@ -0,0 +1,3 @@
1
+ module Prop
2
+ VERSION = "0.0.1"
3
+ end
data/peg-leg-bates.jpg ADDED
Binary file
data/prop.gemspec ADDED
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+ require 'prop/version'
4
+ require 'date'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.required_ruby_version = '>= 2.0.0'
8
+ spec.add_dependency 'bundler', '~> 1.3'
9
+ spec.add_dependency 'rails', '4.0.0'
10
+ spec.authors = ['Nathaniel Wroblewski']
11
+ spec.date = Date.today.strftime('%Y-%m-%d')
12
+
13
+ spec.description = <<-HERE
14
+ Prop is a base Rails project that you can upgrade.
15
+ It is used to get a jump start on a working app.
16
+ HERE
17
+
18
+ spec.email = ["nathanielwroblewski@gmail.com"]
19
+ spec.executables = `git ls-files -- bin/*`.split("\n").map { |file| File.basename(file) }
20
+ spec.extra_rdoc_files = %w[README.md LICENSE]
21
+ spec.name = "prop_up"
22
+ spec.summary = 'Generate a Rails app using pre-configured best practices'
23
+ spec.homepage = 'https://github.com/NathanielWroblewski/prop'
24
+ spec.license = "MIT"
25
+
26
+ spec.files = `git ls-files`.split("\n")
27
+ spec.rdoc_options = ['--charset=UTF-8']
28
+ spec.require_paths = ['lib']
29
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
30
+ spec.version = Prop::VERSION
31
+ end
@@ -0,0 +1,56 @@
1
+ source 'https://rubygems.org'
2
+
3
+ ruby '2.0.0'
4
+
5
+ gem 'rails', '>= 4.0.0'
6
+
7
+ gem 'airbrake'
8
+ gem 'coffee-rails'
9
+ gem 'delayed_job_active_record', '>= 4.0.0'
10
+ gem 'email_validator'
11
+ gem 'haml_coffee_assets'
12
+ gem 'jquery-rails'
13
+ gem 'paperclip'
14
+ gem 'pg'
15
+ gem 'rack-timeout'
16
+ gem 'recipient_interceptor'
17
+ gem 'sass-rails'
18
+ gem 'simple_form'
19
+ gem 'uglifier'
20
+ gem 'unicorn'
21
+ gem 'zurb-foundation'
22
+
23
+ group :development do
24
+ gem 'better_errors'
25
+ gem 'binding_of_caller'
26
+ gem 'foreman'
27
+ gem 'guard'
28
+ gem 'guard-rspec'
29
+ end
30
+
31
+ group :development, :test do
32
+ gem 'capybara'
33
+ gem 'factory_girl_rails'
34
+ gem 'parallel_tests'
35
+ gem 'rspec'
36
+ gem 'rspec-core'
37
+ gem 'rspec-expectations'
38
+ gem 'rspec-mocks'
39
+ gem 'rspec-rails', '>= 2.14'
40
+ gem 'shoulda-matchers'
41
+ gem 'zeus', '>= 0.13.4.pre2'
42
+ end
43
+
44
+ group :test do
45
+ gem 'capybara-webkit', '>= 1.0.0'
46
+ gem 'database_cleaner'
47
+ gem 'launchy'
48
+ gem 'simplecov', require: false
49
+ gem 'timecop'
50
+ gem 'webmock'
51
+ end
52
+
53
+ group :staging, :production do
54
+ gem 'newrelic_rpm', '>= 3.6.7'
55
+ gem 'rails_12factor'
56
+ end
@@ -0,0 +1,11 @@
1
+ guard 'rspec', zeus: true, cli: '--color --order rand:$RANDOM' do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { 'spec' }
5
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
6
+ watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
7
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
8
+ watch(%r{^spec/support/(.+)\.rb$}) { 'spec' }
9
+ watch(%r{^spec/factories.rb$}) { 'spec/factories_spec.rb' }
10
+ watch('app/controllers/application_controller.rb') { 'spec/controllers' }
11
+ end
@@ -0,0 +1,2 @@
1
+ web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
2
+ worker: bundle exec rake jobs:work
@@ -0,0 +1,6 @@
1
+ You're being propped up
2
+ ============================
3
+
4
+ Consult the following repo for best practices and workflow protocol:
5
+
6
+ [Prop](https://github.com/NathanielWroblewski/prop)
@@ -0,0 +1,5 @@
1
+ <div id="flash">
2
+ <% flash.each do |key, value| -%>
3
+ <div id="flash_<%= key %>"><%= value %></div>
4
+ <% end -%>
5
+ </div>
@@ -0,0 +1,9 @@
1
+ <%= javascript_include_tag :application %>
2
+
3
+ <%= yield :javascript %>
4
+
5
+ <% if Rails.env.test? %>
6
+ <%= javascript_tag do %>
7
+ $.ajaxSetup({ async: false });
8
+ <% end %>
9
+ <% end %>
@@ -0,0 +1,5 @@
1
+ @charset 'utf-8';
2
+
3
+ ///////////////////////////////////////////////////////////////////////////////
4
+
5
+ ///////////////////////////////////////////////////////////////////////////////
@@ -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,25 @@
1
+ #!/usr/bin/env sh
2
+
3
+ # Set up Rails app. Run this script immediately after cloning the codebase.
4
+
5
+ # Set up Ruby dependencies via Bundler
6
+ bundle install
7
+
8
+ # Set up the database
9
+ bundle exec rake db:setup
10
+
11
+ # Set up configurable environment variables
12
+ if [ ! -f .env ]; then
13
+ cp .sample.env .env
14
+ fi
15
+
16
+ # Pick a port for Foreman
17
+ echo "port: 7000" > .foreman
18
+
19
+ # Set up DNS via Pow
20
+ if [ -d ~/.pow ]
21
+ then
22
+ echo 7000 > ~/.pow/`basename $PWD`
23
+ else
24
+ echo "Pow not set up but the team uses it for this project. Setup: http://goo.gl/RaDPO"
25
+ fi
@@ -0,0 +1,11 @@
1
+ en:
2
+ date:
3
+ formats:
4
+ default: '%m/%d/%Y'
5
+ with_weekday: '%a %m/%d/%y'
6
+
7
+ time:
8
+ formats:
9
+ default: '%a, %b %-d, %Y at %r'
10
+ date: '%b %-d, %Y'
11
+ short: '%B %d'
@@ -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,3 @@
1
+ # Protect against injection attacks
2
+ # http://www.kb.cert.org/vuls/id/380039
3
+ ActionDispatch::ParamsParser::DEFAULT_PARSERS.delete(Mime::XML)
@@ -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
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ FactoryGirl.factories.map(&:name).each do |factory_name|
4
+ describe "factory #{factory_name}" do
5
+ it 'is valid' do
6
+ factory = build(factory_name)
7
+
8
+ if factory.respond_to?(:valid?)
9
+ expect(factory).to be_valid, factory.errors.full_messages.join(',')
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ if defined?(RSpec)
2
+ desc 'Run factory specs.'
3
+
4
+ RSpec::Core::RakeTask.new(:factory_specs) do |t|
5
+ t.pattern = './spec/models/factories_spec.rb'
6
+ end
7
+
8
+ task spec: :factory_specs
9
+ end
@@ -0,0 +1,3 @@
1
+ RSpec.configure do |config|
2
+ config.include FactoryGirl::Syntax::Methods
3
+ end
@@ -0,0 +1,59 @@
1
+ // clear inputs with starter values
2
+ new function($) {
3
+ $.fn.prefilledInput = function() {
4
+
5
+ var focus = function () {
6
+ $(this).removeClass('prefilled');
7
+ if (this.value == this.prefilledValue) {
8
+ this.value = '';
9
+ }
10
+ };
11
+
12
+ var blur = function () {
13
+ if (this.value == '') {
14
+ $(this).addClass('prefilled').val(this.prefilledValue);
15
+ } else if (this.value != this.prefilledValue) {
16
+ $(this).removeClass('prefilled');
17
+ }
18
+ };
19
+
20
+ var extractPrefilledValue = function () {
21
+ if (this.title) {
22
+ this.prefilledValue = this.title;
23
+ this.title = '';
24
+ } else if (this.id) {
25
+ this.prefilledValue = $('label[for=' + this.id + ']').hide().text();
26
+ }
27
+ if (this.prefilledValue) {
28
+ this.prefilledValue = this.prefilledValue.replace(/\*$/, '');
29
+ }
30
+ };
31
+
32
+ var initialize = function (index) {
33
+ if (!this.prefilledValue) {
34
+ this.extractPrefilledValue = extractPrefilledValue;
35
+ this.extractPrefilledValue();
36
+ $(this).trigger('blur');
37
+ }
38
+ };
39
+
40
+ return this.filter(":input").
41
+ focus(focus).
42
+ blur(blur).
43
+ each(initialize);
44
+ };
45
+
46
+ var clearPrefilledInputs = function () {
47
+ var form = this.form || this;
48
+ $(form).find("input.prefilled, textarea.prefilled").val("");
49
+ };
50
+
51
+ var prefilledSetup = function () {
52
+ $('input.prefilled, textarea.prefilled').prefilledInput();
53
+ $('form').submit(clearPrefilledInputs);
54
+ $('input:submit, button:submit').click(clearPrefilledInputs);
55
+ };
56
+
57
+ $(document).ready(prefilledSetup);
58
+ $(document).ajaxComplete(prefilledSetup);
59
+ }(jQuery);
@@ -0,0 +1,11 @@
1
+ development: &default
2
+ adapter: postgresql
3
+ database: <%= app_name %>_development
4
+ encoding: utf8
5
+ min_messages: warning
6
+ pool: 5
7
+ timeout: 5000
8
+
9
+ test:
10
+ <<: *default
11
+ database: <%= app_name %>_test
@@ -0,0 +1,15 @@
1
+ !.keep
2
+ *.DS_Store
3
+ *.swo
4
+ *.swp
5
+ .bundle
6
+ .sass-cache/
7
+ coverage/*
8
+ db/*.sqlite3
9
+ db/schema.rb
10
+ log/*
11
+ public/system
12
+ rerun.txt
13
+ tags
14
+ tmp/*
15
+ tmp/**/*
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="ROBOTS" content="NOODP" />
6
+ <title><%%= page_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 @@
1
+ Rack::Timeout.timeout = (ENV['TIMEOUT_IN_SECONDS'] || 5).to_i
@@ -0,0 +1,2 @@
1
+ # http://ddollar.github.com/foreman/
2
+ RACK_ENV=development
data/templates/smtp.rb ADDED
@@ -0,0 +1,10 @@
1
+ if Rails.env.staging? || Rails.env.production?
2
+ SMTP_SETTINGS = {
3
+ address: ENV['SMTP_ADDRESS'], # example: 'smtp.sendgrid.net'
4
+ authentication: :plain,
5
+ domain: ENV['SMTP_DOMAIN'], # example: 'this-app.com'
6
+ password: ENV['SMTP_PASSWORD'],
7
+ port: '587',
8
+ user_name: ENV['SMTP_USERNAME']
9
+ }
10
+ end
@@ -0,0 +1,31 @@
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
+ require 'paperclip/matchers'
11
+
12
+ Dir[Rails.root.join('spec/support/**/*.rb')].each { |file| require file }
13
+
14
+ ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
15
+
16
+ RSpec.configure do |config|
17
+ config.expect_with :rspec do |c|
18
+ c.syntax = :expect
19
+ end
20
+
21
+ config.fail_fast = false
22
+ config.infer_base_class_for_anonymous_controllers = false
23
+ config.order = 'random'
24
+ config.color = true
25
+ config.use_transactional_fixtures = false
26
+ config.include FactoryGirl::Syntax::Default
27
+ config.include Paperclip::Shoulda::Matchers
28
+ end
29
+
30
+ Capybara.javascript_driver = :webkit
31
+ WebMock.disable_net_connect!(allow_localhost: true)