From 989c3dae77348f821242ea022b036da900f7cbce Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Wed, 15 Jan 2014 00:05:53 -0600 Subject: [PATCH 01/39] Initial commit: Rails 4.1.beta1 new --- .env.example | 40 -- .gitignore | 43 +- Gemfile | 136 ++--- Gemfile.lock | 468 +++--------------- Procfile | 2 - README.md | 9 - README.rdoc | 28 ++ Rakefile | 2 +- app/assets/stylesheets/application.css | 8 +- app/views/layouts/application.html.erb | 14 + app/views/layouts/application.html.slim | 11 - app/views/pages/index.html.slim | 4 - bin/rename | 8 - bin/setup | 1 - config.ru | 4 +- config/application.rb | 39 +- config/boot.rb | 2 +- config/database.yml | 38 +- config/environment.rb | 2 +- config/environments/development.rb | 36 +- config/environments/production.rb | 30 +- config/environments/test.rb | 11 +- .../log_active_record_validation_errors.rb | 11 - config/initializers/queue_classic_patch.rb | 12 - config/initializers/secret_token.rb | 12 - config/initializers/session_store.rb | 2 +- config/routes.rb | 11 +- config/secrets.yml | 20 + config/unicorn.rb | 28 -- contributing.md | 179 ------- custom_plan.rb | 13 - .../20131121215515_add_queue_classic.rb | 9 - db/structure.sql | 202 -------- lib/tasks/database_tasks.rake | 32 -- public/404.html | 31 +- public/422.html | 31 +- public/500.html | 29 +- public/robots.txt | 2 +- test/support/initializers/capybara.rb | 48 -- test/support/initializers/integration_test.rb | 16 - test/support/initializers/test_case.rb | 24 - test/support/initializers/turn.rb | 14 - test/test_helper.rb | 17 +- zeus.json | 22 - 44 files changed, 303 insertions(+), 1398 deletions(-) delete mode 100644 .env.example delete mode 100644 Procfile delete mode 100644 README.md create mode 100644 README.rdoc create mode 100644 app/views/layouts/application.html.erb delete mode 100644 app/views/layouts/application.html.slim delete mode 100644 app/views/pages/index.html.slim delete mode 100755 bin/rename delete mode 100755 bin/setup delete mode 100644 config/initializers/log_active_record_validation_errors.rb delete mode 100644 config/initializers/queue_classic_patch.rb delete mode 100644 config/initializers/secret_token.rb create mode 100644 config/secrets.yml delete mode 100644 config/unicorn.rb delete mode 100644 contributing.md delete mode 100644 custom_plan.rb delete mode 100644 db/migrate/20131121215515_add_queue_classic.rb delete mode 100644 db/structure.sql delete mode 100644 lib/tasks/database_tasks.rake delete mode 100644 test/support/initializers/capybara.rb delete mode 100644 test/support/initializers/integration_test.rb delete mode 100644 test/support/initializers/test_case.rb delete mode 100644 test/support/initializers/turn.rb delete mode 100644 zeus.json diff --git a/.env.example b/.env.example deleted file mode 100644 index bbb417f..0000000 --- a/.env.example +++ /dev/null @@ -1,40 +0,0 @@ -APPNAME= -DEVELOPER_EMAIL=$(git config user.email) - -# To quickly generate a 128-character token, you can use: -# -# ruby -e "puts rand(36**128).to_s(36)" -# -# And to configure heroku: -# heroku config:add RAILS_SECRET_TOKEN=$(ruby -e "puts rand(36**128).to_s(36)") -r production -export RAILS_SECRET_TOKEN=dw19w73upxp02rxrmsy2vbg7o0lmhqepsm4s3zw5iyz0hccs1a9tbflcxhnk19ivdlgdlio4nevbxfi5rlcpkpwx6 - -export EMAIL_RECIPIENTS=$DEVELOPER_EMAIL -export MAIL_DELIVERY_METHOD=letter_opener - -export AWS_ACCESS_KEY_ID= -export AWS_SECRET_ACCESS_KEY= -export FOG_DIRECTORY=$APPNAME-dev-$USER -export FOG_PROVIDER=AWS - -export MANDRILL_USERNAME=user@email.com -export MANDRILL_API_KEY=abc123 - -export STRIPE_API_KEY=sk_test_Nopqrstuvwxyz67890 -export STRIPE_PUBLIC_KEY=pk_test_Abcdefghijklm12345 - -export PGOPTIONS='-c client_min_messages=WARNING' - -export APP_URI=http://localhost:3000 - -export AIRBRAKE_API_KEY=1234567890abcdef - -# The password for ordinary seed user: -export USER_EMAIL=user@example.com -export USER_NAME='Chester Tester' -export USER_PASSWORD=password - -# Settings for the dev/admin seed user: -export ADMIN_EMAIL=$DEVELOPER_EMAIL -export ADMIN_NAME=$(get config user.name) -export ADMIN_PASSWORD=ridiculous diff --git a/.gitignore b/.gitignore index eca00e4..6a502e9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,45 +1,16 @@ -# See http://help.github.com/ignore-files/ for more about ignoring files. +# See https://help.github.com/articles/ignoring-files for more about ignoring files. # # If you find yourself ignoring temporary files generated by your text editor # or operating system, you probably want to add a global ignore instead: # git config --global core.excludesfile '~/.gitignore_global' # Ignore bundler config. -.bundle -vendor/bundle +/.bundle -# Ignore any SQLite databases. -db/*.sqlite3 -db/*.sqlite3-journal +# Ignore the default SQLite database. +/db/*.sqlite3 +/db/*.sqlite3-journal # Ignore all logfiles and tempfiles. -log/*.log -log/*.yml -tmp - -# Ignore enviroment variable files -.env* -!.env.example -.powenv - -# Ignore local TDDium config -.tddium* - -# Ignore .rvmrc (used by RVM for certain environments) -.rvmrc - -# Ignore swp files -*.swp - -# Ignore Temp Photo Uploads -public/uploads - -# Ignore Assets -public/assets - -tags -coverage - -.sass-cache - -setup.lock +/log/*.log +/tmp diff --git a/Gemfile b/Gemfile index 0c1af54..0ff1861 100644 --- a/Gemfile +++ b/Gemfile @@ -1,92 +1,48 @@ source 'https://rubygems.org' -ruby '2.0.0' # Tell heroku to use ruby 2.0.0 - -gem 'rails', '4.0.0' # Latest version of the best web framework in the world - -gem 'american_date', '~> 1.1.0' # American style month/day/year date parsing -gem 'authority', '~> 2.9.0' # Authorize user actions in your Rails app -gem 'bootstrap-sass', '~> 3.0.0.0' # Twitter Bootstrap front-end framework -gem 'carrierwave', '~> 0.9.0' # Server side file uploads (hand off from s3_direct_upload) -gem 'coffee-rails', '~> 4.0.0' # Outside assets for respondes to coffee -gem 'compass-rails', '~> 1.1.2' # CSS framework -gem 'dalli', '~> 2.6.4' # Caching with Memcached -gem 'devise', '~> 3.1.1' # Authentication with Warden -gem 'fog', '~> 1.14.0' # Ruby cloud services library (used by carrierwave) -gem 'font_assets', '~> 0.1.10' # Addresses Access-Control-Allow-Origin asset problems in Firefox -gem 'has_scope', '~> 0.5.1' # Easy controller scopes -gem 'high_voltage', '~> 2.0.0' # Static pages -gem 'jquery-fileupload-rails', '~> 0.4.1' # Direct upload files to S3 -gem 'jquery-rails', '~> 3.0.4' # jQuery yo -gem 'memcachier', '~> 0.0.2' # Simple memcachier configuration -gem 'mini_magick', '~> 3.6.0' # Image resizing for carrierwave -gem 'momentjs-rails', '~> 2.2.1' # JS time library -gem 'newrelic_rpm', '~> 3.6.8.168' # Production monitoring -gem 'nprogress-rails', '~> 0.1.2.2' # Loading bar for turbolinks -gem 'pg', '~> 0.17.0' # Postgres ActiveRecord adapter -gem 'queue_classic', '~> 2.2.3' # Backgrounding queue that uses postgres for db -gem 'rack-canonical-host', '~> 0.0.8' # Automatically redirect to canonical host -gem 'rack-mini-profiler', '~> 0.1.29' # Middleware that displays speed badge for every html page -gem 'redcarpet', '~> 3.0.0' # Add markdown parsing and rendering -gem 'responders', '~> 1.0.0.rc' # Minimal controllers via responders.yml -gem 'retina_tag', '~> 1.2.2' # Retina image tags -gem 'rolify', '~> 3.3.0.rc4' # Role management library with resource scoping -gem 'rollout', '~> 2.0.0' # Feature flipper -gem 's3_direct_upload', '~> 0.1.6' # Client-side straight-to-s3 file uploads -gem 'sass-rails', '~> 4.0.0' # CSS3 extension (mixins, variables, nesting, etc) -gem 'selectize-rails', '~> 0.8.1' # Textbox/select autocopmlete for tagging and contact lists -gem 'simple_form', '~> 3.0.0.rc' # Simplified DSL for forms''' -gem 'slim-rails', '~> 2.0.3' # Our favorite Ruby templating engine for html -gem 'turbolinks', '~> 1.3.0' # Makes following links in your web application faster -gem 'uglifier', '>= 1.0.3' # Makes your JS ugly (compressed) -gem 'unicorn', '~> 4.6.2' # HTTP server for fast clients on low-latency, high-bandwidth connections -gem 'validates_existence', '~> 0.8.0' # Validates Rails model belongs_to association existence -gem 'will_paginate', '~> 3.0.5' # Pagination - -group :development do - gem 'awesome_print' # Inspect your objects with style (and color) - gem 'brakeman' # Security auditing - gem 'bullet' # Finds your N+1 problems - gem 'foreman' # Manage Procfile-based applications (run multiple ruby processes by running foreman) - gem 'binding_of_caller' # Provide advanced features for better_errors pages - gem 'better_errors' # More helpful error pages in development - gem 'letter_opener' # Open development emails in a browser instead of sending them - gem 'lol_dba' # Scan your models for columns that (probably) should be indexed - gem 'quiet_assets' # No more "Served asset" in your logs - gem 'rails_best_practices' # Code metric tool for showing best practices you're missing out on - gem 'switch_user' # Easily switch users in dev - gem 'thin' # Fast threaded HTTP server for local development - gem 'traceroute' # Finds unused routes - gem 'xray-rails' # See into your views to easily open a partial from your browser -end - -group :development, :test do - gem 'dotenv-rails' # Autoload ENV vars in .env - gem 'pry-awesome_print' # Auto AP in pry - gem 'pry-rails' # Interactive REPL debugger - gem 'pry-plus' # Add a bunch of awesome pry stuff (rescue, stack_explorer, doc) - gem 'pry-remote' # Use pry with pow - gem 'recipient_interceptor' # Intercept recipients when delivering email with the Mail gem - gem 'table_print' # Explore your ActiveRecord data with ease -end - -group :test do - gem 'capybara' # Acceptance test framework - gem 'capybara_minitest_spec' # Integrates capybara and minitest; Duh - gem 'database_cleaner' # Cleans db between test runs - gem 'factory_girl_rails' # For stubbing/creating objects with factories - gem 'minitest-metadata' # Metadata (key-value) support for minitest/spec - gem 'minitest-spec-rails' # Nice minitest integration with Rails - gem 'poltergeist' # Uses phantomjs to headlessly test your views - gem 'simplecov', require: false # Test coverage reporting - gem 'timecop' # Freeze/change time for your tests -end - -group :staging, :production do - gem 'rails_12factor', '~> 0.0.2' # Heroku gem for logging and asset serving - gem 'heroku', '~> 3.0.1' # For continous deployment -end - -group :production do - gem 'airbrake', '~> 3.1.12' # Logs exceptions on airbrake.io -end + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '4.1.0.beta1' + +# Use sqlite3 as the database for Active Record +gem 'sqlite3' + +# Use SCSS for stylesheets +gem 'sass-rails', '~> 4.0.0.rc1' + +# Use Uglifier as compressor for JavaScript assets +gem 'uglifier', '>= 1.3.0' + +# Use CoffeeScript for .js.coffee assets and views +gem 'coffee-rails', '~> 4.0.0' + +# See https://github.com/sstephenson/execjs#readme for more supported runtimes +# gem 'therubyracer', platforms: :ruby + +# Use jquery as the JavaScript library +gem 'jquery-rails' + +# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks +gem 'turbolinks' + +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder +gem 'jbuilder', '~> 1.2' + +# bundle exec rake doc:rails generates the API under doc/api. +gem 'sdoc', group: :doc, require: false + +# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/jonleighton/spring +gem 'spring', group: :development + +# Use ActiveModel has_secure_password +# gem 'bcrypt-ruby', '~> 3.1.2' + +# Use unicorn as the app server +# gem 'unicorn' + +# Use Capistrano for deployment +# gem 'capistrano-rails', group: :development + +# Use debugger +# gem 'debugger', group: [:development, :test] + diff --git a/Gemfile.lock b/Gemfile.lock index 43761dc..c8201a8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,82 +1,35 @@ GEM remote: https://rubygems.org/ specs: - actionmailer (4.0.0) - actionpack (= 4.0.0) - mail (~> 2.5.3) - actionpack (4.0.0) - activesupport (= 4.0.0) - builder (~> 3.1.0) - erubis (~> 2.7.0) + actionmailer (4.1.0.beta1) + actionpack (= 4.1.0.beta1) + actionview (= 4.1.0.beta1) + mail (~> 2.5.4) + actionpack (4.1.0.beta1) + actionview (= 4.1.0.beta1) + activesupport (= 4.1.0.beta1) rack (~> 1.5.2) rack-test (~> 0.6.2) - activemodel (4.0.0) - activesupport (= 4.0.0) - builder (~> 3.1.0) - activerecord (4.0.0) - activemodel (= 4.0.0) - activerecord-deprecated_finders (~> 1.0.2) - activesupport (= 4.0.0) - arel (~> 4.0.0) - activerecord-deprecated_finders (1.0.3) - activesupport (4.0.0) - i18n (~> 0.6, >= 0.6.4) - minitest (~> 4.2) - multi_json (~> 1.3) + actionview (4.1.0.beta1) + activesupport (= 4.1.0.beta1) + builder (~> 3.1) + erubis (~> 2.7.0) + activemodel (4.1.0.beta1) + activesupport (= 4.1.0.beta1) + builder (~> 3.1) + activerecord (4.1.0.beta1) + activemodel (= 4.1.0.beta1) + activesupport (= 4.1.0.beta1) + arel (~> 5.0.0) + activesupport (4.1.0.beta1) + i18n (~> 0.6, >= 0.6.9) + json (~> 1.7, >= 1.7.7) + minitest (~> 5.1) thread_safe (~> 0.1) - tzinfo (~> 0.3.37) - addressable (2.3.5) - airbrake (3.1.14) - builder - json - american_date (1.1.0) - arel (4.0.1) + tzinfo (~> 1.1) + arel (5.0.0) atomic (1.1.14) - authority (2.9.0) - activesupport (>= 3.0.0) - rake (>= 0.8.7) - awesome_print (1.1.0) - bcrypt-ruby (3.1.2) - better_errors (1.0.1) - coderay (>= 1.0.0) - erubis (>= 2.6.6) - binding_of_caller (0.7.2) - debug_inspector (>= 0.0.1) - bond (0.4.3) - bootstrap-sass (3.0.0.0) - sass (~> 3.2) - brakeman (2.2.0) - erubis (~> 2.6) - fastercsv (~> 1.5) - haml (>= 3.0, < 5.0) - highline (~> 1.6.20) - multi_json (~> 1.2) - ruby2ruby (~> 2.0.5) - ruby_parser (~> 3.2.2) - sass (~> 3.0) - slim (>= 1.3.6, < 3.0) - terminal-table (~> 1.4) - builder (3.1.4) - bullet (4.6.0) - uniform_notifier - capybara (2.1.0) - mime-types (>= 1.16) - nokogiri (>= 1.3.3) - rack (>= 1.0.0) - rack-test (>= 0.5.4) - xpath (~> 2.0) - capybara_minitest_spec (1.0.1) - capybara (>= 2) - minitest (>= 2) - carrierwave (0.9.0) - activemodel (>= 3.2.0) - activesupport (>= 3.2.0) - json (>= 1.7) - chunky_png (1.2.9) - cliver (0.2.2) - code_analyzer (0.4.3) - sexp_processor - coderay (1.0.9) + builder (3.2.2) coffee-rails (4.0.1) coffee-script (>= 2.2.0) railties (>= 4.0.0, < 5.0) @@ -84,256 +37,55 @@ GEM coffee-script-source execjs coffee-script-source (1.6.3) - colored (1.2) - columnize (0.3.6) - compass (0.12.2) - chunky_png (~> 1.2) - fssm (>= 0.2.7) - sass (~> 3.1) - compass-rails (1.1.2) - compass (>= 0.12.2) - daemons (1.1.9) - dalli (2.6.4) - database_cleaner (1.2.0) - debug_inspector (0.0.2) - debugger (1.6.2) - columnize (>= 0.3.1) - debugger-linecache (~> 1.2.0) - debugger-ruby_core_source (~> 1.2.3) - debugger-linecache (1.2.0) - debugger-ruby_core_source (1.2.3) - devise (3.1.1) - bcrypt-ruby (~> 3.0) - orm_adapter (~> 0.1) - railties (>= 3.2.6, < 5) - thread_safe (~> 0.1) - warden (~> 1.2.3) - dotenv (0.9.0) - dotenv-rails (0.9.0) - dotenv (= 0.9.0) erubis (2.7.0) - eventmachine (1.0.3) - excon (0.25.3) execjs (2.0.2) - factory_girl (4.2.0) - activesupport (>= 3.0.0) - factory_girl_rails (4.2.1) - factory_girl (~> 4.2.0) - railties (>= 3.0.0) - fastercsv (1.5.5) - fog (1.14.0) - builder - excon (~> 0.25.0) - formatador (~> 0.2.0) - mime-types - multi_json (~> 1.0) - net-scp (~> 1.1) - net-ssh (>= 2.1.3) - nokogiri (~> 1.5) - ruby-hmac - font_assets (0.1.10) - rack - foreman (0.63.0) - dotenv (>= 0.7) - thor (>= 0.13.6) - formatador (0.2.4) - fssm (0.2.10) - haml (4.0.3) - tilt - has_scope (0.5.1) - heroku (3.0.1) - heroku-api (~> 0.3.7) - launchy (>= 0.3.2) - netrc (~> 0.7.7) - rest-client (~> 1.6.1) - rubyzip - heroku-api (0.3.15) - excon (~> 0.25.1) - high_voltage (2.0.0) - highline (1.6.20) hike (1.2.3) - i18n (0.6.5) - interception (0.3) - jist (1.5.1) - json - jquery-fileupload-rails (0.4.1) - actionpack (>= 3.1) - railties (>= 3.1) + i18n (0.6.9) + jbuilder (1.5.3) + activesupport (>= 3.0.0) + multi_json (>= 1.2.0) jquery-rails (3.0.4) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) json (1.8.1) - kgio (2.8.1) - launchy (2.3.0) - addressable (~> 2.3) - letter_opener (1.1.2) - launchy (~> 2.2) - lol_dba (1.6.0) - actionpack (>= 3.0) - activerecord (>= 3.0) - railties (>= 3.0) mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) - memcachier (0.0.2) - method_source (0.8.2) - mime-types (1.25) - mini_magick (3.6.0) - subexec (~> 0.2.1) - mini_portile (0.5.2) - minitest (4.7.5) - minitest-metadata (0.4.0) - minitest (~> 4.7) - minitest-spec-rails (4.7.4) - minitest (~> 4.7) - rails (<= 4.0) - momentjs-rails (2.2.1) - railties (>= 3.1) - multi_json (1.8.2) - net-scp (1.1.2) - net-ssh (>= 2.6.5) - net-ssh (2.7.0) - netrc (0.7.7) - newrelic_rpm (3.6.8.168) - nokogiri (1.6.0) - mini_portile (~> 0.5.0) - nprogress-rails (0.1.2.3) - orm_adapter (0.4.0) - pg (0.17.0) - poltergeist (1.4.1) - capybara (~> 2.1.0) - cliver (~> 0.2.1) - multi_json (~> 1.0) - websocket-driver (>= 0.2.0) + mime-types (1.25.1) + minitest (5.2.1) + multi_json (1.8.3) polyglot (0.3.3) - pry (0.9.12.2) - coderay (~> 1.0.5) - method_source (~> 0.8) - slop (~> 3.4) - pry-awesome_print (9.6.8) - awesome_print (~> 1.1.0) - pry (~> 0.9.0) - pry-debugger (0.2.2) - debugger (~> 1.3) - pry (~> 0.9.10) - pry-doc (0.4.6) - pry (>= 0.9) - yard (>= 0.8) - pry-docmore (0.1.1) - pry - pry-doc - pry-plus (1.0.0) - bond - jist - pry-debugger - pry-doc - pry-docmore - pry-rescue - pry-stack_explorer - pry-rails (0.3.2) - pry (>= 0.9.10) - pry-remote (0.1.7) - pry (~> 0.9) - slop (~> 3.0) - pry-rescue (1.2.0) - interception (>= 0.3) - pry - pry-stack_explorer (0.4.9.1) - binding_of_caller (>= 0.7) - pry (>= 0.9.11) - queue_classic (2.2.3) - pg (~> 0.17.0) - quiet_assets (1.0.2) - railties (>= 3.1, < 5.0) rack (1.5.2) - rack-canonical-host (0.0.8) - addressable - rack (~> 1.0) - rack-mini-profiler (0.1.31) - rack (>= 1.1.3) rack-test (0.6.2) rack (>= 1.0) - rails (4.0.0) - actionmailer (= 4.0.0) - actionpack (= 4.0.0) - activerecord (= 4.0.0) - activesupport (= 4.0.0) + rails (4.1.0.beta1) + actionmailer (= 4.1.0.beta1) + actionpack (= 4.1.0.beta1) + actionview (= 4.1.0.beta1) + activemodel (= 4.1.0.beta1) + activerecord (= 4.1.0.beta1) + activesupport (= 4.1.0.beta1) bundler (>= 1.3.0, < 2.0) - railties (= 4.0.0) + railties (= 4.1.0.beta1) sprockets-rails (~> 2.0.0) - rails_12factor (0.0.2) - rails_serve_static_assets - rails_stdout_logging - rails_best_practices (1.14.4) - activesupport - awesome_print - code_analyzer (>= 0.4.3) - colored - erubis - i18n - require_all - ruby-progressbar - rails_serve_static_assets (0.0.1) - rails_stdout_logging (0.0.3) - railties (4.0.0) - actionpack (= 4.0.0) - activesupport (= 4.0.0) + railties (4.1.0.beta1) + actionpack (= 4.1.0.beta1) + activesupport (= 4.1.0.beta1) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - raindrops (0.12.0) - rake (10.1.0) - recipient_interceptor (0.1.2) - mail - redcarpet (3.0.0) - redis (3.0.5) - require_all (1.3.2) - responders (1.0.0) - railties (>= 3.2, < 5) - rest-client (1.6.7) - mime-types (>= 1.16) - retina_tag (1.2.2) - jquery-rails - rails (>= 4.0) - rolify (3.3.0.rc4) - rollout (2.0.0) - redis - ruby-hmac (0.4.0) - ruby-progressbar (1.2.0) - ruby2ruby (2.0.6) - ruby_parser (~> 3.1) - sexp_processor (~> 4.0) - ruby_parser (3.2.2) - sexp_processor (~> 4.1) - rubyzip (1.0.0) - s3_direct_upload (0.1.6) - coffee-rails (>= 3.2.1) - jquery-fileupload-rails (~> 0.4.1) - rails (>= 3.2) - sass-rails (>= 3.2.5) - sass (3.2.12) + rake (10.1.1) + rdoc (3.12.2) + json (~> 1.4) + sass (3.2.13) sass-rails (4.0.1) railties (>= 4.0.0, < 5.0) sass (>= 3.1.10) sprockets-rails (~> 2.0.0) - selectize-rails (0.8.1) - sexp_processor (4.4.0) - simple_form (3.0.0) - actionpack (>= 4.0.0, < 4.1) - activemodel (>= 4.0.0, < 4.1) - simplecov (0.7.1) - multi_json (~> 1.0) - simplecov-html (~> 0.7.1) - simplecov-html (0.7.1) - slim (2.0.2) - temple (~> 0.6.6) - tilt (>= 1.3.3, < 2.1) - slim-rails (2.0.3) - actionpack (>= 3.0, < 4.1) - activesupport (>= 3.0, < 4.1) - railties (>= 3.0, < 4.1) - slim (~> 2.0) - slop (3.4.6) - sprockets (2.10.0) + sdoc (0.3.20) + json (>= 1.1.3) + rdoc (~> 3.10) + spring (1.0.0) + sprockets (2.10.1) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) @@ -342,121 +94,33 @@ GEM actionpack (>= 3.0) activesupport (>= 3.0) sprockets (~> 2.8) - subexec (0.2.3) - switch_user (0.9.3) - table_print (1.5.1) - temple (0.6.7) - terminal-table (1.4.5) - thin (1.6.1) - daemons (>= 1.0.9) - eventmachine (>= 1.0.0) - rack (>= 1.0.0) + sqlite3 (1.3.8) thor (0.18.1) thread_safe (0.1.3) atomic tilt (1.4.1) - timecop (0.6.3) - traceroute (0.3.0) - rails (>= 3.0.0) treetop (1.4.15) polyglot polyglot (>= 0.3.1) - turbolinks (1.3.0) + turbolinks (2.1.0) coffee-rails - tzinfo (0.3.38) - uglifier (2.3.0) + tzinfo (1.1.0) + thread_safe (~> 0.1) + uglifier (2.4.0) execjs (>= 0.3.0) json (>= 1.8.0) - unicorn (4.6.3) - kgio (~> 2.6) - rack - raindrops (~> 0.7) - uniform_notifier (1.3.0) - validates_existence (0.8.0) - warden (1.2.3) - rack (>= 1.0) - websocket-driver (0.3.0) - will_paginate (3.0.5) - xpath (2.0.0) - nokogiri (~> 1.3) - xray-rails (0.1.6) - coffee-rails - rails (>= 3.1.0) - yard (0.8.7.2) PLATFORMS ruby DEPENDENCIES - airbrake (~> 3.1.12) - american_date (~> 1.1.0) - authority (~> 2.9.0) - awesome_print - better_errors - binding_of_caller - bootstrap-sass (~> 3.0.0.0) - brakeman - bullet - capybara - capybara_minitest_spec - carrierwave (~> 0.9.0) coffee-rails (~> 4.0.0) - compass-rails (~> 1.1.2) - dalli (~> 2.6.4) - database_cleaner - devise (~> 3.1.1) - dotenv-rails - factory_girl_rails - fog (~> 1.14.0) - font_assets (~> 0.1.10) - foreman - has_scope (~> 0.5.1) - heroku (~> 3.0.1) - high_voltage (~> 2.0.0) - jquery-fileupload-rails (~> 0.4.1) - jquery-rails (~> 3.0.4) - letter_opener - lol_dba - memcachier (~> 0.0.2) - mini_magick (~> 3.6.0) - minitest-metadata - minitest-spec-rails - momentjs-rails (~> 2.2.1) - newrelic_rpm (~> 3.6.8.168) - nprogress-rails (~> 0.1.2.2) - pg (~> 0.17.0) - poltergeist - pry-awesome_print - pry-plus - pry-rails - pry-remote - queue_classic (~> 2.2.3) - quiet_assets - rack-canonical-host (~> 0.0.8) - rack-mini-profiler (~> 0.1.29) - rails (= 4.0.0) - rails_12factor (~> 0.0.2) - rails_best_practices - recipient_interceptor - redcarpet (~> 3.0.0) - responders (~> 1.0.0.rc) - retina_tag (~> 1.2.2) - rolify (~> 3.3.0.rc4) - rollout (~> 2.0.0) - s3_direct_upload (~> 0.1.6) - sass-rails (~> 4.0.0) - selectize-rails (~> 0.8.1) - simple_form (~> 3.0.0.rc) - simplecov - slim-rails (~> 2.0.3) - switch_user - table_print - thin - timecop - traceroute - turbolinks (~> 1.3.0) - uglifier (>= 1.0.3) - unicorn (~> 4.6.2) - validates_existence (~> 0.8.0) - will_paginate (~> 3.0.5) - xray-rails + jbuilder (~> 1.2) + jquery-rails + rails (= 4.1.0.beta1) + sass-rails (~> 4.0.0.rc1) + sdoc + spring + sqlite3 + turbolinks + uglifier (>= 1.3.0) diff --git a/Procfile b/Procfile deleted file mode 100644 index 94553f2..0000000 --- a/Procfile +++ /dev/null @@ -1,2 +0,0 @@ -web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb -worker: rake jobs:work diff --git a/README.md b/README.md deleted file mode 100644 index 5468001..0000000 --- a/README.md +++ /dev/null @@ -1,9 +0,0 @@ - ------------------- - - - -### Contributing ### - -See [contributing.md](contributing.md) for development process guidance. - diff --git a/README.rdoc b/README.rdoc new file mode 100644 index 0000000..dd4e97e --- /dev/null +++ b/README.rdoc @@ -0,0 +1,28 @@ +== README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... + + +Please feel free to use a different markup language if you do not plan to run +rake doc:app. diff --git a/Rakefile b/Rakefile index 897266d..ba6b733 100644 --- a/Rakefile +++ b/Rakefile @@ -3,4 +3,4 @@ require File.expand_path('../config/application', __FILE__) -MyApp::Application.load_tasks +Rails.application.load_tasks diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 3192ec8..a443db3 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -5,9 +5,11 @@ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. * - * You're free to add application-wide styles to this file and they'll appear at the top of the - * compiled file, but it's generally better to create a new file per style scope. + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any styles + * defined in the other CSS/SCSS files in this directory. It is generally better to create a new + * file per style scope. * - *= require_self *= require_tree . + *= require_self */ diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb new file mode 100644 index 0000000..8736e21 --- /dev/null +++ b/app/views/layouts/application.html.erb @@ -0,0 +1,14 @@ + + + + RailsTemplate + <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %> + <%= javascript_include_tag "application", "data-turbolinks-track" => true %> + <%= csrf_meta_tags %> + + + +<%= yield %> + + + diff --git a/app/views/layouts/application.html.slim b/app/views/layouts/application.html.slim deleted file mode 100644 index 25b28d6..0000000 --- a/app/views/layouts/application.html.slim +++ /dev/null @@ -1,11 +0,0 @@ -doctype 5 -html - head - title = Rails.application.class.parent_name - = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true - = javascript_include_tag 'application', 'data-turbolinks-track' => true - = csrf_meta_tags - -body - - = yield diff --git a/app/views/pages/index.html.slim b/app/views/pages/index.html.slim deleted file mode 100644 index 31c11a2..0000000 --- a/app/views/pages/index.html.slim +++ /dev/null @@ -1,4 +0,0 @@ -h1 Welcome to Rails - -a href='/rails/info/properties' - | Application properties diff --git a/bin/rename b/bin/rename deleted file mode 100755 index 29be61a..0000000 --- a/bin/rename +++ /dev/null @@ -1,8 +0,0 @@ -#! /usr/bin/env bash -[[ -z $1 ]] && echo 'Provide an app name' && exit 1 -input_string=${2:-MyApp} -input_string_underscored=$(ruby -r'active_support/inflector' -e "puts '$input_string'.strip.underscore") -output_string=$1 -output_string_underscored=$(ruby -r'active_support/inflector' -e "puts '$output_string'.strip.underscore") -git grep -l -e "$input_string" | grep -v 'bin/rename' | xargs sed -i '' "s/$input_string/$output_string/g" -git grep -l -e "$input_string_underscored" | grep -v 'bin/rename' | xargs sed -i '' "s/$input_string_underscored/$output_string_underscored/g" diff --git a/bin/setup b/bin/setup deleted file mode 100755 index d4fe335..0000000 --- a/bin/setup +++ /dev/null @@ -1 +0,0 @@ -bash -c "$(curl -s https://raw.github.com/brightbit/bin_setup/master/bin/setup)" diff --git a/config.ru b/config.ru index b34eb62..5bc2a61 100644 --- a/config.ru +++ b/config.ru @@ -1,6 +1,4 @@ # This file is used by Rack-based servers to start the application. -require File.expand_path('config/environment', __dir__) -use Rack::CanonicalHost, ENV['CANONICAL_HOST'] if ENV['CANONICAL_HOST'] - +require ::File.expand_path('../config/environment', __FILE__) run Rails.application diff --git a/config/application.rb b/config/application.rb index 8d00360..03bd09a 100644 --- a/config/application.rb +++ b/config/application.rb @@ -4,9 +4,9 @@ # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. -Bundler.require(:default, Rails.env) +Bundler.require(*Rails.groups) -module MyApp +module RailsTemplate class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers @@ -19,40 +19,5 @@ class Application < Rails::Application # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.default_locale = :de - - # Use SQL instead of Active Record's schema dumper when creating the database (for QueueClassic) - # This is necessary if your schema can't be completely dumped by the schema dumper, - # like if you have constraints or database-specific column types - config.active_record.schema_format = :sql - - # Tell Unicorn to log to STDOUT on Heroku - config.logger = Logger.new(STDOUT) unless Rails.env.development? - - # Raise errors when an unpermitted param is sent to a controller action - ActiveRecord::Base.send(:include, ActiveModel::ForbiddenAttributesProtection) - - config.app_uri = URI.parse ENV.fetch('APP_URI') - - # ActionMailer Config with Mandrill from Mailchimp for transactional mail - config.action_mailer.delivery_method = ENV.fetch('MAIL_DELIVERY_METHOD', :smtp).to_sym - if config.action_mailer.delivery_method == :smtp - config.action_mailer.smtp_settings = { - address: 'smtp.mandrillapp.com', - port: 587, - enable_starttls_auto: true, - user_name: ENV.fetch('MANDRILL_USERNAME'), - password: ENV.fetch('MANDRILL_APIKEY'), - authentication: :plain, - domain: config.app_uri.host - } - end - - config.action_mailer.perform_deliveries = true - config.action_mailer.raise_delivery_errors = false - config.action_mailer.default charset: "utf-8" - config.action_mailer.default_url_options = { protocol: config.app_uri.scheme, host: config.app_uri.host } - config.action_mailer.asset_host = config.app_uri.to_s end end - -Mail.register_interceptor RecipientInterceptor.new(ENV['EMAIL_RECIPIENTS']) if ENV['EMAIL_RECIPIENTS'] && defined?(Mail) && !Rails.env.test? diff --git a/config/boot.rb b/config/boot.rb index 3596736..5e5f0c1 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,4 +1,4 @@ # Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) -require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) +require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) diff --git a/config/database.yml b/config/database.yml index a23c995..1c1a37c 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,19 +1,25 @@ -development: &development - adapter : postgresql - encoding : unicode - database : my_app_development - template : template0 - pool : 5 - min_messages : warning +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: 5 + timeout: 5000 -test: &test - <<: *development - database : my_app_test +development: + <<: *default + database: db/development.sqlite3 -staging: &staging - <<: *development - database : my_app_staging +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 -production: &production - <<: *development - database : my_app_production +production: + <<: *default + database: db/production.sqlite3 diff --git a/config/environment.rb b/config/environment.rb index 98a6efb..ee8d90d 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -2,4 +2,4 @@ require File.expand_path('../application', __FILE__) # Initialize the Rails application. -MyApp::Application.initialize! +Rails.application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index 139f526..01aca64 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,4 +1,4 @@ -MyApp::Application.configure do +Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on @@ -11,45 +11,19 @@ # Show full error reports and disable caching. config.consider_all_requests_local = true - config.action_controller.perform_caching = true + config.action_controller.perform_caching = false - # Cache stuff in memcache - config.cache_store = :mem_cache_store, { expires_in: 10.minutes } - - # Open email in browser or send via smtp - if ENV['EMAIL_RECIPIENTS'] == 'letter_opener' - config.action_mailer.delivery_method = :letter_opener - end - - # Enable serving of images, stylesheets, and JavaScripts from an asset server for mailers. - config.action_mailer.asset_host = "http://localhost:3000" - - # Raise real errors in development - config.action_mailer.raise_delivery_errors = true + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log - # Raise an error on page load if there are pending migrations + # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. config.assets.debug = true - - # Add the fonts path - config.assets.paths << Rails.root.join('app', 'assets', 'fonts') - - # Precompile additional assets - config.assets.precompile += %w( .svg .eot .woff .ttf ) - - # Configure Bullet - config.after_initialize do - Bullet.enable = true - Bullet.console = true - Bullet.rails_logger = true - end - - BetterErrors::Middleware.allow_ip! ENV['BETTER_ERRORS_TRUSTED_IP'] if (IPAddr(ENV['BETTER_ERRORS_TRUSTED_IP']) rescue false) end diff --git a/config/environments/production.rb b/config/environments/production.rb index e501ef6..f335833 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,4 +1,4 @@ -MyApp::Application.configure do +Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. @@ -19,52 +19,40 @@ # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. # config.action_dispatch.rack_cache = true - # Enable Rails's static asset server (for passthrough CDNs) - config.serve_static_assets = true + # Disable Rails's static asset server (Apache or nginx will already do this). + config.serve_static_assets = false # Compress JavaScripts and CSS. config.assets.js_compressor = :uglifier # config.assets.css_compressor = :sass - # Fallback to assets pipeline if a precompiled asset is missed - config.assets.compile = true + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false # Generate digests for assets URLs. config.assets.digest = true - # Keep static assets for 300 days - config.static_cache_control = "public, max-age=2592000" - # Version of your assets, change this if you want to expire all your assets. config.assets.version = '1.0' - # Cache assets between deloys (speeds up heroku deploys) - config.assets.configure {|env| env.cache = ActiveSupport::Cache.lookup_store(:dalli_store) } - # Specifies the header that your server uses for sending files. # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. - config.force_ssl = true + # config.force_ssl = true # Set to :debug to see everything in the log. config.log_level = :info # Prepend all log lines with the following tags. - config.log_tags = [ :uuid ] + # config.log_tags = [ :subdomain, :uuid ] # Use a different logger for distributed setups. # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) - # Use a different cache store in production - config.cache_store = :dalli_store - - # Add the fonts path - config.assets.paths << Rails.root.join('app', 'assets', 'fonts') - - # Precompile additional assets - config.assets.precompile += %w( .svg .eot .woff .ttf ) + # Use a different cache store in production. + # config.cache_store = :mem_cache_store # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.action_controller.asset_host = "http://assets.example.com" diff --git a/config/environments/test.rb b/config/environments/test.rb index 912165d..ba0742f 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,4 +1,4 @@ -MyApp::Application.configure do +Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # The test environment is used exclusively to run your application's @@ -16,15 +16,6 @@ config.serve_static_assets = true config.static_cache_control = "public, max-age=3600" - # Add the fonts path - config.assets.paths << Rails.root.join('app', 'assets', 'fonts') - - # Precompile additional assets - config.assets.precompile += %w( .svg .eot .woff .ttf ) - - # Silence SQL and other logging in test (tail log/test.log instead) - config.logger = nil - # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false diff --git a/config/initializers/log_active_record_validation_errors.rb b/config/initializers/log_active_record_validation_errors.rb deleted file mode 100644 index e1a9bb9..0000000 --- a/config/initializers/log_active_record_validation_errors.rb +++ /dev/null @@ -1,11 +0,0 @@ -def log_arv_errors - if self.errors.any? - Rails.logger.warn "#{self.class} failed to save!" - Rails.logger.warn "Attributes: " - Rails.logger.warn self.attributes - Rails.logger.warn "Errors: " - Rails.logger.warn self.errors.full_messages.join("\n") - end -end - -ActiveRecord::Base.send(:after_validation, :log_arv_errors) diff --git a/config/initializers/queue_classic_patch.rb b/config/initializers/queue_classic_patch.rb deleted file mode 100644 index 4aa1502..0000000 --- a/config/initializers/queue_classic_patch.rb +++ /dev/null @@ -1,12 +0,0 @@ -# Resolves "connection is closed" in integration tests. See: https://github.com/ryandotsmith/queue_classic/issues/96#issuecomment-24118800 -if Rails.env.development? || Rails.env.test? - module QC - module Conn - def connect - conn = ActiveRecord::Base.connection.raw_connection - log(:level => :error, :message => conn.error) if conn.status != PGconn::CONNECTION_OK - conn - end - end - end -end diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb deleted file mode 100644 index 17b7eab..0000000 --- a/config/initializers/secret_token.rb +++ /dev/null @@ -1,12 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Your secret key is used for verifying the integrity of signed cookies. -# If you change this key, all old signed cookies will become invalid! - -# Make sure the secret is at least 30 characters and all random, -# no regular words or you'll be exposed to dictionary attacks. -# You can use `rake secret` to generate a secure secret key. - -# Make sure your secret_key_base is kept private -# if you're sharing your code publicly. -MyApp::Application.config.secret_key_base = ENV.fetch('RAILS_SECRET_TOKEN') diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index 96daa03..0fc7dbb 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,3 +1,3 @@ # Be sure to restart your server when you modify this file. -MyApp::Application.config.session_store :cookie_store, key: "_#{Rails.application.class.parent_name}_session" +Rails.application.config.session_store :cookie_store, key: '_rails-template_session' diff --git a/config/routes.rb b/config/routes.rb index 4bef8a4..3f66539 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,4 @@ -MyApp::Application.routes.draw do +Rails.application.routes.draw do # The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "rake routes". @@ -39,7 +39,7 @@ # get 'recent', on: :collection # end # end - + # Example resource route with concerns: # concern :toggleable do # post 'toggle' @@ -53,11 +53,4 @@ # # (app/controllers/admin/products_controller.rb) # resources :products # end - - # Point root to static index file using high_voltage gem - root to: 'high_voltage/pages#show', id: 'index' - - # Point fallback route to any matching static page - # Keep this at the end to avoid conflicting with other routes - get ':id' => 'high_voltage/pages#show', as: :static end diff --git a/config/secrets.yml b/config/secrets.yml new file mode 100644 index 0000000..3cc7980 --- /dev/null +++ b/config/secrets.yml @@ -0,0 +1,20 @@ +# Be sure to restart your server when you modify this file. + +# Your secret key is used for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! + +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +# You can use `rake secret` to generate a secure secret key. + +# Make sure the secrets in this file are kept private +# if you're sharing your code publicly. + +development: + secret_key_base: b1aef1c9601246acf6e78ec8b361699d25d70485b15b5d087179a2e43cd92366c2ed3785376057eea35c1ed5719fe8c219440d89d98a55f03d97c7f857785d85 + +test: + secret_key_base: 0c7c63c35d95e6bf950f78e71af6d09a58b5d08c30d689e94223f4c1ae3400af131e7a6f053af6217ef42ee734057478903c648c290fb3b5d6985e01e42af72a + +production: + secret_key_base: 5d69a19eea3dd5cac779d581eb6c45568fe52c32aba8dcc3ddde4c836fd9dabcd807d164dfe78206a5e77aab8ca17ca705a2b79c8cb08b1c967a77d921478b9e diff --git a/config/unicorn.rb b/config/unicorn.rb deleted file mode 100644 index e025676..0000000 --- a/config/unicorn.rb +++ /dev/null @@ -1,28 +0,0 @@ -worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3) -preload_app true -GC.respond_to?(:copy_on_write_friendly=) and GC.copy_on_write_friendly = true - -before_exec do |server| - ENV['RUBY_HEAP_MIN_SLOTS']=800000 - ENV['RUBY_GC_MALLOC_LIMIT']=90000000 - ENV['RUBY_HEAP_SLOTS_INCREMENT']=10000 - ENV['RUBY_HEAP_SLOTS_GROWTH_FACTOR']=1 - ENV['RUBY_HEAP_FREE_MIN']=100000 -end - -before_fork do |server, worker| - Signal.trap 'TERM' do - puts 'Unicorn master intercepting TERM and sending myself QUIT instead' - Process.kill 'QUIT', Process.pid - end - - defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect! -end - -after_fork do |server, worker| - Signal.trap 'TERM' do - puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT' - end - - defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection -end diff --git a/contributing.md b/contributing.md deleted file mode 100644 index 1c03b89..0000000 --- a/contributing.md +++ /dev/null @@ -1,179 +0,0 @@ -# Reporting issues - -Titles should be concise and <55 characters (like commit messages). - -Please use this template for bug reports: - -```markdown -## Description of Problem - -One or two sentences giving an overview of the issue. - -## System details - -* **Browser**: Chrome 29 - -* **OS**: Mac OS X 10.9.0 - -## Steps to Reproduce - - 1. Went to [Giant Coffee mug](https://example.com/products/123) - - 2. Clicked "Launch Ponies" - -## HAR file (Attach only if applicable and reproducable in Chrome) - - * [HAR](http://example.com/issue_123.har) - -## Observed Behavior - - * Ponies die - -## Expected Behavior - - * Ponies survive -``` - -# Adding a feature/fixing a bug (developer) - -* Have each feature/fix in a single commit. You can create mutliple - commits, but rebase them together before doing a pull request. - -* Each commit should be a working set of changes (don't commit one change with - another fix commit after it). If you want to get your code off your computer - add "@wip" to the commit message and then rebase over it later. (This doesn't - work well if you're collaborating on a branch. A branch with your initials at - the front [e.g. eb-add_minitest] signifies it's your personal branch.) - -* Never push to the master branch. Use feature branches instead, as detailed below. - If you ever do push to master, make sure to *never* do a forced push to master. - This will avoid the potential for much pain and gnashing of teeth. - -* In feature branches, we do encourage forced push to clean up commit history. - However, even in a feature branch, use great care if anyone else might be - collaborating on the same branch. - -* When feasible, program production code with a pair. - -* Even when pair programming is not feasible, allow a second developer to review - production code and merge it to master after any discussion and revision. In - other words: a developer other than the author should merge the pull request. - -## A good workflow when you're ready to fix something: - -1. Make sure you're on master and up to date (note a rebase not merge): - - ```bash - git checkout master - git pull --rebase - ``` - -2. Make a feature branch for your fix: - - ```bash - git checkout -b eb-add_minitest - ``` - -3. *do your work*, then: - -4. Add all files not checked in (make sure you don't have family_photo.jpg in the - directory): - - ```bash - git add . - ``` - -5. Commit the changes; --verbose add the full git diff to comments in the commit - message for your reviewing: - - ```bash - git commit --verbose - ``` - -6. When you run the above command it will open your EDITOR and ask for a commit - message. Provide - * a <55 character one line title, followed by - * two newlines, followed by - * a paragraph of what was changed, followed by - * a bulleted list of changes. - - See: https://github.com/brightbit/swagexpert/commit/bb4a46a80245f4362b59855274ef697eb143d8b2) - -7. This is a good time to do an interactive rebase to squash any excess commits. - - ```bash - git rebase -i HEAD~4 - ``` - -8. Next push the changes to github (this sets the upstream for the pull request): - - ```bash - git push -u origin eb-add_minitest - ``` - -9. And make the pull request: - - ```bash - hub pull-request - ``` - - (This opens EDITOR so you can write the pull request; after save/quit it - provides the link to the PR. See https://github.com/github/hub for installation.) - -This looks like a lot but with some aliases such as in [dotfiles](http://github.com/ericboehs/dotfiles) -it can look something like this: - -```bash -gco -b eb-add_minitest -``` -*do work* - -```bash -gacpr -``` - -# Environment Setup - -1. To satisfy the PostgreSQL dependency, ensure that either - a. You don't have PostgreSQL installed at all (step 2 will install it), or - b. PostgreSQL 9.2+ is running on the default port of 5433. -2. Run script/setup from the shell console. -3. Install PhantomJS 1.8.1+ on your machine, in order to run the test suite - -To have a fully running local development environment, you'll need to replace the dummy values in .env with real ones. -Most of these can be obtained by running `heroku config -s` on the console. You'll also need a working S3 bucket for some functionality. - -## Configure a development S3 Bucket - -One exception is configuring S3 for development. You'll need to create a real S3 bucket that matches the value of your -FOG_DIRECTORY variable. That bucket will need to be fully writeable by the user specified in your -AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY environment variables. Also, you will need to add a CORS configuration like the -following to the bucket: - -```xml - - - - *://localhost:3000 - GET - POST - PUT - 3000 - * - - - *://appname.dev - GET - POST - PUT - 3000 - * - - - * - GET - 3000 - Authorization - - -``` diff --git a/custom_plan.rb b/custom_plan.rb deleted file mode 100644 index fc903c1..0000000 --- a/custom_plan.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'zeus/rails' - -class CustomPlan < Zeus::Rails - - def test_environment - require 'minitest/unit' - MiniTest::Unit.class_variable_set("@@installed_at_exit", true) - super - end - -end - -Zeus.plan = CustomPlan.new diff --git a/db/migrate/20131121215515_add_queue_classic.rb b/db/migrate/20131121215515_add_queue_classic.rb deleted file mode 100644 index 00ffb6a..0000000 --- a/db/migrate/20131121215515_add_queue_classic.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddQueueClassic < ActiveRecord::Migration - def self.up - QC::Setup.create - end - - def self.down - QC::Setup.drop - end -end diff --git a/db/structure.sql b/db/structure.sql deleted file mode 100644 index e658d87..0000000 --- a/db/structure.sql +++ /dev/null @@ -1,202 +0,0 @@ --- --- PostgreSQL database dump --- - -SET statement_timeout = 0; -SET client_encoding = 'UTF8'; -SET standard_conforming_strings = on; -SET check_function_bodies = false; -SET client_min_messages = warning; - --- --- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: - --- - -CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; - - --- --- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: - --- - -COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; - - -SET search_path = public, pg_catalog; - -SET default_tablespace = ''; - -SET default_with_oids = false; - --- --- Name: queue_classic_jobs; Type: TABLE; Schema: public; Owner: -; Tablespace: --- - -CREATE TABLE queue_classic_jobs ( - id bigint NOT NULL, - q_name text NOT NULL, - method text NOT NULL, - args json NOT NULL, - locked_at timestamp with time zone, - CONSTRAINT queue_classic_jobs_method_check CHECK ((length(method) > 0)), - CONSTRAINT queue_classic_jobs_q_name_check CHECK ((length(q_name) > 0)) -); - - --- --- Name: lock_head(character varying); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION lock_head(tname character varying) RETURNS SETOF queue_classic_jobs - LANGUAGE plpgsql - AS $_$ -BEGIN - RETURN QUERY EXECUTE 'SELECT * FROM lock_head($1,10)' USING tname; -END; -$_$; - - --- --- Name: lock_head(character varying, integer); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION lock_head(q_name character varying, top_boundary integer) RETURNS SETOF queue_classic_jobs - LANGUAGE plpgsql - AS $_$ -DECLARE - unlocked bigint; - relative_top integer; - job_count integer; -BEGIN - -- The purpose is to release contention for the first spot in the table. - -- The select count(*) is going to slow down dequeue performance but allow - -- for more workers. Would love to see some optimization here... - - EXECUTE 'SELECT count(*) FROM ' - || '(SELECT * FROM queue_classic_jobs WHERE q_name = ' - || quote_literal(q_name) - || ' LIMIT ' - || quote_literal(top_boundary) - || ') limited' - INTO job_count; - - SELECT TRUNC(random() * (top_boundary - 1)) - INTO relative_top; - - IF job_count < top_boundary THEN - relative_top = 0; - END IF; - - LOOP - BEGIN - EXECUTE 'SELECT id FROM queue_classic_jobs ' - || ' WHERE locked_at IS NULL' - || ' AND q_name = ' - || quote_literal(q_name) - || ' ORDER BY id ASC' - || ' LIMIT 1' - || ' OFFSET ' || quote_literal(relative_top) - || ' FOR UPDATE NOWAIT' - INTO unlocked; - EXIT; - EXCEPTION - WHEN lock_not_available THEN - -- do nothing. loop again and hope we get a lock - END; - END LOOP; - - RETURN QUERY EXECUTE 'UPDATE queue_classic_jobs ' - || ' SET locked_at = (CURRENT_TIMESTAMP)' - || ' WHERE id = $1' - || ' AND locked_at is NULL' - || ' RETURNING *' - USING unlocked; - - RETURN; -END; -$_$; - - --- --- Name: queue_classic_notify(); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION queue_classic_notify() RETURNS trigger - LANGUAGE plpgsql - AS $$ begin - perform pg_notify(new.q_name, ''); - return null; -end $$; - - --- --- Name: queue_classic_jobs_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE queue_classic_jobs_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: queue_classic_jobs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE queue_classic_jobs_id_seq OWNED BY queue_classic_jobs.id; - - --- --- Name: schema_migrations; Type: TABLE; Schema: public; Owner: -; Tablespace: --- - -CREATE TABLE schema_migrations ( - version character varying(255) NOT NULL -); - - --- --- Name: id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY queue_classic_jobs ALTER COLUMN id SET DEFAULT nextval('queue_classic_jobs_id_seq'::regclass); - - --- --- Name: queue_classic_jobs_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: --- - -ALTER TABLE ONLY queue_classic_jobs - ADD CONSTRAINT queue_classic_jobs_pkey PRIMARY KEY (id); - - --- --- Name: idx_qc_on_name_only_unlocked; Type: INDEX; Schema: public; Owner: -; Tablespace: --- - -CREATE INDEX idx_qc_on_name_only_unlocked ON queue_classic_jobs USING btree (q_name, id) WHERE (locked_at IS NULL); - - --- --- Name: unique_schema_migrations; Type: INDEX; Schema: public; Owner: -; Tablespace: --- - -CREATE UNIQUE INDEX unique_schema_migrations ON schema_migrations USING btree (version); - - --- --- Name: queue_classic_notify; Type: TRIGGER; Schema: public; Owner: - --- - -CREATE TRIGGER queue_classic_notify AFTER INSERT ON queue_classic_jobs FOR EACH ROW EXECUTE PROCEDURE queue_classic_notify(); - - --- --- PostgreSQL database dump complete --- - -SET search_path TO "$user",public; - -INSERT INTO schema_migrations (version) VALUES ('20131121215515'); diff --git a/lib/tasks/database_tasks.rake b/lib/tasks/database_tasks.rake deleted file mode 100644 index 9e201fc..0000000 --- a/lib/tasks/database_tasks.rake +++ /dev/null @@ -1,32 +0,0 @@ -# monkey patch ActiveRecord to avoid There are n other session(s) using the database. -module ActiveRecord - module Tasks # :nodoc: - module DatabaseTasks - extend self - - def configuration - @arguments.first - end - - def pg_adapter - class_for_adapter(configuration['adapter']).new(*@arguments) - end - - def terminate_existing_connetions - pg_adapter.establish_connection(*@arguments) - pg_adapter.connection.select_all("select * from pg_stat_activity order by pid;").each do |x| - if configuration['database'] == x['datname'] && x['state'] == "idle" - pg_adapter.connection.execute("select pg_terminate_backend(#{x['pid']})") - end - end - end - - def drop(*arguments) - @arguments = arguments - terminate_existing_connetions - pg_adapter.drop - rescue Exception => error - end - end - end -end diff --git a/public/404.html b/public/404.html index a0daa0c..b612547 100644 --- a/public/404.html +++ b/public/404.html @@ -2,17 +2,23 @@ The page you were looking for doesn't exist (404) + @@ -50,9 +57,11 @@
-

The page you were looking for doesn't exist.

-

You may have mistyped the address or the page may have moved.

+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

-

If you are the application owner check the logs for more information.

diff --git a/public/422.html b/public/422.html index fbb4b84..a21f82b 100644 --- a/public/422.html +++ b/public/422.html @@ -2,17 +2,23 @@ The change you wanted was rejected (422) + @@ -50,9 +57,11 @@
-

The change you wanted was rejected.

-

Maybe you tried to change something you didn't have access to.

+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

-

If you are the application owner check the logs for more information.

diff --git a/public/500.html b/public/500.html index e9052d3..061abc5 100644 --- a/public/500.html +++ b/public/500.html @@ -2,17 +2,23 @@ We're sorry, but something went wrong (500) + @@ -50,8 +57,10 @@
-

We're sorry, but something went wrong.

+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

-

If you are the application owner check the logs for more information.

diff --git a/public/robots.txt b/public/robots.txt index 1a3a5e4..3c9c7c0 100644 --- a/public/robots.txt +++ b/public/robots.txt @@ -1,4 +1,4 @@ -# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file # # To ban all spiders from the entire site uncomment the next two lines: # User-agent: * diff --git a/test/support/initializers/capybara.rb b/test/support/initializers/capybara.rb deleted file mode 100644 index 144611c..0000000 --- a/test/support/initializers/capybara.rb +++ /dev/null @@ -1,48 +0,0 @@ -require 'capybara/rails' -require 'capybara/poltergeist' - -# This hack is to surpress warnings in Mavericks. See: https://github.com/ariya/phantomjs/issues/11418#issuecomment-26938117 -class Capybara::Poltergeist::Client - private - - def redirect_stdout - orig_stdout = STDOUT.dup - orig_stdout.autoclose = false - $stdout = @write_io - STDOUT.reopen(@write_io) - - orig_stderr = STDERR.dup - orig_stderr.autoclose = false - $stderr = @write_io - STDERR.reopen(@write_io) - - yield - ensure - STDOUT.reopen(orig_stdout) - $stdout = STDOUT - STDERR.reopen(orig_stderr) - $stderr = STDERR - end -end - -class WarningSuppressor - def self.write(message) - if message =~ /QFont::setPixelSize: Pixel size <= 0|CoreText performance note:/ - 0 - else - puts message - 1 - end - end -end - -Capybara.register_driver :poltergeist do |app| - Capybara::Poltergeist::Driver.new(app, phantomjs_logger: WarningSuppressor) -end - -Capybara.register_driver :poltergeist_debug do |app| - Capybara::Poltergeist::Driver.new(app, inspector: true, debug: true) -end - -Capybara.default_driver = :rack_test -Capybara.javascript_driver = :poltergeist diff --git a/test/support/initializers/integration_test.rb b/test/support/initializers/integration_test.rb deleted file mode 100644 index 329677c..0000000 --- a/test/support/initializers/integration_test.rb +++ /dev/null @@ -1,16 +0,0 @@ -class ActionDispatch::IntegrationTest - include Rails.application.routes.url_helpers - include Capybara::DSL - - before do - if metadata[:js] - Capybara.current_driver = Capybara.javascript_driver - metadata[:db_clean_strategy] = :truncation - end - end - - after do - Capybara.reset_sessions! # Forget the (simulated) browser state - Capybara.use_default_driver # Revert Capybara.current_driver to Capybara.default_driver - end -end diff --git a/test/support/initializers/test_case.rb b/test/support/initializers/test_case.rb deleted file mode 100644 index 741d188..0000000 --- a/test/support/initializers/test_case.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'database_cleaner' -DatabaseCleaner.clean_with(:truncation) -DatabaseCleaner.strategy = :transaction - -class ActiveSupport::TestCase - include MiniTest::Metadata - include FactoryGirl::Syntax::Methods - - ActiveRecord::Migration.check_pending! - - # Leave db cleanup to the master--DatabaseCleaner - self.use_transactional_fixtures = false - - before do - DatabaseCleaner.clean - DatabaseCleaner.strategy = :transaction - DatabaseCleaner.start - end - - def run_all_queued_jobs - worker = QC::Worker.new - worker.work while worker.queue.count > 0 - end -end diff --git a/test/support/initializers/turn.rb b/test/support/initializers/turn.rb deleted file mode 100644 index 292794c..0000000 --- a/test/support/initializers/turn.rb +++ /dev/null @@ -1,14 +0,0 @@ -# To enable turn formatting, set the TURN_FORMAT variable to one of the following: -# pretty, dot, cue, marshal, outline, or progress -# or set to true (or on, yes, or 1) to use the default turn format -if ENV['TURN_FORMAT'].to_s !~ /^(|false|0|off|no|pride)$/i - require 'turn/autorun' - - if ENV['TURN_FORMAT'] =~ /^(on|yes|1|true)$/i - ENV['TURN_FORMAT'] = Turn.config.format.to_s - else - Turn.config.format = ENV['TURN_FORMAT'].intern - end -else - require 'minitest/pride' -end diff --git a/test/test_helper.rb b/test/test_helper.rb index 55403fe..bc7e05d 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,10 +1,15 @@ ENV["RAILS_ENV"] ||= "test" -require_relative '../config/environment' -require_relative '../config/boot' +require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' -require 'dotenv' -Dotenv.load +class ActiveSupport::TestCase + ActiveRecord::Migration.check_pending! -# Load all support files -Dir[File.expand_path('support/**/*.rb', __dir__)].each { |f| require f } + # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. + # + # Note: You'll currently still have to declare fixtures explicitly in integration tests + # -- they do not yet inherit this setting + fixtures :all + + # Add more helper methods to be used by all tests here... +end diff --git a/zeus.json b/zeus.json deleted file mode 100644 index 71193b9..0000000 --- a/zeus.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "command": "ruby -rubygems -r./custom_plan -eZeus.go", - - "plan": { - "boot": { - "default_bundle": { - "development_environment": { - "prerake": {"rake": []}, - "runner": ["r"], - "console": ["c"], - "server": ["s"], - "generate": ["g"], - "destroy": ["d"], - "dbconsole": [] - }, - "test_environment": { - "test_helper": {"test": ["testrb"]} - } - } - } - } -} From f68eed50d140b8494bd65689cf1941b6b000be4e Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Thu, 9 Jan 2014 17:35:11 -0600 Subject: [PATCH 02/39] Rename app to "MyApp" (and switch to postresql) --- Gemfile | 9 +----- app/views/layouts/application.html.erb | 2 +- config/application.rb | 2 +- config/database.yml | 38 +++++++++++--------------- db/schema.rb | 16 +++++++++++ 5 files changed, 35 insertions(+), 32 deletions(-) create mode 100644 db/schema.rb diff --git a/Gemfile b/Gemfile index 0ff1861..371e43a 100644 --- a/Gemfile +++ b/Gemfile @@ -4,14 +4,7 @@ source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.1.0.beta1' -# Use sqlite3 as the database for Active Record -gem 'sqlite3' - -# Use SCSS for stylesheets -gem 'sass-rails', '~> 4.0.0.rc1' - -# Use Uglifier as compressor for JavaScript assets -gem 'uglifier', '>= 1.3.0' +gem 'pg', '~> 0.17.1' # Use CoffeeScript for .js.coffee assets and views gem 'coffee-rails', '~> 4.0.0' diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 8736e21..fdb1d70 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,7 +1,7 @@ - RailsTemplate + MyApp <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %> <%= javascript_include_tag "application", "data-turbolinks-track" => true %> <%= csrf_meta_tags %> diff --git a/config/application.rb b/config/application.rb index 03bd09a..51b8991 100644 --- a/config/application.rb +++ b/config/application.rb @@ -6,7 +6,7 @@ # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) -module RailsTemplate +module MyApp class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers diff --git a/config/database.yml b/config/database.yml index 1c1a37c..a23c995 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,25 +1,19 @@ -# SQLite version 3.x -# gem install sqlite3 -# -# Ensure the SQLite 3 gem is defined in your Gemfile -# gem 'sqlite3' -# -default: &default - adapter: sqlite3 - pool: 5 - timeout: 5000 +development: &development + adapter : postgresql + encoding : unicode + database : my_app_development + template : template0 + pool : 5 + min_messages : warning -development: - <<: *default - database: db/development.sqlite3 +test: &test + <<: *development + database : my_app_test -# Warning: The database defined as "test" will be erased and -# re-generated from your development database when you run "rake". -# Do not set this db to the same as development or production. -test: - <<: *default - database: db/test.sqlite3 +staging: &staging + <<: *development + database : my_app_staging -production: - <<: *default - database: db/production.sqlite3 +production: &production + <<: *development + database : my_app_production diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000..4dfbb16 --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,16 @@ +# encoding: UTF-8 +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 0) do + +end From f88236eaa543df8a17694ca6b4ea866ee7431ee7 Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Thu, 9 Jan 2014 17:52:36 -0600 Subject: [PATCH 03/39] Add bin/rename --- bin/rename | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100755 bin/rename diff --git a/bin/rename b/bin/rename new file mode 100755 index 0000000..29be61a --- /dev/null +++ b/bin/rename @@ -0,0 +1,8 @@ +#! /usr/bin/env bash +[[ -z $1 ]] && echo 'Provide an app name' && exit 1 +input_string=${2:-MyApp} +input_string_underscored=$(ruby -r'active_support/inflector' -e "puts '$input_string'.strip.underscore") +output_string=$1 +output_string_underscored=$(ruby -r'active_support/inflector' -e "puts '$output_string'.strip.underscore") +git grep -l -e "$input_string" | grep -v 'bin/rename' | xargs sed -i '' "s/$input_string/$output_string/g" +git grep -l -e "$input_string_underscored" | grep -v 'bin/rename' | xargs sed -i '' "s/$input_string_underscored/$output_string_underscored/g" From ad2dc164a5b7b8724670ca97073fc8c37adc8e52 Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Thu, 9 Jan 2014 18:17:13 -0600 Subject: [PATCH 04/39] Add .env.example --- .env.example | 40 ++++++++++++++++++++++++++++++++++++++++ .gitignore | 29 ++++++++++++++++++++++++----- 2 files changed, 64 insertions(+), 5 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..e11bd3e --- /dev/null +++ b/.env.example @@ -0,0 +1,40 @@ +APPNAME=my-app +DEVELOPER_EMAIL=$(git config user.email) + +# To quickly generate a 128-character token, you can use: +# +# ruby -e "puts rand(36**128).to_s(36)" +# +# And to configure heroku: +# heroku config:add RAILS_SECRET_TOKEN=$(ruby -e "puts rand(36**128).to_s(36)") -r production +export RAILS_SECRET_TOKEN=dhb0h20edrflpzdy3b6ywdkijegvzvo9hnwoh6qegw2ytn0klvvmhdgczkkefxl1c6kgszzgogomayo + +export EMAIL_RECIPIENTS=$DEVELOPER_EMAIL +export MAIL_DELIVERY_METHOD=letter_opener + +export AWS_ACCESS_KEY_ID= +export AWS_SECRET_ACCESS_KEY= +export FOG_DIRECTORY=$APPNAME-dev-$USER +export FOG_PROVIDER=AWS + +export MANDRILL_USERNAME=user@email.com +export MANDRILL_API_KEY=abc123 + +export STRIPE_API_KEY=sk_test_Nopqrstuvwxyz67890 +export STRIPE_PUBLIC_KEY=pk_test_Abcdefghijklm12345 + +export PGOPTIONS='-c client_min_messages=WARNING' + +export APP_URI=http://localhost:3000 + +export AIRBRAKE_API_KEY=1234567890abcdef + +# The password for ordinary seed user: +export USER_EMAIL=user@example.com +export USER_NAME='Chester Tester' +export USER_PASSWORD=password + +# Settings for the dev/admin seed user: +export ADMIN_EMAIL=admin@example.com +export ADMIN_NAME='Adam Minister' +export ADMIN_PASSWORD=password diff --git a/.gitignore b/.gitignore index 6a502e9..2eb5aec 100644 --- a/.gitignore +++ b/.gitignore @@ -6,11 +6,30 @@ # Ignore bundler config. /.bundle - -# Ignore the default SQLite database. -/db/*.sqlite3 -/db/*.sqlite3-journal +vendor/bundle # Ignore all logfiles and tempfiles. /log/*.log -/tmp +log/*.yml +tmp + +# Ignore enviroment variable files +.env* +!.env.example +.powenv + +# Ignore swp files +*.swp + +# Ignore Temp Photo Uploads +public/uploads + +# Ignore Assets +public/assets + +tags +coverage + +.sass-cache + +setup.lock From fc2167513033faa517b463eb26d9a445ff4e0452 Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Thu, 9 Jan 2014 18:22:24 -0600 Subject: [PATCH 05/39] Clean Gemfile; Add dotenv; Use secret_token initializer over secrets.yml --- Gemfile | 44 +++++++++-------------------- Gemfile.lock | 14 +++++---- config/initializers/secret_token.rb | 12 ++++++++ config/secrets.yml | 20 ------------- 4 files changed, 34 insertions(+), 56 deletions(-) create mode 100644 config/initializers/secret_token.rb delete mode 100644 config/secrets.yml diff --git a/Gemfile b/Gemfile index 371e43a..b580ca1 100644 --- a/Gemfile +++ b/Gemfile @@ -1,41 +1,23 @@ source 'https://rubygems.org' - -# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.1.0.beta1' gem 'pg', '~> 0.17.1' -# Use CoffeeScript for .js.coffee assets and views +# Asset related gems +gem 'sass-rails', '~> 4.0.0.rc1' +gem 'uglifier', '~> 2.4.0' gem 'coffee-rails', '~> 4.0.0' +gem 'jquery-rails', '~> 3.0.4' +gem 'turbolinks', '~> 2.1.0' -# See https://github.com/sstephenson/execjs#readme for more supported runtimes -# gem 'therubyracer', platforms: :ruby - -# Use jquery as the JavaScript library -gem 'jquery-rails' - -# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks -gem 'turbolinks' - -# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder -gem 'jbuilder', '~> 1.2' - -# bundle exec rake doc:rails generates the API under doc/api. -gem 'sdoc', group: :doc, require: false - -# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/jonleighton/spring -gem 'spring', group: :development - -# Use ActiveModel has_secure_password -# gem 'bcrypt-ruby', '~> 3.1.2' - -# Use unicorn as the app server -# gem 'unicorn' - -# Use Capistrano for deployment -# gem 'capistrano-rails', group: :development +gem 'jbuilder', '~> 1.2' # Build JSON APIs with ease -# Use debugger -# gem 'debugger', group: [:development, :test] +gem 'sdoc', group: :doc, require: false # bundle exec rake doc:rails generates the API under doc/api +group :development do + gem 'spring' # Spring speeds up development by keeping your application running in the background +end +group :development, :test do + gem 'dotenv-rails' # Autoload ENV vars in .env +end diff --git a/Gemfile.lock b/Gemfile.lock index c8201a8..e6a74f0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -37,6 +37,9 @@ GEM coffee-script-source execjs coffee-script-source (1.6.3) + dotenv (0.9.0) + dotenv-rails (0.9.0) + dotenv (= 0.9.0) erubis (2.7.0) execjs (2.0.2) hike (1.2.3) @@ -54,6 +57,7 @@ GEM mime-types (1.25.1) minitest (5.2.1) multi_json (1.8.3) + pg (0.17.1) polyglot (0.3.3) rack (1.5.2) rack-test (0.6.2) @@ -94,7 +98,6 @@ GEM actionpack (>= 3.0) activesupport (>= 3.0) sprockets (~> 2.8) - sqlite3 (1.3.8) thor (0.18.1) thread_safe (0.1.3) atomic @@ -115,12 +118,13 @@ PLATFORMS DEPENDENCIES coffee-rails (~> 4.0.0) + dotenv-rails jbuilder (~> 1.2) - jquery-rails + jquery-rails (~> 3.0.4) + pg (~> 0.17.1) rails (= 4.1.0.beta1) sass-rails (~> 4.0.0.rc1) sdoc spring - sqlite3 - turbolinks - uglifier (>= 1.3.0) + turbolinks (~> 2.1.0) + uglifier (~> 2.4.0) diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb new file mode 100644 index 0000000..d72e18c --- /dev/null +++ b/config/initializers/secret_token.rb @@ -0,0 +1,12 @@ +# Be sure to restart your server when you modify this file. + +# Your secret key is used for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! + +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +# You can use `rake secret` to generate a secure secret key. + +# Make sure your secret_key_base is kept private +# if you're sharing your code publicly. +Rails.application.config.secret_key_base = ENV.fetch('RAILS_SECRET_TOKEN') diff --git a/config/secrets.yml b/config/secrets.yml deleted file mode 100644 index 3cc7980..0000000 --- a/config/secrets.yml +++ /dev/null @@ -1,20 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Your secret key is used for verifying the integrity of signed cookies. -# If you change this key, all old signed cookies will become invalid! - -# Make sure the secret is at least 30 characters and all random, -# no regular words or you'll be exposed to dictionary attacks. -# You can use `rake secret` to generate a secure secret key. - -# Make sure the secrets in this file are kept private -# if you're sharing your code publicly. - -development: - secret_key_base: b1aef1c9601246acf6e78ec8b361699d25d70485b15b5d087179a2e43cd92366c2ed3785376057eea35c1ed5719fe8c219440d89d98a55f03d97c7f857785d85 - -test: - secret_key_base: 0c7c63c35d95e6bf950f78e71af6d09a58b5d08c30d689e94223f4c1ae3400af131e7a6f053af6217ef42ee734057478903c648c290fb3b5d6985e01e42af72a - -production: - secret_key_base: 5d69a19eea3dd5cac779d581eb6c45568fe52c32aba8dcc3ddde4c836fd9dabcd807d164dfe78206a5e77aab8ca17ca705a2b79c8cb08b1c967a77d921478b9e From 0020825e613f233161f8f41c459e3b5fb03d12dc Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Thu, 9 Jan 2014 18:22:53 -0600 Subject: [PATCH 06/39] Add bin/setup; Add database overide which allows resetting db while conencted --- bin/setup | 1 + db/schema.rb | 3 +++ lib/tasks/database_tasks.rake | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100755 bin/setup create mode 100644 lib/tasks/database_tasks.rake diff --git a/bin/setup b/bin/setup new file mode 100755 index 0000000..d4fe335 --- /dev/null +++ b/bin/setup @@ -0,0 +1 @@ +bash -c "$(curl -s https://raw.github.com/brightbit/bin_setup/master/bin/setup)" diff --git a/db/schema.rb b/db/schema.rb index 4dfbb16..ea89ed5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -13,4 +13,7 @@ ActiveRecord::Schema.define(version: 0) do + # These are extensions that must be enabled in order to support this database + enable_extension "plpgsql" + end diff --git a/lib/tasks/database_tasks.rake b/lib/tasks/database_tasks.rake new file mode 100644 index 0000000..9e201fc --- /dev/null +++ b/lib/tasks/database_tasks.rake @@ -0,0 +1,32 @@ +# monkey patch ActiveRecord to avoid There are n other session(s) using the database. +module ActiveRecord + module Tasks # :nodoc: + module DatabaseTasks + extend self + + def configuration + @arguments.first + end + + def pg_adapter + class_for_adapter(configuration['adapter']).new(*@arguments) + end + + def terminate_existing_connetions + pg_adapter.establish_connection(*@arguments) + pg_adapter.connection.select_all("select * from pg_stat_activity order by pid;").each do |x| + if configuration['database'] == x['datname'] && x['state'] == "idle" + pg_adapter.connection.execute("select pg_terminate_backend(#{x['pid']})") + end + end + end + + def drop(*arguments) + @arguments = arguments + terminate_existing_connetions + pg_adapter.drop + rescue Exception => error + end + end + end +end From bfaff6b16483007b6678e4c264d162a1e952fd25 Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Thu, 9 Jan 2014 18:24:41 -0600 Subject: [PATCH 07/39] Add logger for AR validation errors --- .../log_active_record_validation_errors.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 config/initializers/log_active_record_validation_errors.rb diff --git a/config/initializers/log_active_record_validation_errors.rb b/config/initializers/log_active_record_validation_errors.rb new file mode 100644 index 0000000..e1a9bb9 --- /dev/null +++ b/config/initializers/log_active_record_validation_errors.rb @@ -0,0 +1,11 @@ +def log_arv_errors + if self.errors.any? + Rails.logger.warn "#{self.class} failed to save!" + Rails.logger.warn "Attributes: " + Rails.logger.warn self.attributes + Rails.logger.warn "Errors: " + Rails.logger.warn self.errors.full_messages.join("\n") + end +end + +ActiveRecord::Base.send(:after_validation, :log_arv_errors) From b9d8785e5b01a3ece1d384c726c5c4719517c721 Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Thu, 9 Jan 2014 18:40:31 -0600 Subject: [PATCH 08/39] Add unicorn and thin (dev) web servers --- Gemfile | 5 ++++- Gemfile.lock | 14 ++++++++++++++ config/unicorn.rb | 28 ++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 config/unicorn.rb diff --git a/Gemfile b/Gemfile index b580ca1..5be663b 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,8 @@ source 'https://rubygems.org' gem 'rails', '4.1.0.beta1' -gem 'pg', '~> 0.17.1' +gem 'pg', '~> 0.17.1' # Postgres ActiveRecord adapter +gem 'unicorn', '~> 4.7.0' # HTTP server for fast clients on low-latency, high-bandwidth connections # Asset related gems gem 'sass-rails', '~> 4.0.0.rc1' @@ -17,7 +18,9 @@ gem 'sdoc', group: :doc, require: false # bundle exec rake doc:rails generates t group :development do gem 'spring' # Spring speeds up development by keeping your application running in the background + gem 'thin' # Fast threaded HTTP server for local development end + group :development, :test do gem 'dotenv-rails' # Autoload ENV vars in .env end diff --git a/Gemfile.lock b/Gemfile.lock index e6a74f0..7569226 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -37,10 +37,12 @@ GEM coffee-script-source execjs coffee-script-source (1.6.3) + daemons (1.1.9) dotenv (0.9.0) dotenv-rails (0.9.0) dotenv (= 0.9.0) erubis (2.7.0) + eventmachine (1.0.3) execjs (2.0.2) hike (1.2.3) i18n (0.6.9) @@ -51,6 +53,7 @@ GEM railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) json (1.8.1) + kgio (2.8.1) mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) @@ -77,6 +80,7 @@ GEM activesupport (= 4.1.0.beta1) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) + raindrops (0.12.0) rake (10.1.1) rdoc (3.12.2) json (~> 1.4) @@ -98,6 +102,10 @@ GEM actionpack (>= 3.0) activesupport (>= 3.0) sprockets (~> 2.8) + thin (1.6.1) + daemons (>= 1.0.9) + eventmachine (>= 1.0.0) + rack (>= 1.0.0) thor (0.18.1) thread_safe (0.1.3) atomic @@ -112,6 +120,10 @@ GEM uglifier (2.4.0) execjs (>= 0.3.0) json (>= 1.8.0) + unicorn (4.7.0) + kgio (~> 2.6) + rack + raindrops (~> 0.7) PLATFORMS ruby @@ -126,5 +138,7 @@ DEPENDENCIES sass-rails (~> 4.0.0.rc1) sdoc spring + thin turbolinks (~> 2.1.0) uglifier (~> 2.4.0) + unicorn (~> 4.7.0) diff --git a/config/unicorn.rb b/config/unicorn.rb new file mode 100644 index 0000000..f0c30cf --- /dev/null +++ b/config/unicorn.rb @@ -0,0 +1,28 @@ +worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3) +preload_app true +GC.respond_to?(:copy_on_write_friendly=) and GC.copy_on_write_friendly = true + +before_exec do |server| + ENV['RUBY_GC_HEAP_INIT_SLOTS']=800000 + ENV['RUBY_GC_MALLOC_LIMIT']=90000000 + ENV['RUBY_HEAP_SLOTS_INCREMENT']=10000 + ENV['RUBY_HEAP_SLOTS_GROWTH_FACTOR']=1 + ENV['RUBY_HEAP_FREE_MIN']=100000 +end + +before_fork do |server, worker| + Signal.trap 'TERM' do + puts 'Unicorn master intercepting TERM and sending myself QUIT instead' + Process.kill 'QUIT', Process.pid + end + + defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect! +end + +after_fork do |server, worker| + Signal.trap 'TERM' do + puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT' + end + + defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection +end From ed0fdfb1bcac2935505860dc4cbd6e6c5411585a Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Thu, 9 Jan 2014 18:42:00 -0600 Subject: [PATCH 09/39] Herokuify: Procfile and ruby version in Gemfile --- Gemfile | 2 ++ Procfile | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 Procfile diff --git a/Gemfile b/Gemfile index 5be663b..bf8a949 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,7 @@ source 'https://rubygems.org' +ruby '2.1.0' # Tell heroku to use ruby 2.1.0 + gem 'rails', '4.1.0.beta1' gem 'pg', '~> 0.17.1' # Postgres ActiveRecord adapter diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..94553f2 --- /dev/null +++ b/Procfile @@ -0,0 +1,2 @@ +web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb +worker: rake jobs:work From 2f79c78fe2db02d26a5724e6dc36921fbe3355ab Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Thu, 9 Jan 2014 18:52:49 -0600 Subject: [PATCH 10/39] Add envrc (make sure you direnv allow it) --- .envrc | 1 + .gitignore | 1 + 2 files changed, 2 insertions(+) create mode 100644 .envrc diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..310c115 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +export PATH=vendor/bundle/bin:bin:$PATH diff --git a/.gitignore b/.gitignore index 2eb5aec..f7526eb 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ tmp # Ignore enviroment variable files .env* !.env.example +!.envrc .powenv # Ignore swp files From c721b534bef289bb3be2a84f51ea1291021f5600 Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Thu, 9 Jan 2014 22:20:07 -0600 Subject: [PATCH 11/39] Always use SSL in production --- config/environments/production.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index f335833..48bdcec 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -40,7 +40,7 @@ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. - # config.force_ssl = true + config.force_ssl = true # Set to :debug to see everything in the log. config.log_level = :info From 13e63d7ea4dfae778fc6fd4554a529779e4884bd Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Thu, 9 Jan 2014 22:22:46 -0600 Subject: [PATCH 12/39] Add UUID to log entries on production --- config/environments/production.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index 48bdcec..d2bc17e 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -46,7 +46,7 @@ config.log_level = :info # Prepend all log lines with the following tags. - # config.log_tags = [ :subdomain, :uuid ] + config.log_tags = [ :uuid ] # Use a different logger for distributed setups. # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) From 6541c9a3823b3d921ad49909ee4286fae80d4029 Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Thu, 9 Jan 2014 22:23:50 -0600 Subject: [PATCH 13/39] Silence SQL and other logging in test --- config/environments/test.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/environments/test.rb b/config/environments/test.rb index ba0742f..2b47988 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -16,6 +16,9 @@ config.serve_static_assets = true config.static_cache_control = "public, max-age=3600" + # Silence SQL and other logging in test (tail log/test.log instead) + config.logger = nil + # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false From ea7fce70767d23683462a0bb33fbe43cf8272600 Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Fri, 10 Jan 2014 15:28:51 -0600 Subject: [PATCH 14/39] Use memcache in dev and prod --- Gemfile | 1 + Gemfile.lock | 2 ++ config/environments/development.rb | 5 ++++- config/environments/production.rb | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index bf8a949..bbe28a2 100644 --- a/Gemfile +++ b/Gemfile @@ -4,6 +4,7 @@ ruby '2.1.0' # Tell heroku to use ruby 2.1.0 gem 'rails', '4.1.0.beta1' +gem 'dalli', '~> 2.7.0' # High performance memcached client gem 'pg', '~> 0.17.1' # Postgres ActiveRecord adapter gem 'unicorn', '~> 4.7.0' # HTTP server for fast clients on low-latency, high-bandwidth connections diff --git a/Gemfile.lock b/Gemfile.lock index 7569226..c04f42d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -38,6 +38,7 @@ GEM execjs coffee-script-source (1.6.3) daemons (1.1.9) + dalli (2.7.0) dotenv (0.9.0) dotenv-rails (0.9.0) dotenv (= 0.9.0) @@ -130,6 +131,7 @@ PLATFORMS DEPENDENCIES coffee-rails (~> 4.0.0) + dalli (~> 2.7.0) dotenv-rails jbuilder (~> 1.2) jquery-rails (~> 3.0.4) diff --git a/config/environments/development.rb b/config/environments/development.rb index 01aca64..28bfb50 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -11,7 +11,10 @@ # Show full error reports and disable caching. config.consider_all_requests_local = true - config.action_controller.perform_caching = false + config.action_controller.perform_caching = true + + # Cache stuff in memcache + config.cache_store = :dalli_store, { expires_in: 10.minutes } # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false diff --git a/config/environments/production.rb b/config/environments/production.rb index d2bc17e..b8b13ba 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -52,7 +52,7 @@ # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) # Use a different cache store in production. - # config.cache_store = :mem_cache_store + config.cache_store = :dalli_store # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.action_controller.asset_host = "http://assets.example.com" From fd9b5a167f69599022ee58e6dfcd654ee4946d4f Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Fri, 10 Jan 2014 15:53:18 -0600 Subject: [PATCH 15/39] Setup assets in production --- config/environments/production.rb | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index b8b13ba..5ed65a4 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -19,22 +19,28 @@ # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. # config.action_dispatch.rack_cache = true - # Disable Rails's static asset server (Apache or nginx will already do this). - config.serve_static_assets = false + # Enable Rails's static asset server (for passthrough CDNs). + config.serve_static_assets = true # Compress JavaScripts and CSS. config.assets.js_compressor = :uglifier # config.assets.css_compressor = :sass - # Do not fallback to assets pipeline if a precompiled asset is missed. - config.assets.compile = false + # Fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = true # Generate digests for assets URLs. config.assets.digest = true + # Keep static assets for 300 days + config.static_cache_control = "public, max-age=2592000" + # Version of your assets, change this if you want to expire all your assets. config.assets.version = '1.0' + # Cache assets between deloys (speeds up heroku deploys) + config.assets.configure {|env| env.cache = ActiveSupport::Cache.lookup_store(:dalli_store) } + # Specifies the header that your server uses for sending files. # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx @@ -54,6 +60,12 @@ # Use a different cache store in production. config.cache_store = :dalli_store + # Add the fonts path + config.assets.paths << Rails.root.join('app', 'assets', 'fonts') + + # Precompile additional assets + config.assets.precompile += %w( .svg .eot .woff .ttf ) + # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.action_controller.asset_host = "http://assets.example.com" From 4e14f4b73709769fb19de3ca0d4bbf2f3d0bed1f Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Mon, 13 Jan 2014 18:29:58 -0600 Subject: [PATCH 16/39] Add american_date gem for native MM/DD/YY parsing --- Gemfile | 7 ++++--- Gemfile.lock | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index bbe28a2..5adc534 100644 --- a/Gemfile +++ b/Gemfile @@ -4,9 +4,10 @@ ruby '2.1.0' # Tell heroku to use ruby 2.1.0 gem 'rails', '4.1.0.beta1' -gem 'dalli', '~> 2.7.0' # High performance memcached client -gem 'pg', '~> 0.17.1' # Postgres ActiveRecord adapter -gem 'unicorn', '~> 4.7.0' # HTTP server for fast clients on low-latency, high-bandwidth connections +gem 'american_date', '~> 1.1.0' # American style month/day/year date parsing +gem 'dalli', '~> 2.7.0' # High performance memcached client +gem 'pg', '~> 0.17.1' # Postgres ActiveRecord adapter +gem 'unicorn', '~> 4.7.0' # HTTP server for fast clients on low-latency, high-bandwidth connections # Asset related gems gem 'sass-rails', '~> 4.0.0.rc1' diff --git a/Gemfile.lock b/Gemfile.lock index c04f42d..a954f79 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -27,6 +27,7 @@ GEM minitest (~> 5.1) thread_safe (~> 0.1) tzinfo (~> 1.1) + american_date (1.1.0) arel (5.0.0) atomic (1.1.14) builder (3.2.2) @@ -130,6 +131,7 @@ PLATFORMS ruby DEPENDENCIES + american_date (~> 1.1.0) coffee-rails (~> 4.0.0) dalli (~> 2.7.0) dotenv-rails From adfb45d634485f30e570ed247842f401acb44a05 Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Mon, 13 Jan 2014 18:37:32 -0600 Subject: [PATCH 17/39] Add momentjs for javascript time parsing --- Gemfile | 11 ++++++----- Gemfile.lock | 3 +++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index 5adc534..ca153fc 100644 --- a/Gemfile +++ b/Gemfile @@ -10,11 +10,12 @@ gem 'pg', '~> 0.17.1' # Postgres ActiveRecord adapter gem 'unicorn', '~> 4.7.0' # HTTP server for fast clients on low-latency, high-bandwidth connections # Asset related gems -gem 'sass-rails', '~> 4.0.0.rc1' -gem 'uglifier', '~> 2.4.0' -gem 'coffee-rails', '~> 4.0.0' -gem 'jquery-rails', '~> 3.0.4' -gem 'turbolinks', '~> 2.1.0' +gem 'coffee-rails', '~> 4.0.0' +gem 'jquery-rails', '~> 3.0.4' +gem 'momentjs-rails', '~> 2.5.0' +gem 'sass-rails', '~> 4.0.0.rc1' +gem 'turbolinks', '~> 2.1.0' +gem 'uglifier', '~> 2.4.0' gem 'jbuilder', '~> 1.2' # Build JSON APIs with ease diff --git a/Gemfile.lock b/Gemfile.lock index a954f79..eb8099c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -61,6 +61,8 @@ GEM treetop (~> 1.4.8) mime-types (1.25.1) minitest (5.2.1) + momentjs-rails (2.5.0) + railties (>= 3.1) multi_json (1.8.3) pg (0.17.1) polyglot (0.3.3) @@ -137,6 +139,7 @@ DEPENDENCIES dotenv-rails jbuilder (~> 1.2) jquery-rails (~> 3.0.4) + momentjs-rails (~> 2.5.0) pg (~> 0.17.1) rails (= 4.1.0.beta1) sass-rails (~> 4.0.0.rc1) From 31f7420a4e51cc6a5fdd82ce4dc77e480fbb2a4a Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Mon, 13 Jan 2014 18:47:41 -0600 Subject: [PATCH 18/39] Add pry gems for development and test --- Gemfile | 5 ++++- Gemfile.lock | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index ca153fc..eec1f56 100644 --- a/Gemfile +++ b/Gemfile @@ -27,5 +27,8 @@ group :development do end group :development, :test do - gem 'dotenv-rails' # Autoload ENV vars in .env + gem 'dotenv-rails' # Autoload ENV vars in .env + gem 'pry-awesome_print' # Auto AP in pry + gem 'pry-rails' # Interactive REPL debugger + gem 'pry-plus' # Add a bunch of awesome pry stuff (rescue, stack_explorer, doc) end diff --git a/Gemfile.lock b/Gemfile.lock index eb8099c..a0f7ebd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -30,7 +30,12 @@ GEM american_date (1.1.0) arel (5.0.0) atomic (1.1.14) + awesome_print (1.1.0) + binding_of_caller (0.7.2) + debug_inspector (>= 0.0.1) + bond (0.5.0) builder (3.2.2) + coderay (1.1.0) coffee-rails (4.0.1) coffee-script (>= 2.2.0) railties (>= 4.0.0, < 5.0) @@ -38,8 +43,16 @@ GEM coffee-script-source execjs coffee-script-source (1.6.3) + columnize (0.3.6) daemons (1.1.9) dalli (2.7.0) + debug_inspector (0.0.2) + debugger (1.6.5) + columnize (>= 0.3.1) + debugger-linecache (~> 1.2.0) + debugger-ruby_core_source (~> 1.3.1) + debugger-linecache (1.2.0) + debugger-ruby_core_source (1.3.1) dotenv (0.9.0) dotenv-rails (0.9.0) dotenv (= 0.9.0) @@ -48,9 +61,12 @@ GEM execjs (2.0.2) hike (1.2.3) i18n (0.6.9) + interception (0.3) jbuilder (1.5.3) activesupport (>= 3.0.0) multi_json (>= 1.2.0) + jist (1.5.1) + json jquery-rails (3.0.4) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) @@ -59,6 +75,7 @@ GEM mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) + method_source (0.8.2) mime-types (1.25.1) minitest (5.2.1) momentjs-rails (2.5.0) @@ -66,6 +83,38 @@ GEM multi_json (1.8.3) pg (0.17.1) polyglot (0.3.3) + pry (0.9.12.4) + coderay (~> 1.0) + method_source (~> 0.8) + slop (~> 3.4) + pry-awesome_print (9.6.8) + awesome_print (~> 1.1.0) + pry (~> 0.9.0) + pry-debugger (0.2.2) + debugger (~> 1.3) + pry (~> 0.9.10) + pry-doc (0.5.1) + pry (>= 0.9) + yard (>= 0.8) + pry-docmore (0.1.1) + pry + pry-doc + pry-plus (1.0.0) + bond + jist + pry-debugger + pry-doc + pry-docmore + pry-rescue + pry-stack_explorer + pry-rails (0.3.2) + pry (>= 0.9.10) + pry-rescue (1.2.0) + interception (>= 0.3) + pry + pry-stack_explorer (0.4.9.1) + binding_of_caller (>= 0.7) + pry (>= 0.9.11) rack (1.5.2) rack-test (0.6.2) rack (>= 1.0) @@ -96,6 +145,7 @@ GEM sdoc (0.3.20) json (>= 1.1.3) rdoc (~> 3.10) + slop (3.4.7) spring (1.0.0) sprockets (2.10.1) hike (~> 1.2) @@ -128,6 +178,7 @@ GEM kgio (~> 2.6) rack raindrops (~> 0.7) + yard (0.8.7.3) PLATFORMS ruby @@ -141,6 +192,9 @@ DEPENDENCIES jquery-rails (~> 3.0.4) momentjs-rails (~> 2.5.0) pg (~> 0.17.1) + pry-awesome_print + pry-plus + pry-rails rails (= 4.1.0.beta1) sass-rails (~> 4.0.0.rc1) sdoc From 5d10623143e12b43cc06e9d31f7480e6931b39d4 Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Mon, 13 Jan 2014 19:16:33 -0600 Subject: [PATCH 19/39] Add minitest --- Gemfile | 9 +++++---- Gemfile.lock | 4 ++++ Rakefile | 3 +++ test/test_helper.rb | 4 ++++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index eec1f56..1f1b1ae 100644 --- a/Gemfile +++ b/Gemfile @@ -27,8 +27,9 @@ group :development do end group :development, :test do - gem 'dotenv-rails' # Autoload ENV vars in .env - gem 'pry-awesome_print' # Auto AP in pry - gem 'pry-rails' # Interactive REPL debugger - gem 'pry-plus' # Add a bunch of awesome pry stuff (rescue, stack_explorer, doc) + gem 'dotenv-rails' # Autoload ENV vars in .env + gem 'minitest-spec-rails' # MiniTest integration for Rails 3 and 4 + gem 'pry-awesome_print' # Auto AP in pry + gem 'pry-rails' # Interactive REPL debugger + gem 'pry-plus' # Add a bunch of awesome pry stuff (rescue, stack_explorer, doc) end diff --git a/Gemfile.lock b/Gemfile.lock index a0f7ebd..0ef3ff9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -78,6 +78,9 @@ GEM method_source (0.8.2) mime-types (1.25.1) minitest (5.2.1) + minitest-spec-rails (5.0.2) + minitest (~> 5.0) + rails (>= 4.1.0.beta, < 5.0) momentjs-rails (2.5.0) railties (>= 3.1) multi_json (1.8.3) @@ -190,6 +193,7 @@ DEPENDENCIES dotenv-rails jbuilder (~> 1.2) jquery-rails (~> 3.0.4) + minitest-spec-rails momentjs-rails (~> 2.5.0) pg (~> 0.17.1) pry-awesome_print diff --git a/Rakefile b/Rakefile index ba6b733..d119c1e 100644 --- a/Rakefile +++ b/Rakefile @@ -4,3 +4,6 @@ require File.expand_path('../config/application', __FILE__) Rails.application.load_tasks + +Rake::Task['default'].clear +task default: 'test:all' diff --git a/test/test_helper.rb b/test/test_helper.rb index bc7e05d..04b2025 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,6 +1,7 @@ ENV["RAILS_ENV"] ||= "test" require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' +require 'dotenv'; Dotenv.load class ActiveSupport::TestCase ActiveRecord::Migration.check_pending! @@ -13,3 +14,6 @@ class ActiveSupport::TestCase # Add more helper methods to be used by all tests here... end + +# Load all support files +Dir[File.expand_path('support/**/*.rb', __dir__)].each { |f| require f } From 2aa779786b39a402fbd37a2f4ffe7da908cbb440 Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Mon, 13 Jan 2014 19:47:03 -0600 Subject: [PATCH 20/39] Add minitest reporters (turn replacement) --- Gemfile | 1 + Gemfile.lock | 11 +++++++++++ test/test_helper.rb | 1 + 3 files changed, 13 insertions(+) diff --git a/Gemfile b/Gemfile index 1f1b1ae..d8c1fe5 100644 --- a/Gemfile +++ b/Gemfile @@ -29,6 +29,7 @@ end group :development, :test do gem 'dotenv-rails' # Autoload ENV vars in .env gem 'minitest-spec-rails' # MiniTest integration for Rails 3 and 4 + gem 'minitest-reporters' # Customizable MiniTest output formats gem 'pry-awesome_print' # Auto AP in pry gem 'pry-rails' # Interactive REPL debugger gem 'pry-plus' # Add a bunch of awesome pry stuff (rescue, stack_explorer, doc) diff --git a/Gemfile.lock b/Gemfile.lock index 0ef3ff9..5b83cbe 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -28,6 +28,7 @@ GEM thread_safe (~> 0.1) tzinfo (~> 1.1) american_date (1.1.0) + ansi (1.4.3) arel (5.0.0) atomic (1.1.14) awesome_print (1.1.0) @@ -59,6 +60,7 @@ GEM erubis (2.7.0) eventmachine (1.0.3) execjs (2.0.2) + hashie (2.0.5) hike (1.2.3) i18n (0.6.9) interception (0.3) @@ -78,6 +80,11 @@ GEM method_source (0.8.2) mime-types (1.25.1) minitest (5.2.1) + minitest-reporters (1.0.0) + ansi + builder + minitest (>= 5.0) + powerbar minitest-spec-rails (5.0.2) minitest (~> 5.0) rails (>= 4.1.0.beta, < 5.0) @@ -86,6 +93,9 @@ GEM multi_json (1.8.3) pg (0.17.1) polyglot (0.3.3) + powerbar (1.0.11) + ansi (~> 1.4.0) + hashie (>= 1.1.0) pry (0.9.12.4) coderay (~> 1.0) method_source (~> 0.8) @@ -193,6 +203,7 @@ DEPENDENCIES dotenv-rails jbuilder (~> 1.2) jquery-rails (~> 3.0.4) + minitest-reporters minitest-spec-rails momentjs-rails (~> 2.5.0) pg (~> 0.17.1) diff --git a/test/test_helper.rb b/test/test_helper.rb index 04b2025..e0fbd51 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -2,6 +2,7 @@ require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' require 'dotenv'; Dotenv.load +require 'minitest/reporters'; Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new class ActiveSupport::TestCase ActiveRecord::Migration.check_pending! From b0cbc3bc37318f952712f148afdb49e510b43a09 Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Mon, 13 Jan 2014 20:02:38 -0600 Subject: [PATCH 21/39] Add autotest-rails for running tests in changes --- Gemfile | 1 + Gemfile.lock | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/Gemfile b/Gemfile index d8c1fe5..c588be8 100644 --- a/Gemfile +++ b/Gemfile @@ -27,6 +27,7 @@ group :development do end group :development, :test do + gem 'autotest-rails' # Run 'autotest' to continually run your tests on change gem 'dotenv-rails' # Autoload ENV vars in .env gem 'minitest-spec-rails' # MiniTest integration for Rails 3 and 4 gem 'minitest-reporters' # Customizable MiniTest output formats diff --git a/Gemfile.lock b/Gemfile.lock index 5b83cbe..5854b5f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,7 @@ GEM remote: https://rubygems.org/ specs: + ZenTest (4.9.5) actionmailer (4.1.0.beta1) actionpack (= 4.1.0.beta1) actionview (= 4.1.0.beta1) @@ -31,6 +32,8 @@ GEM ansi (1.4.3) arel (5.0.0) atomic (1.1.14) + autotest-rails (4.2.1) + ZenTest (~> 4.5) awesome_print (1.1.0) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) @@ -198,6 +201,7 @@ PLATFORMS DEPENDENCIES american_date (~> 1.1.0) + autotest-rails coffee-rails (~> 4.0.0) dalli (~> 2.7.0) dotenv-rails From 3025c9df407a5adf96afce340674bb9e6536233d Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Tue, 14 Jan 2014 21:21:24 -0600 Subject: [PATCH 22/39] Rename `rename` to `rails-rename` to avoid conflict --- bin/{rename => rails-rename} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename bin/{rename => rails-rename} (55%) diff --git a/bin/rename b/bin/rails-rename similarity index 55% rename from bin/rename rename to bin/rails-rename index 29be61a..950d144 100755 --- a/bin/rename +++ b/bin/rails-rename @@ -4,5 +4,5 @@ input_string=${2:-MyApp} input_string_underscored=$(ruby -r'active_support/inflector' -e "puts '$input_string'.strip.underscore") output_string=$1 output_string_underscored=$(ruby -r'active_support/inflector' -e "puts '$output_string'.strip.underscore") -git grep -l -e "$input_string" | grep -v 'bin/rename' | xargs sed -i '' "s/$input_string/$output_string/g" -git grep -l -e "$input_string_underscored" | grep -v 'bin/rename' | xargs sed -i '' "s/$input_string_underscored/$output_string_underscored/g" +git grep -l -e "$input_string" | grep -v 'bin/rails-rename' | xargs sed -i '' "s/$input_string/$output_string/g" +git grep -l -e "$input_string_underscored" | grep -v 'bin/rails-rename' | xargs sed -i '' "s/$input_string_underscored/$output_string_underscored/g" From 454b9460cf3acf43b4daefd1d902dd8a460a6804 Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Tue, 14 Jan 2014 23:38:29 -0600 Subject: [PATCH 23/39] Add lots of environment tests - Add `rake test:environments` which iterates over `test/environments` and runs each file in a separate ruby process (to isolate requires) - Check presence of multiple files (.envrc, .env.example, bin/setup, etc) - Check AR validation errors are logged - Ensure presence of gems, bins and assets - Ensure SSL required in production --- lib/tasks/test_environment.rake | 8 +++ test/environments/application.rb | 104 +++++++++++++++++++++++++++++++ test/environments/development.rb | 10 +++ test/environments/production.rb | 10 +++ test/environments/test.rb | 14 +++++ 5 files changed, 146 insertions(+) create mode 100644 lib/tasks/test_environment.rake create mode 100644 test/environments/application.rb create mode 100644 test/environments/development.rb create mode 100644 test/environments/production.rb create mode 100644 test/environments/test.rb diff --git a/lib/tasks/test_environment.rake b/lib/tasks/test_environment.rake new file mode 100644 index 0000000..0e0bb39 --- /dev/null +++ b/lib/tasks/test_environment.rake @@ -0,0 +1,8 @@ +namespace :test do + desc "Run environment tests for each environment" + task environments: :environment do + Dir[File.expand_path('test/environments/*.rb', Rails.root)].each do |f| + system("ruby -Itest -Iconfig/environments #{f}") + end + end +end diff --git a/test/environments/application.rb b/test/environments/application.rb new file mode 100644 index 0000000..16f9ffd --- /dev/null +++ b/test/environments/application.rb @@ -0,0 +1,104 @@ +require 'test_helper' +require 'mkmf' + +describe "General Environment" do + it "has an application name" do + # This will need changing when you rename your app manually + Rails.application.class.parent_name.must_equal "MyApp" + end + + it "uses american date" do + DateTime.parse('01/10/1999').month.must_equal 1 + end + + it "has a rails-rename bin" do + File.size(Rails.root + 'bin/rails-rename').must_equal 589 + end + + it "has a setup bin" do + File.size(Rails.root + 'bin/setup').must_equal 81 + end + + it "has a .env.example" do + File.exist?(Rails.root + '.env.example').must_equal true + end + + it "has a .envrc" do + File.exist?(Rails.root + '.envrc').must_equal true + end + + it "has a Procfile" do + File.exist?(Rails.root + 'Procfile').must_equal true + end + + it "has a unicorn config" do + File.exist?(Rails.root + 'config/unicorn.rb').must_equal true + end + + it "disconnects currently connected database connections" do + File.size(Rails.root + 'lib/tasks/database_tasks.rake').must_equal 912 + end + + it "will output details on AR validation error" do + @output = StringIO.new + @logger = Logger.new(@output) + Rails.logger = @logger + + class TestImp < ActiveRecord::Base + def self.columns; []; end; def self.column_types; {}; end # Set up a tableless AR Model + + attr_accessor :name + validates_presence_of :name + end + + TestImp.new.save + @output.string.must_include %Q[WARN -- : TestImp failed to save!] + @output.string.must_include %Q[WARN -- : Attributes:] + @output.string.must_include %Q[WARN -- : {"id"=>nil}] + @output.string.must_include %Q[WARN -- : Errors:] + @output.string.must_include %Q[WARN -- : Name can't be blank] + end + + describe "Gems" do + it "has momentjs available" do + Rails.application.config.assets.paths.any? {|p| p.include? 'momentjs-rails' } + end + + it "has dalli available" do + ActiveSupport::Cache.lookup_store(:dalli_store).stats.values.wont_include nil + end + + it "has pg available" do + defined?(PG).wont_be_nil + ActiveRecord::Base.connection.wont_be_nil + end + + it "has unicorn available" do + defined?(Unicorn).wont_be_nil + end + + it "has autotest-rails available" do + defined?(Autotest::Rails).wont_be_nil + end + end + + describe "Bins" do + it "has direnv installed and configured" do + %x[direnv status].must_include 'Found RC allowed true' + ENV['PATH'].split(':').grep('^bin$').wont_be_nil + ENV['PATH'].split(':').grep('^vendor/bundle/bin$').wont_be_nil + end + + it "has autotest" do + system("command -v autotest >/dev/null 2>&1").must_equal true + end + + it "has imagemagick" do + system("command -v identify >/dev/null 2>&1").must_equal true + end + + it "has phantomjs" do + system("command -v phantomjs >/dev/null 2>&1").must_equal true + end + end +end diff --git a/test/environments/development.rb b/test/environments/development.rb new file mode 100644 index 0000000..f9469ca --- /dev/null +++ b/test/environments/development.rb @@ -0,0 +1,10 @@ +require 'test_helper' +require 'development' + +describe "Development Environment" do + describe "Gems" do + it "has dotenv" do + defined?(Dotenv).wont_equal nil + end + end +end diff --git a/test/environments/production.rb b/test/environments/production.rb new file mode 100644 index 0000000..a983195 --- /dev/null +++ b/test/environments/production.rb @@ -0,0 +1,10 @@ +require 'test_helper' +require 'production' + +describe "Production Environment" do + it "only allows SSL in production" do + Rails.application.config.force_ssl.must_equal true + end + + #TODO: Check all the different production env configs (fonts in pipeline, caching, etc) +end diff --git a/test/environments/test.rb b/test/environments/test.rb new file mode 100644 index 0000000..0ba636d --- /dev/null +++ b/test/environments/test.rb @@ -0,0 +1,14 @@ +require 'test_helper' +require 'test' + +describe "Test Environment" do + describe "Gems" do + it "has minitest-reporters" do + defined?(Minitest::Reporters).wont_be_nil + end + + it "has pry" do + defined?(Pry).wont_be_nil + end + end +end From 3c2d0997fd7ad38069fc7672ab65b85ced263816 Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Wed, 15 Jan 2014 00:25:01 -0600 Subject: [PATCH 24/39] Add old README.md --- README.md | 9 +++++++++ README.rdoc | 28 ---------------------------- 2 files changed, 9 insertions(+), 28 deletions(-) create mode 100644 README.md delete mode 100644 README.rdoc diff --git a/README.md b/README.md new file mode 100644 index 0000000..5468001 --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ + +------------------ + + + +### Contributing ### + +See [contributing.md](contributing.md) for development process guidance. + diff --git a/README.rdoc b/README.rdoc deleted file mode 100644 index dd4e97e..0000000 --- a/README.rdoc +++ /dev/null @@ -1,28 +0,0 @@ -== README - -This README would normally document whatever steps are necessary to get the -application up and running. - -Things you may want to cover: - -* Ruby version - -* System dependencies - -* Configuration - -* Database creation - -* Database initialization - -* How to run the test suite - -* Services (job queues, cache servers, search engines, etc.) - -* Deployment instructions - -* ... - - -Please feel free to use a different markup language if you do not plan to run -rake doc:app. From 1b4e1bdd35fdaa3b1a1a33f29942607722aa34ea Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Wed, 15 Jan 2014 00:29:52 -0600 Subject: [PATCH 25/39] Replace 'rails-template' with dynamic app name --- config/initializers/session_store.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index 0fc7dbb..639915c 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,3 +1,3 @@ # Be sure to restart your server when you modify this file. -Rails.application.config.session_store :cookie_store, key: '_rails-template_session' +Rails.application.config.session_store :cookie_store, key: "_#{Rails.application.class.parent_name.underscore}_session" From c12408292ecd0e010266673bfd101eed8d973a4a Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Wed, 15 Jan 2014 00:32:52 -0600 Subject: [PATCH 26/39] Add back contributing.md --- contributing.md | 179 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 contributing.md diff --git a/contributing.md b/contributing.md new file mode 100644 index 0000000..1c03b89 --- /dev/null +++ b/contributing.md @@ -0,0 +1,179 @@ +# Reporting issues + +Titles should be concise and <55 characters (like commit messages). + +Please use this template for bug reports: + +```markdown +## Description of Problem + +One or two sentences giving an overview of the issue. + +## System details + +* **Browser**: Chrome 29 + +* **OS**: Mac OS X 10.9.0 + +## Steps to Reproduce + + 1. Went to [Giant Coffee mug](https://example.com/products/123) + + 2. Clicked "Launch Ponies" + +## HAR file (Attach only if applicable and reproducable in Chrome) + + * [HAR](http://example.com/issue_123.har) + +## Observed Behavior + + * Ponies die + +## Expected Behavior + + * Ponies survive +``` + +# Adding a feature/fixing a bug (developer) + +* Have each feature/fix in a single commit. You can create mutliple + commits, but rebase them together before doing a pull request. + +* Each commit should be a working set of changes (don't commit one change with + another fix commit after it). If you want to get your code off your computer + add "@wip" to the commit message and then rebase over it later. (This doesn't + work well if you're collaborating on a branch. A branch with your initials at + the front [e.g. eb-add_minitest] signifies it's your personal branch.) + +* Never push to the master branch. Use feature branches instead, as detailed below. + If you ever do push to master, make sure to *never* do a forced push to master. + This will avoid the potential for much pain and gnashing of teeth. + +* In feature branches, we do encourage forced push to clean up commit history. + However, even in a feature branch, use great care if anyone else might be + collaborating on the same branch. + +* When feasible, program production code with a pair. + +* Even when pair programming is not feasible, allow a second developer to review + production code and merge it to master after any discussion and revision. In + other words: a developer other than the author should merge the pull request. + +## A good workflow when you're ready to fix something: + +1. Make sure you're on master and up to date (note a rebase not merge): + + ```bash + git checkout master + git pull --rebase + ``` + +2. Make a feature branch for your fix: + + ```bash + git checkout -b eb-add_minitest + ``` + +3. *do your work*, then: + +4. Add all files not checked in (make sure you don't have family_photo.jpg in the + directory): + + ```bash + git add . + ``` + +5. Commit the changes; --verbose add the full git diff to comments in the commit + message for your reviewing: + + ```bash + git commit --verbose + ``` + +6. When you run the above command it will open your EDITOR and ask for a commit + message. Provide + * a <55 character one line title, followed by + * two newlines, followed by + * a paragraph of what was changed, followed by + * a bulleted list of changes. + + See: https://github.com/brightbit/swagexpert/commit/bb4a46a80245f4362b59855274ef697eb143d8b2) + +7. This is a good time to do an interactive rebase to squash any excess commits. + + ```bash + git rebase -i HEAD~4 + ``` + +8. Next push the changes to github (this sets the upstream for the pull request): + + ```bash + git push -u origin eb-add_minitest + ``` + +9. And make the pull request: + + ```bash + hub pull-request + ``` + + (This opens EDITOR so you can write the pull request; after save/quit it + provides the link to the PR. See https://github.com/github/hub for installation.) + +This looks like a lot but with some aliases such as in [dotfiles](http://github.com/ericboehs/dotfiles) +it can look something like this: + +```bash +gco -b eb-add_minitest +``` +*do work* + +```bash +gacpr +``` + +# Environment Setup + +1. To satisfy the PostgreSQL dependency, ensure that either + a. You don't have PostgreSQL installed at all (step 2 will install it), or + b. PostgreSQL 9.2+ is running on the default port of 5433. +2. Run script/setup from the shell console. +3. Install PhantomJS 1.8.1+ on your machine, in order to run the test suite + +To have a fully running local development environment, you'll need to replace the dummy values in .env with real ones. +Most of these can be obtained by running `heroku config -s` on the console. You'll also need a working S3 bucket for some functionality. + +## Configure a development S3 Bucket + +One exception is configuring S3 for development. You'll need to create a real S3 bucket that matches the value of your +FOG_DIRECTORY variable. That bucket will need to be fully writeable by the user specified in your +AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY environment variables. Also, you will need to add a CORS configuration like the +following to the bucket: + +```xml + + + + *://localhost:3000 + GET + POST + PUT + 3000 + * + + + *://appname.dev + GET + POST + PUT + 3000 + * + + + * + GET + 3000 + Authorization + + +``` From c8b38e564b2000f7c7e16196dacf1a99fbe3e919 Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Wed, 15 Jan 2014 00:53:23 -0600 Subject: [PATCH 27/39] SQUASH ME: Remove unnecessary require 'mkmf' (clean up) --- test/environments/application.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/test/environments/application.rb b/test/environments/application.rb index 16f9ffd..425c1b6 100644 --- a/test/environments/application.rb +++ b/test/environments/application.rb @@ -1,5 +1,4 @@ require 'test_helper' -require 'mkmf' describe "General Environment" do it "has an application name" do From 4a133d907d0c53a6f4801630afcf2dea1503b93f Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Wed, 15 Jan 2014 17:25:40 -0600 Subject: [PATCH 28/39] Add QueueClassic --- Gemfile | 1 + Gemfile.lock | 3 + config/application.rb | 9 +- .../20140115230618_add_queue_classic.rb | 9 + db/schema.rb | 19 -- db/structure.sql | 204 ++++++++++++++++++ 6 files changed, 219 insertions(+), 26 deletions(-) create mode 100644 db/migrate/20140115230618_add_queue_classic.rb delete mode 100644 db/schema.rb create mode 100644 db/structure.sql diff --git a/Gemfile b/Gemfile index c588be8..753f982 100644 --- a/Gemfile +++ b/Gemfile @@ -7,6 +7,7 @@ gem 'rails', '4.1.0.beta1' gem 'american_date', '~> 1.1.0' # American style month/day/year date parsing gem 'dalli', '~> 2.7.0' # High performance memcached client gem 'pg', '~> 0.17.1' # Postgres ActiveRecord adapter +gem 'queue_classic', '~> 3.0.0rc' # Backgrounding queue that uses postgres for its queue gem 'unicorn', '~> 4.7.0' # HTTP server for fast clients on low-latency, high-bandwidth connections # Asset related gems diff --git a/Gemfile.lock b/Gemfile.lock index 5854b5f..a3a2a7f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -131,6 +131,8 @@ GEM pry-stack_explorer (0.4.9.1) binding_of_caller (>= 0.7) pry (>= 0.9.11) + queue_classic (3.0.0rc) + pg (~> 0.17.0) rack (1.5.2) rack-test (0.6.2) rack (>= 1.0) @@ -214,6 +216,7 @@ DEPENDENCIES pry-awesome_print pry-plus pry-rails + queue_classic (~> 3.0.0rc) rails (= 4.1.0.beta1) sass-rails (~> 4.0.0.rc1) sdoc diff --git a/config/application.rb b/config/application.rb index 51b8991..398a0cd 100644 --- a/config/application.rb +++ b/config/application.rb @@ -12,12 +12,7 @@ class Application < Rails::Application # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. - # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. - # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. - # config.time_zone = 'Central Time (US & Canada)' - - # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. - # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] - # config.i18n.default_locale = :de + # Use SQL instead of Active Record's schema dumper when creating the database (for QueueClassic) + config.active_record.schema_format = :sql end end diff --git a/db/migrate/20140115230618_add_queue_classic.rb b/db/migrate/20140115230618_add_queue_classic.rb new file mode 100644 index 0000000..00ffb6a --- /dev/null +++ b/db/migrate/20140115230618_add_queue_classic.rb @@ -0,0 +1,9 @@ +class AddQueueClassic < ActiveRecord::Migration + def self.up + QC::Setup.create + end + + def self.down + QC::Setup.drop + end +end diff --git a/db/schema.rb b/db/schema.rb deleted file mode 100644 index ea89ed5..0000000 --- a/db/schema.rb +++ /dev/null @@ -1,19 +0,0 @@ -# encoding: UTF-8 -# This file is auto-generated from the current state of the database. Instead -# of editing this file, please use the migrations feature of Active Record to -# incrementally modify your database, and then regenerate this schema definition. -# -# Note that this schema.rb definition is the authoritative source for your -# database schema. If you need to create the application database on another -# system, you should be using db:schema:load, not running all the migrations -# from scratch. The latter is a flawed and unsustainable approach (the more migrations -# you'll amass, the slower it'll run and the greater likelihood for issues). -# -# It's strongly recommended that you check this file into your version control system. - -ActiveRecord::Schema.define(version: 0) do - - # These are extensions that must be enabled in order to support this database - enable_extension "plpgsql" - -end diff --git a/db/structure.sql b/db/structure.sql new file mode 100644 index 0000000..5e65862 --- /dev/null +++ b/db/structure.sql @@ -0,0 +1,204 @@ +-- +-- PostgreSQL database dump +-- + +SET statement_timeout = 0; +SET lock_timeout = 0; +SET client_encoding = 'UTF8'; +SET standard_conforming_strings = on; +SET check_function_bodies = false; +SET client_min_messages = warning; + +-- +-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: - +-- + +CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; + + +-- +-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: - +-- + +COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; + + +SET search_path = public, pg_catalog; + +SET default_tablespace = ''; + +SET default_with_oids = false; + +-- +-- Name: queue_classic_jobs; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- + +CREATE TABLE queue_classic_jobs ( + id bigint NOT NULL, + q_name text NOT NULL, + method text NOT NULL, + args json NOT NULL, + locked_at timestamp with time zone, + CONSTRAINT queue_classic_jobs_method_check CHECK ((length(method) > 0)), + CONSTRAINT queue_classic_jobs_q_name_check CHECK ((length(q_name) > 0)) +); + + +-- +-- Name: lock_head(character varying); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION lock_head(tname character varying) RETURNS SETOF queue_classic_jobs + LANGUAGE plpgsql + AS $_$ +BEGIN + RETURN QUERY EXECUTE 'SELECT * FROM lock_head($1,10)' USING tname; +END; +$_$; + + +-- +-- Name: lock_head(character varying, integer); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION lock_head(q_name character varying, top_boundary integer) RETURNS SETOF queue_classic_jobs + LANGUAGE plpgsql + AS $_$ +DECLARE + unlocked bigint; + relative_top integer; + job_count integer; +BEGIN + -- The purpose is to release contention for the first spot in the table. + -- The select count(*) is going to slow down dequeue performance but allow + -- for more workers. Would love to see some optimization here... + + EXECUTE 'SELECT count(*) FROM ' + || '(SELECT * FROM queue_classic_jobs WHERE q_name = ' + || quote_literal(q_name) + || ' LIMIT ' + || quote_literal(top_boundary) + || ') limited' + INTO job_count; + + SELECT TRUNC(random() * (top_boundary - 1)) + INTO relative_top; + + IF job_count < top_boundary THEN + relative_top = 0; + END IF; + + LOOP + BEGIN + EXECUTE 'SELECT id FROM queue_classic_jobs ' + || ' WHERE locked_at IS NULL' + || ' AND q_name = ' + || quote_literal(q_name) + || ' ORDER BY id ASC' + || ' LIMIT 1' + || ' OFFSET ' || quote_literal(relative_top) + || ' FOR UPDATE NOWAIT' + INTO unlocked; + EXIT; + EXCEPTION + WHEN lock_not_available THEN + -- do nothing. loop again and hope we get a lock + END; + END LOOP; + + RETURN QUERY EXECUTE 'UPDATE queue_classic_jobs ' + || ' SET locked_at = (CURRENT_TIMESTAMP)' + || ' WHERE id = $1' + || ' AND locked_at is NULL' + || ' RETURNING *' + USING unlocked; + + RETURN; +END; +$_$; + + +-- +-- Name: queue_classic_notify(); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION queue_classic_notify() RETURNS trigger + LANGUAGE plpgsql + AS $$ begin + perform pg_notify(new.q_name, ''); + return null; +end $$; + + +-- +-- Name: queue_classic_jobs_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE queue_classic_jobs_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: queue_classic_jobs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE queue_classic_jobs_id_seq OWNED BY queue_classic_jobs.id; + + +-- +-- Name: schema_migrations; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- + +CREATE TABLE schema_migrations ( + version character varying(255) NOT NULL +); + + +-- +-- Name: id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY queue_classic_jobs ALTER COLUMN id SET DEFAULT nextval('queue_classic_jobs_id_seq'::regclass); + + +-- +-- Name: queue_classic_jobs_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- + +ALTER TABLE ONLY queue_classic_jobs + ADD CONSTRAINT queue_classic_jobs_pkey PRIMARY KEY (id); + + +-- +-- Name: idx_qc_on_name_only_unlocked; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- + +CREATE INDEX idx_qc_on_name_only_unlocked ON queue_classic_jobs USING btree (q_name, id) WHERE (locked_at IS NULL); + + +-- +-- Name: unique_schema_migrations; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- + +CREATE UNIQUE INDEX unique_schema_migrations ON schema_migrations USING btree (version); + + +-- +-- Name: queue_classic_notify; Type: TRIGGER; Schema: public; Owner: - +-- + +CREATE TRIGGER queue_classic_notify AFTER INSERT ON queue_classic_jobs FOR EACH ROW EXECUTE PROCEDURE queue_classic_notify(); + + +-- +-- PostgreSQL database dump complete +-- + +SET search_path TO "$user",public; + +INSERT INTO schema_migrations (version) VALUES ('20140115230618'); + From c41f668c891289a4e00fbf05af99e4ca9f9b2bcf Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Wed, 15 Jan 2014 17:38:41 -0600 Subject: [PATCH 29/39] Protect us from ourselves (Raise on ForbiddenAttr) --- config/application.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/application.rb b/config/application.rb index 398a0cd..eb83db5 100644 --- a/config/application.rb +++ b/config/application.rb @@ -14,5 +14,8 @@ class Application < Rails::Application # Use SQL instead of Active Record's schema dumper when creating the database (for QueueClassic) config.active_record.schema_format = :sql + + # Raise errors when an unpermitted param is sent to a controller action + ActiveRecord::Base.send(:include, ActiveModel::ForbiddenAttributesProtection) end end From 243589666b7a7e67576f82b24ef930d646c7a53f Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Wed, 15 Jan 2014 17:42:39 -0600 Subject: [PATCH 30/39] Add rack canonical host --- Gemfile | 11 ++++++----- Gemfile.lock | 5 +++++ config.ru | 3 +++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index 753f982..ea57fb0 100644 --- a/Gemfile +++ b/Gemfile @@ -4,11 +4,12 @@ ruby '2.1.0' # Tell heroku to use ruby 2.1.0 gem 'rails', '4.1.0.beta1' -gem 'american_date', '~> 1.1.0' # American style month/day/year date parsing -gem 'dalli', '~> 2.7.0' # High performance memcached client -gem 'pg', '~> 0.17.1' # Postgres ActiveRecord adapter -gem 'queue_classic', '~> 3.0.0rc' # Backgrounding queue that uses postgres for its queue -gem 'unicorn', '~> 4.7.0' # HTTP server for fast clients on low-latency, high-bandwidth connections +gem 'american_date', '~> 1.1.0' # American style month/day/year date parsing +gem 'dalli', '~> 2.7.0' # High performance memcached client +gem 'pg', '~> 0.17.1' # Postgres ActiveRecord adapter +gem 'queue_classic', '~> 3.0.0rc' # Backgrounding queue that uses postgres for its queue +gem 'rack-canonical-host', '~> 0.0.8' # Automatically redirect to canonical host +gem 'unicorn', '~> 4.7.0' # HTTP server for fast clients on low-latency, high-bandwidth connections # Asset related gems gem 'coffee-rails', '~> 4.0.0' diff --git a/Gemfile.lock b/Gemfile.lock index a3a2a7f..17b913f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -28,6 +28,7 @@ GEM minitest (~> 5.1) thread_safe (~> 0.1) tzinfo (~> 1.1) + addressable (2.3.5) american_date (1.1.0) ansi (1.4.3) arel (5.0.0) @@ -134,6 +135,9 @@ GEM queue_classic (3.0.0rc) pg (~> 0.17.0) rack (1.5.2) + rack-canonical-host (0.0.8) + addressable + rack (~> 1.0) rack-test (0.6.2) rack (>= 1.0) rails (4.1.0.beta1) @@ -217,6 +221,7 @@ DEPENDENCIES pry-plus pry-rails queue_classic (~> 3.0.0rc) + rack-canonical-host (~> 0.0.8) rails (= 4.1.0.beta1) sass-rails (~> 4.0.0.rc1) sdoc diff --git a/config.ru b/config.ru index 5bc2a61..fc51304 100644 --- a/config.ru +++ b/config.ru @@ -1,4 +1,7 @@ # This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) + +use Rack::CanonicalHost, ENV['CANONICAL_HOST'] if ENV['CANONICAL_HOST'] + run Rails.application From 597faaf967b7faad394d5f03bbd7d0346b5300ac Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Wed, 15 Jan 2014 18:41:00 -0600 Subject: [PATCH 31/39] Add font_assets gem and fonts to the pipeline --- Gemfile | 13 +++++++------ Gemfile.lock | 3 +++ config/application.rb | 6 ++++++ config/environments/production.rb | 7 ++----- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/Gemfile b/Gemfile index ea57fb0..486f05f 100644 --- a/Gemfile +++ b/Gemfile @@ -12,12 +12,13 @@ gem 'rack-canonical-host', '~> 0.0.8' # Automatically redirect to canonical gem 'unicorn', '~> 4.7.0' # HTTP server for fast clients on low-latency, high-bandwidth connections # Asset related gems -gem 'coffee-rails', '~> 4.0.0' -gem 'jquery-rails', '~> 3.0.4' -gem 'momentjs-rails', '~> 2.5.0' -gem 'sass-rails', '~> 4.0.0.rc1' -gem 'turbolinks', '~> 2.1.0' -gem 'uglifier', '~> 2.4.0' +gem 'coffee-rails', '~> 4.0.0' # Add Coffescript support to the asset pipeline +gem 'font_assets', '~> 0.1.10' # Addresses Access-Control-Allow-Origin asset problems in Firefox +gem 'jquery-rails', '~> 3.0.4' # jQuery 1.10 for pipeline +gem 'momentjs-rails', '~> 2.5.0' # JavaScript Time Library +gem 'sass-rails', '~> 4.0.0.rc1' # CSS3 extension (mixins, variables, nesting, etc) +gem 'turbolinks', '~> 2.1.0' # Makes following links in your web application faster +gem 'uglifier', '~> 2.4.0' # Makes your JS ugly (compressed) gem 'jbuilder', '~> 1.2' # Build JSON APIs with ease diff --git a/Gemfile.lock b/Gemfile.lock index 17b913f..f8cf5dc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -64,6 +64,8 @@ GEM erubis (2.7.0) eventmachine (1.0.3) execjs (2.0.2) + font_assets (0.1.10) + rack hashie (2.0.5) hike (1.2.3) i18n (0.6.9) @@ -211,6 +213,7 @@ DEPENDENCIES coffee-rails (~> 4.0.0) dalli (~> 2.7.0) dotenv-rails + font_assets (~> 0.1.10) jbuilder (~> 1.2) jquery-rails (~> 3.0.4) minitest-reporters diff --git a/config/application.rb b/config/application.rb index eb83db5..ebc41bd 100644 --- a/config/application.rb +++ b/config/application.rb @@ -17,5 +17,11 @@ class Application < Rails::Application # Raise errors when an unpermitted param is sent to a controller action ActiveRecord::Base.send(:include, ActiveModel::ForbiddenAttributesProtection) + + # Add the fonts path + config.assets.paths << Rails.root.join('app', 'assets', 'fonts') + + # Precompile additional assets + config.assets.precompile += %w(.svg .eot .woff .ttf) end end diff --git a/config/environments/production.rb b/config/environments/production.rb index 5ed65a4..0a43015 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -60,11 +60,8 @@ # Use a different cache store in production. config.cache_store = :dalli_store - # Add the fonts path - config.assets.paths << Rails.root.join('app', 'assets', 'fonts') - - # Precompile additional assets - config.assets.precompile += %w( .svg .eot .woff .ttf ) + # Addresses Access-Control-Allow-Origin asset problems in Firefox + config.font_assets.origin = "https://#{ENV['CANONICAL_HOST']}" # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.action_controller.asset_host = "http://assets.example.com" From 810a6fd150667f2aac458ffa1dd4d40caf0715dc Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Mon, 20 Jan 2014 15:55:20 -0600 Subject: [PATCH 32/39] Add $PWD to $PATH in .envrc --- .envrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.envrc b/.envrc index 310c115..e2396c2 100644 --- a/.envrc +++ b/.envrc @@ -1 +1 @@ -export PATH=vendor/bundle/bin:bin:$PATH +export PATH=$PWD/vendor/bundle/bin:$PWD/bin:$PATH From 1ceedd6a9bca4f02e67ce8aa1f07e6adfe0f327e Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Thu, 23 Jan 2014 00:40:45 -0600 Subject: [PATCH 33/39] Add slim and high voltage --- Gemfile | 4 +++- Gemfile.lock | 12 ++++++++++++ app/assets/javascripts/application.coffee | 4 ++++ app/assets/javascripts/application.js | 16 ---------------- app/views/layouts/application.html.erb | 14 -------------- app/views/layouts/application.html.slim | 10 ++++++++++ app/views/pages/index.html.slim | 3 +++ config/routes.rb | 7 +++++++ 8 files changed, 39 insertions(+), 31 deletions(-) create mode 100644 app/assets/javascripts/application.coffee delete mode 100644 app/assets/javascripts/application.js delete mode 100644 app/views/layouts/application.html.erb create mode 100644 app/views/layouts/application.html.slim create mode 100644 app/views/pages/index.html.slim diff --git a/Gemfile b/Gemfile index 486f05f..4358403 100644 --- a/Gemfile +++ b/Gemfile @@ -11,12 +11,14 @@ gem 'queue_classic', '~> 3.0.0rc' # Backgrounding queue that uses postgr gem 'rack-canonical-host', '~> 0.0.8' # Automatically redirect to canonical host gem 'unicorn', '~> 4.7.0' # HTTP server for fast clients on low-latency, high-bandwidth connections -# Asset related gems +# Asset/View related gems gem 'coffee-rails', '~> 4.0.0' # Add Coffescript support to the asset pipeline gem 'font_assets', '~> 0.1.10' # Addresses Access-Control-Allow-Origin asset problems in Firefox +gem 'high_voltage', '~> 2.1.0' # Easily include static pages gem 'jquery-rails', '~> 3.0.4' # jQuery 1.10 for pipeline gem 'momentjs-rails', '~> 2.5.0' # JavaScript Time Library gem 'sass-rails', '~> 4.0.0.rc1' # CSS3 extension (mixins, variables, nesting, etc) +gem 'slim-rails', '~> 2.0.4' # A fast, lightweight templating engine gem 'turbolinks', '~> 2.1.0' # Makes following links in your web application faster gem 'uglifier', '~> 2.4.0' # Makes your JS ugly (compressed) diff --git a/Gemfile.lock b/Gemfile.lock index f8cf5dc..7ecb4ce 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -67,6 +67,7 @@ GEM font_assets (0.1.10) rack hashie (2.0.5) + high_voltage (2.1.0) hike (1.2.3) i18n (0.6.9) interception (0.3) @@ -169,6 +170,14 @@ GEM sdoc (0.3.20) json (>= 1.1.3) rdoc (~> 3.10) + slim (2.0.2) + temple (~> 0.6.6) + tilt (>= 1.3.3, < 2.1) + slim-rails (2.0.4) + actionpack (>= 3.0, < 4.1) + activesupport (>= 3.0, < 4.1) + railties (>= 3.0, < 4.1) + slim (~> 2.0) slop (3.4.7) spring (1.0.0) sprockets (2.10.1) @@ -180,6 +189,7 @@ GEM actionpack (>= 3.0) activesupport (>= 3.0) sprockets (~> 2.8) + temple (0.6.7) thin (1.6.1) daemons (>= 1.0.9) eventmachine (>= 1.0.0) @@ -214,6 +224,7 @@ DEPENDENCIES dalli (~> 2.7.0) dotenv-rails font_assets (~> 0.1.10) + high_voltage (~> 2.1.0) jbuilder (~> 1.2) jquery-rails (~> 3.0.4) minitest-reporters @@ -228,6 +239,7 @@ DEPENDENCIES rails (= 4.1.0.beta1) sass-rails (~> 4.0.0.rc1) sdoc + slim-rails (~> 2.0.4) spring thin turbolinks (~> 2.1.0) diff --git a/app/assets/javascripts/application.coffee b/app/assets/javascripts/application.coffee new file mode 100644 index 0000000..a37af36 --- /dev/null +++ b/app/assets/javascripts/application.coffee @@ -0,0 +1,4 @@ +#= require jquery +#= require jquery_ujs +#= require turbolinks +#= require_tree . diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js deleted file mode 100644 index d6925fa..0000000 --- a/app/assets/javascripts/application.js +++ /dev/null @@ -1,16 +0,0 @@ -// This is a manifest file that'll be compiled into application.js, which will include all the files -// listed below. -// -// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, -// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. -// -// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the -// compiled file. -// -// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details -// about supported directives. -// -//= require jquery -//= require jquery_ujs -//= require turbolinks -//= require_tree . diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb deleted file mode 100644 index fdb1d70..0000000 --- a/app/views/layouts/application.html.erb +++ /dev/null @@ -1,14 +0,0 @@ - - - - MyApp - <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %> - <%= javascript_include_tag "application", "data-turbolinks-track" => true %> - <%= csrf_meta_tags %> - - - -<%= yield %> - - - diff --git a/app/views/layouts/application.html.slim b/app/views/layouts/application.html.slim new file mode 100644 index 0000000..8fa1d9c --- /dev/null +++ b/app/views/layouts/application.html.slim @@ -0,0 +1,10 @@ +doctype 5 +html + head + title = Rails.application.class.parent_name + = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true + = javascript_include_tag 'application', 'data-turbolinks-track' => true + = csrf_meta_tags + +body + = yield diff --git a/app/views/pages/index.html.slim b/app/views/pages/index.html.slim new file mode 100644 index 0000000..a3f2a2c --- /dev/null +++ b/app/views/pages/index.html.slim @@ -0,0 +1,3 @@ +h1 Welcome to Rails + +a href='/rails/info/properties' Application properties diff --git a/config/routes.rb b/config/routes.rb index 3f66539..8f82795 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -53,4 +53,11 @@ # # (app/controllers/admin/products_controller.rb) # resources :products # end + # + # Point root to static index file using high_voltage gem + root to: 'high_voltage/pages#show', id: 'index' + + # Point fallback route to any matching static page + # Keep this at the end to avoid conflicting with other routes + get ':id' => 'high_voltage/pages#show', as: :static end From 8893ad9c6b8d9492882acde9b6758b5dc47e039b Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Thu, 23 Jan 2014 02:05:31 -0600 Subject: [PATCH 34/39] Remove the need for rails-rename (using .env) --- .env.example | 7 +++++-- bin/rails-rename | 8 -------- config/application.rb | 15 +++++++++++++-- config/database.yml | 8 ++++---- 4 files changed, 22 insertions(+), 16 deletions(-) delete mode 100755 bin/rails-rename diff --git a/.env.example b/.env.example index e11bd3e..4de4c17 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,5 @@ -APPNAME=my-app +APP_NAME=my_app +APP_NAME_DASHED=my-app DEVELOPER_EMAIL=$(git config user.email) # To quickly generate a 128-character token, you can use: @@ -9,12 +10,14 @@ DEVELOPER_EMAIL=$(git config user.email) # heroku config:add RAILS_SECRET_TOKEN=$(ruby -e "puts rand(36**128).to_s(36)") -r production export RAILS_SECRET_TOKEN=dhb0h20edrflpzdy3b6ywdkijegvzvo9hnwoh6qegw2ytn0klvvmhdgczkkefxl1c6kgszzgogomayo +export DATABASE_URL=postgresql://localhost/${APP_NAME}_development + export EMAIL_RECIPIENTS=$DEVELOPER_EMAIL export MAIL_DELIVERY_METHOD=letter_opener export AWS_ACCESS_KEY_ID= export AWS_SECRET_ACCESS_KEY= -export FOG_DIRECTORY=$APPNAME-dev-$USER +export FOG_DIRECTORY=$APP_NAME_DASHED-dev-$USER export FOG_PROVIDER=AWS export MANDRILL_USERNAME=user@email.com diff --git a/bin/rails-rename b/bin/rails-rename deleted file mode 100755 index 950d144..0000000 --- a/bin/rails-rename +++ /dev/null @@ -1,8 +0,0 @@ -#! /usr/bin/env bash -[[ -z $1 ]] && echo 'Provide an app name' && exit 1 -input_string=${2:-MyApp} -input_string_underscored=$(ruby -r'active_support/inflector' -e "puts '$input_string'.strip.underscore") -output_string=$1 -output_string_underscored=$(ruby -r'active_support/inflector' -e "puts '$output_string'.strip.underscore") -git grep -l -e "$input_string" | grep -v 'bin/rails-rename' | xargs sed -i '' "s/$input_string/$output_string/g" -git grep -l -e "$input_string_underscored" | grep -v 'bin/rails-rename' | xargs sed -i '' "s/$input_string_underscored/$output_string_underscored/g" diff --git a/config/application.rb b/config/application.rb index ebc41bd..9b5ff38 100644 --- a/config/application.rb +++ b/config/application.rb @@ -6,8 +6,17 @@ # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) -module MyApp - class Application < Rails::Application +raise %Q( + Please set an APP_NAME environment variable in .env. + If you are initializing this app, run bin/setup to copy over the example .env. +) unless ENV['APP_NAME'] + +#TODO: Decide if +# Object.const_set(ENV.fetch('APP_NAME').camelize, Module.new do ... +# is a better syntax. + +application = Module.new do + const_set :Application, Class.new(Rails::Application) do # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. @@ -25,3 +34,5 @@ class Application < Rails::Application config.assets.precompile += %w(.svg .eot .woff .ttf) end end + +Object.const_set ENV.fetch('APP_NAME').camelize, application diff --git a/config/database.yml b/config/database.yml index a23c995..acbc13c 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,19 +1,19 @@ development: &development adapter : postgresql encoding : unicode - database : my_app_development + database : <%= ENV['APP_NAME'] %>_development template : template0 pool : 5 min_messages : warning test: &test <<: *development - database : my_app_test + database : <%= ENV['APP_NAME'] %>_test staging: &staging <<: *development - database : my_app_staging + database : <%= ENV['APP_NAME'] %>_staging production: &production <<: *development - database : my_app_production + database : <%= ENV['APP_NAME'] %>_production From 3b0ebdc8b329078d99bd95015b92ceba6356a143 Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Thu, 23 Jan 2014 02:28:25 -0600 Subject: [PATCH 35/39] Add twitter bootstrap 3; Switch to application.css.sass --- Gemfile | 1 + Gemfile.lock | 3 +++ app/assets/stylesheets/application.css | 15 --------------- app/assets/stylesheets/application.css.sass | 1 + 4 files changed, 5 insertions(+), 15 deletions(-) delete mode 100644 app/assets/stylesheets/application.css create mode 100644 app/assets/stylesheets/application.css.sass diff --git a/Gemfile b/Gemfile index 4358403..69846ab 100644 --- a/Gemfile +++ b/Gemfile @@ -12,6 +12,7 @@ gem 'rack-canonical-host', '~> 0.0.8' # Automatically redirect to canonical gem 'unicorn', '~> 4.7.0' # HTTP server for fast clients on low-latency, high-bandwidth connections # Asset/View related gems +gem 'bootstrap-sass', '~> 3.0.3.0' # Sleek, intuitive, and powerful mobile first front-end framework gem 'coffee-rails', '~> 4.0.0' # Add Coffescript support to the asset pipeline gem 'font_assets', '~> 0.1.10' # Addresses Access-Control-Allow-Origin asset problems in Firefox gem 'high_voltage', '~> 2.1.0' # Easily include static pages diff --git a/Gemfile.lock b/Gemfile.lock index 7ecb4ce..4a0fc22 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -39,6 +39,8 @@ GEM binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) bond (0.5.0) + bootstrap-sass (3.0.3.0) + sass (~> 3.2) builder (3.2.2) coderay (1.1.0) coffee-rails (4.0.1) @@ -220,6 +222,7 @@ PLATFORMS DEPENDENCIES american_date (~> 1.1.0) autotest-rails + bootstrap-sass (~> 3.0.3.0) coffee-rails (~> 4.0.0) dalli (~> 2.7.0) dotenv-rails diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css deleted file mode 100644 index a443db3..0000000 --- a/app/assets/stylesheets/application.css +++ /dev/null @@ -1,15 +0,0 @@ -/* - * This is a manifest file that'll be compiled into application.css, which will include all the files - * listed below. - * - * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, - * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. - * - * You're free to add application-wide styles to this file and they'll appear at the bottom of the - * compiled file so the styles you add here take precedence over styles defined in any styles - * defined in the other CSS/SCSS files in this directory. It is generally better to create a new - * file per style scope. - * - *= require_tree . - *= require_self - */ diff --git a/app/assets/stylesheets/application.css.sass b/app/assets/stylesheets/application.css.sass new file mode 100644 index 0000000..79ffd23 --- /dev/null +++ b/app/assets/stylesheets/application.css.sass @@ -0,0 +1 @@ +@import "bootstrap" From d667f29beceada03a23e1b4a9cc3f25578412ce3 Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Thu, 23 Jan 2014 02:35:19 -0600 Subject: [PATCH 36/39] Add simple_form --- Gemfile | 1 + Gemfile.lock | 4 + config/initializers/simple_form.rb | 145 +++++++++++++++++++ config/initializers/simple_form_bootstrap.rb | 45 ++++++ config/locales/simple_form.en.yml | 26 ++++ lib/templates/slim/scaffold/_form.html.slim | 10 ++ 6 files changed, 231 insertions(+) create mode 100644 config/initializers/simple_form.rb create mode 100644 config/initializers/simple_form_bootstrap.rb create mode 100644 config/locales/simple_form.en.yml create mode 100644 lib/templates/slim/scaffold/_form.html.slim diff --git a/Gemfile b/Gemfile index 69846ab..fb17346 100644 --- a/Gemfile +++ b/Gemfile @@ -9,6 +9,7 @@ gem 'dalli', '~> 2.7.0' # High performance memcached client gem 'pg', '~> 0.17.1' # Postgres ActiveRecord adapter gem 'queue_classic', '~> 3.0.0rc' # Backgrounding queue that uses postgres for its queue gem 'rack-canonical-host', '~> 0.0.8' # Automatically redirect to canonical host +gem 'simple_form', '~> 3.0.1' # Forms made easy gem 'unicorn', '~> 4.7.0' # HTTP server for fast clients on low-latency, high-bandwidth connections # Asset/View related gems diff --git a/Gemfile.lock b/Gemfile.lock index 4a0fc22..32f81bc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -172,6 +172,9 @@ GEM sdoc (0.3.20) json (>= 1.1.3) rdoc (~> 3.10) + simple_form (3.0.1) + actionpack (>= 4.0.0, < 4.1) + activemodel (>= 4.0.0, < 4.1) slim (2.0.2) temple (~> 0.6.6) tilt (>= 1.3.3, < 2.1) @@ -242,6 +245,7 @@ DEPENDENCIES rails (= 4.1.0.beta1) sass-rails (~> 4.0.0.rc1) sdoc + simple_form (~> 3.0.1) slim-rails (~> 2.0.4) spring thin diff --git a/config/initializers/simple_form.rb b/config/initializers/simple_form.rb new file mode 100644 index 0000000..6986de9 --- /dev/null +++ b/config/initializers/simple_form.rb @@ -0,0 +1,145 @@ +# Use this setup block to configure all options available in SimpleForm. +SimpleForm.setup do |config| + # Wrappers are used by the form builder to generate a + # complete input. You can remove any component from the + # wrapper, change the order or even add your own to the + # stack. The options given below are used to wrap the + # whole input. + config.wrappers :default, class: :input, + hint_class: :field_with_hint, error_class: :field_with_errors do |b| + ## Extensions enabled by default + # Any of these extensions can be disabled for a + # given input by passing: `f.input EXTENSION_NAME => false`. + # You can make any of these extensions optional by + # renaming `b.use` to `b.optional`. + + # Determines whether to use HTML5 (:email, :url, ...) + # and required attributes + b.use :html5 + + # Calculates placeholders automatically from I18n + # You can also pass a string as f.input placeholder: "Placeholder" + b.use :placeholder + + ## Optional extensions + # They are disabled unless you pass `f.input EXTENSION_NAME => :lookup` + # to the input. If so, they will retrieve the values from the model + # if any exists. If you want to enable the lookup for any of those + # extensions by default, you can change `b.optional` to `b.use`. + + # Calculates maxlength from length validations for string inputs + b.optional :maxlength + + # Calculates pattern from format validations for string inputs + b.optional :pattern + + # Calculates min and max from length validations for numeric inputs + b.optional :min_max + + # Calculates readonly automatically from readonly attributes + b.optional :readonly + + ## Inputs + b.use :label_input + b.use :hint, wrap_with: { tag: :span, class: :hint } + b.use :error, wrap_with: { tag: :span, class: :error } + end + + # The default wrapper to be used by the FormBuilder. + config.default_wrapper = :default + + # Define the way to render check boxes / radio buttons with labels. + # Defaults to :nested for bootstrap config. + # inline: input + label + # nested: label > input + config.boolean_style = :nested + + # Default class for buttons + config.button_class = 'btn' + + # Method used to tidy up errors. Specify any Rails Array method. + # :first lists the first message for each field. + # Use :to_sentence to list all errors for each field. + # config.error_method = :first + + # Default tag used for error notification helper. + config.error_notification_tag = :div + + # CSS class to add for error notification helper. + config.error_notification_class = 'alert alert-error' + + # ID to add for error notification helper. + # config.error_notification_id = nil + + # Series of attempts to detect a default label method for collection. + # config.collection_label_methods = [ :to_label, :name, :title, :to_s ] + + # Series of attempts to detect a default value method for collection. + # config.collection_value_methods = [ :id, :to_s ] + + # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none. + # config.collection_wrapper_tag = nil + + # You can define the class to use on all collection wrappers. Defaulting to none. + # config.collection_wrapper_class = nil + + # You can wrap each item in a collection of radio/check boxes with a tag, + # defaulting to :span. Please note that when using :boolean_style = :nested, + # SimpleForm will force this option to be a label. + # config.item_wrapper_tag = :span + + # You can define a class to use in all item wrappers. Defaulting to none. + # config.item_wrapper_class = nil + + # How the label text should be generated altogether with the required text. + # config.label_text = lambda { |label, required| "#{required} #{label}" } + + # You can define the class to use on all labels. Default is nil. + config.label_class = 'control-label' + + # You can define the class to use on all forms. Default is simple_form. + # config.form_class = :simple_form + + # You can define which elements should obtain additional classes + # config.generate_additional_classes_for = [:wrapper, :label, :input] + + # Whether attributes are required by default (or not). Default is true. + # config.required_by_default = true + + # Tell browsers whether to use the native HTML5 validations (novalidate form option). + # These validations are enabled in SimpleForm's internal config but disabled by default + # in this configuration, which is recommended due to some quirks from different browsers. + # To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations, + # change this configuration to true. + config.browser_validations = false + + # Collection of methods to detect if a file type was given. + # config.file_methods = [ :mounted_as, :file?, :public_filename ] + + # Custom mappings for input types. This should be a hash containing a regexp + # to match as key, and the input type that will be used when the field name + # matches the regexp as value. + # config.input_mappings = { /count/ => :integer } + + # Custom wrappers for input types. This should be a hash containing an input + # type as key and the wrapper that will be used for all inputs with specified type. + # config.wrapper_mappings = { string: :prepend } + + # Default priority for time_zone inputs. + # config.time_zone_priority = nil + + # Default priority for country inputs. + # config.country_priority = nil + + # When false, do not use translations for labels. + # config.translate_labels = true + + # Automatically discover new inputs in Rails' autoload path. + # config.inputs_discovery = true + + # Cache SimpleForm inputs discovery + # config.cache_discovery = !Rails.env.development? + + # Default class for inputs + # config.input_class = nil +end diff --git a/config/initializers/simple_form_bootstrap.rb b/config/initializers/simple_form_bootstrap.rb new file mode 100644 index 0000000..ad4ca74 --- /dev/null +++ b/config/initializers/simple_form_bootstrap.rb @@ -0,0 +1,45 @@ +# Use this setup block to configure all options available in SimpleForm. +SimpleForm.setup do |config| + config.wrappers :bootstrap, tag: 'div', class: 'control-group', error_class: 'error' do |b| + b.use :html5 + b.use :placeholder + b.use :label + b.wrapper tag: 'div', class: 'controls' do |ba| + ba.use :input + ba.use :error, wrap_with: { tag: 'span', class: 'help-inline' } + ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' } + end + end + + config.wrappers :prepend, tag: 'div', class: "control-group", error_class: 'error' do |b| + b.use :html5 + b.use :placeholder + b.use :label + b.wrapper tag: 'div', class: 'controls' do |input| + input.wrapper tag: 'div', class: 'input-prepend' do |prepend| + prepend.use :input + end + input.use :hint, wrap_with: { tag: 'span', class: 'help-block' } + input.use :error, wrap_with: { tag: 'span', class: 'help-inline' } + end + end + + config.wrappers :append, tag: 'div', class: "control-group", error_class: 'error' do |b| + b.use :html5 + b.use :placeholder + b.use :label + b.wrapper tag: 'div', class: 'controls' do |input| + input.wrapper tag: 'div', class: 'input-append' do |append| + append.use :input + end + input.use :hint, wrap_with: { tag: 'span', class: 'help-block' } + input.use :error, wrap_with: { tag: 'span', class: 'help-inline' } + end + end + + # Wrappers for forms and inputs using the Twitter Bootstrap toolkit. + # Check the Bootstrap docs (http://twitter.github.com/bootstrap) + # to learn about the different styles for forms and inputs, + # buttons and other elements. + config.default_wrapper = :bootstrap +end diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml new file mode 100644 index 0000000..0df11fe --- /dev/null +++ b/config/locales/simple_form.en.yml @@ -0,0 +1,26 @@ +en: + simple_form: + "yes": 'Yes' + "no": 'No' + required: + text: 'required' + mark: '*' + # You can uncomment the line below if you need to overwrite the whole required html. + # When using html, text and mark won't be used. + # html: '*' + error_notification: + default_message: "Please review the problems below:" + # Labels and hints examples + # labels: + # defaults: + # password: 'Password' + # user: + # new: + # email: 'E-mail to sign in.' + # edit: + # email: 'E-mail.' + # hints: + # defaults: + # username: 'User name to sign in.' + # password: 'No special characters, please.' + diff --git a/lib/templates/slim/scaffold/_form.html.slim b/lib/templates/slim/scaffold/_form.html.slim new file mode 100644 index 0000000..a2ff775 --- /dev/null +++ b/lib/templates/slim/scaffold/_form.html.slim @@ -0,0 +1,10 @@ += simple_form_for(@<%= singular_table_name %>) do |f| + = f.error_notification + + .form-inputs +<%- attributes.each do |attribute| -%> + = f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %> +<%- end -%> + + .form-actions + = f.button :submit From 1a702a7c7d440a6a71844a02ed743337cb61f516 Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Thu, 23 Jan 2014 13:57:40 -0600 Subject: [PATCH 37/39] SQUASH ME: Switch nameless module syntax --- config/application.rb | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/config/application.rb b/config/application.rb index 9b5ff38..3b7fee2 100644 --- a/config/application.rb +++ b/config/application.rb @@ -11,11 +11,7 @@ If you are initializing this app, run bin/setup to copy over the example .env. ) unless ENV['APP_NAME'] -#TODO: Decide if -# Object.const_set(ENV.fetch('APP_NAME').camelize, Module.new do ... -# is a better syntax. - -application = Module.new do +Object.const_set(ENV.fetch('APP_NAME').camelize, Module.new do const_set :Application, Class.new(Rails::Application) do # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers @@ -33,6 +29,4 @@ # Precompile additional assets config.assets.precompile += %w(.svg .eot .woff .ttf) end -end - -Object.const_set ENV.fetch('APP_NAME').camelize, application +end) From 131c70ffc8d0bb1d4707895b86317e278061493e Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Sat, 3 May 2014 13:51:42 -0500 Subject: [PATCH 38/39] Switch to .git/safe; check rails cache differently --- test/environments/application.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/environments/application.rb b/test/environments/application.rb index 425c1b6..00b22a3 100644 --- a/test/environments/application.rb +++ b/test/environments/application.rb @@ -64,7 +64,8 @@ def self.columns; []; end; def self.column_types; {}; end # Set up a tableless A end it "has dalli available" do - ActiveSupport::Cache.lookup_store(:dalli_store).stats.values.wont_include nil + Rails.cache.stats.values.wont_include nil + # ActiveSupport::Cache.lookup_store(:dalli_store).stats.values.wont_include nil end it "has pg available" do @@ -82,8 +83,7 @@ def self.columns; []; end; def self.column_types; {}; end # Set up a tableless A end describe "Bins" do - it "has direnv installed and configured" do - %x[direnv status].must_include 'Found RC allowed true' + it "has .git/safe/../../bin in PATH" do ENV['PATH'].split(':').grep('^bin$').wont_be_nil ENV['PATH'].split(':').grep('^vendor/bundle/bin$').wont_be_nil end From ee1f8e9f48af40016c2396ea569c6c80e32d5db8 Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Sat, 3 May 2014 13:52:12 -0500 Subject: [PATCH 39/39] Update all gems (rails 4.1.0 and friends) --- Gemfile | 26 +++---- Gemfile.lock | 210 +++++++++++++++++++++++++-------------------------- 2 files changed, 117 insertions(+), 119 deletions(-) diff --git a/Gemfile b/Gemfile index fb17346..fca20c9 100644 --- a/Gemfile +++ b/Gemfile @@ -1,30 +1,30 @@ source 'https://rubygems.org' -ruby '2.1.0' # Tell heroku to use ruby 2.1.0 +ruby '2.1.1' -gem 'rails', '4.1.0.beta1' +gem 'rails', '4.1.0' gem 'american_date', '~> 1.1.0' # American style month/day/year date parsing gem 'dalli', '~> 2.7.0' # High performance memcached client gem 'pg', '~> 0.17.1' # Postgres ActiveRecord adapter gem 'queue_classic', '~> 3.0.0rc' # Backgrounding queue that uses postgres for its queue -gem 'rack-canonical-host', '~> 0.0.8' # Automatically redirect to canonical host +gem 'rack-canonical-host', '~> 0.1.0' # Automatically redirect to canonical host gem 'simple_form', '~> 3.0.1' # Forms made easy -gem 'unicorn', '~> 4.7.0' # HTTP server for fast clients on low-latency, high-bandwidth connections +gem 'unicorn', '~> 4.8.2' # HTTP server for fast clients on low-latency, high-bandwidth connections # Asset/View related gems -gem 'bootstrap-sass', '~> 3.0.3.0' # Sleek, intuitive, and powerful mobile first front-end framework +gem 'bootstrap-sass', '~> 3.1.1.1' # Sleek, intuitive, and powerful mobile first front-end framework gem 'coffee-rails', '~> 4.0.0' # Add Coffescript support to the asset pipeline gem 'font_assets', '~> 0.1.10' # Addresses Access-Control-Allow-Origin asset problems in Firefox gem 'high_voltage', '~> 2.1.0' # Easily include static pages -gem 'jquery-rails', '~> 3.0.4' # jQuery 1.10 for pipeline -gem 'momentjs-rails', '~> 2.5.0' # JavaScript Time Library -gem 'sass-rails', '~> 4.0.0.rc1' # CSS3 extension (mixins, variables, nesting, etc) -gem 'slim-rails', '~> 2.0.4' # A fast, lightweight templating engine -gem 'turbolinks', '~> 2.1.0' # Makes following links in your web application faster -gem 'uglifier', '~> 2.4.0' # Makes your JS ugly (compressed) - -gem 'jbuilder', '~> 1.2' # Build JSON APIs with ease +gem 'jquery-rails', '~> 3.1.0' # jQuery 1.10 for pipeline +gem 'momentjs-rails', '~> 2.6.0' # JavaScript Time Library +gem 'sass-rails', '~> 4.0.3' # CSS3 extension (mixins, variables, nesting, etc) +gem 'slim-rails', '~> 2.1.4' # A fast, lightweight templating engine +gem 'turbolinks', '~> 2.2.2' # Makes following links in your web application faster +gem 'uglifier', '~> 2.5.0' # Makes your JS ugly (compressed) + +gem 'jbuilder', '~> 2.0.7' # Build JSON APIs with ease gem 'sdoc', group: :doc, require: false # bundle exec rake doc:rails generates the API under doc/api diff --git a/Gemfile.lock b/Gemfile.lock index 32f81bc..2f926d2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,45 +1,44 @@ GEM remote: https://rubygems.org/ specs: - ZenTest (4.9.5) - actionmailer (4.1.0.beta1) - actionpack (= 4.1.0.beta1) - actionview (= 4.1.0.beta1) + ZenTest (4.10.0) + actionmailer (4.1.0) + actionpack (= 4.1.0) + actionview (= 4.1.0) mail (~> 2.5.4) - actionpack (4.1.0.beta1) - actionview (= 4.1.0.beta1) - activesupport (= 4.1.0.beta1) + actionpack (4.1.0) + actionview (= 4.1.0) + activesupport (= 4.1.0) rack (~> 1.5.2) rack-test (~> 0.6.2) - actionview (4.1.0.beta1) - activesupport (= 4.1.0.beta1) + actionview (4.1.0) + activesupport (= 4.1.0) builder (~> 3.1) erubis (~> 2.7.0) - activemodel (4.1.0.beta1) - activesupport (= 4.1.0.beta1) + activemodel (4.1.0) + activesupport (= 4.1.0) builder (~> 3.1) - activerecord (4.1.0.beta1) - activemodel (= 4.1.0.beta1) - activesupport (= 4.1.0.beta1) + activerecord (4.1.0) + activemodel (= 4.1.0) + activesupport (= 4.1.0) arel (~> 5.0.0) - activesupport (4.1.0.beta1) + activesupport (4.1.0) i18n (~> 0.6, >= 0.6.9) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) thread_safe (~> 0.1) tzinfo (~> 1.1) - addressable (2.3.5) + addressable (2.3.6) american_date (1.1.0) ansi (1.4.3) - arel (5.0.0) - atomic (1.1.14) + arel (5.0.1.20140414130214) autotest-rails (4.2.1) ZenTest (~> 4.5) awesome_print (1.1.0) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) - bond (0.5.0) - bootstrap-sass (3.0.3.0) + bond (0.5.1) + bootstrap-sass (3.1.1.1) sass (~> 3.2) builder (3.2.2) coderay (1.1.0) @@ -49,63 +48,61 @@ GEM coffee-script (2.2.0) coffee-script-source execjs - coffee-script-source (1.6.3) - columnize (0.3.6) + coffee-script-source (1.7.0) + columnize (0.8.9) daemons (1.1.9) dalli (2.7.0) debug_inspector (0.0.2) - debugger (1.6.5) + debugger (1.6.6) columnize (>= 0.3.1) debugger-linecache (~> 1.2.0) - debugger-ruby_core_source (~> 1.3.1) + debugger-ruby_core_source (~> 1.3.2) debugger-linecache (1.2.0) - debugger-ruby_core_source (1.3.1) - dotenv (0.9.0) - dotenv-rails (0.9.0) - dotenv (= 0.9.0) + debugger-ruby_core_source (1.3.2) + dotenv (0.11.1) + dotenv-deployment (~> 0.0.2) + dotenv-deployment (0.0.2) + dotenv-rails (0.11.1) + dotenv (= 0.11.1) erubis (2.7.0) eventmachine (1.0.3) execjs (2.0.2) - font_assets (0.1.10) + font_assets (0.1.11) rack - hashie (2.0.5) high_voltage (2.1.0) hike (1.2.3) i18n (0.6.9) - interception (0.3) - jbuilder (1.5.3) - activesupport (>= 3.0.0) - multi_json (>= 1.2.0) + interception (0.5) + jbuilder (2.0.7) + activesupport (>= 3.0.0, < 5) + multi_json (~> 1.2) jist (1.5.1) json - jquery-rails (3.0.4) + jquery-rails (3.1.0) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) json (1.8.1) - kgio (2.8.1) + kgio (2.9.2) mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) method_source (0.8.2) mime-types (1.25.1) - minitest (5.2.1) - minitest-reporters (1.0.0) + minitest (5.3.3) + minitest-reporters (1.0.4) ansi builder minitest (>= 5.0) - powerbar - minitest-spec-rails (5.0.2) + ruby-progressbar + minitest-spec-rails (5.0.3) minitest (~> 5.0) - rails (>= 4.1.0.beta, < 5.0) - momentjs-rails (2.5.0) + rails (~> 4.1.0.rc2) + momentjs-rails (2.6.0) railties (>= 3.1) - multi_json (1.8.3) + multi_json (1.9.3) pg (0.17.1) - polyglot (0.3.3) - powerbar (1.0.11) - ansi (~> 1.4.0) - hashie (>= 1.1.0) - pry (0.9.12.4) + polyglot (0.3.4) + pry (0.9.12.6) coderay (~> 1.0) method_source (~> 0.8) slop (~> 3.4) @@ -115,9 +112,9 @@ GEM pry-debugger (0.2.2) debugger (~> 1.3) pry (~> 0.9.10) - pry-doc (0.5.1) - pry (>= 0.9) - yard (>= 0.8) + pry-doc (0.6.0) + pry (~> 0.9) + yard (~> 0.8) pry-docmore (0.1.1) pry pry-doc @@ -131,8 +128,8 @@ GEM pry-stack_explorer pry-rails (0.3.2) pry (>= 0.9.10) - pry-rescue (1.2.0) - interception (>= 0.3) + pry-rescue (1.4.1) + interception (>= 0.5) pry pry-stack_explorer (0.4.9.1) binding_of_caller (>= 0.7) @@ -140,84 +137,85 @@ GEM queue_classic (3.0.0rc) pg (~> 0.17.0) rack (1.5.2) - rack-canonical-host (0.0.8) + rack-canonical-host (0.1.0) addressable rack (~> 1.0) rack-test (0.6.2) rack (>= 1.0) - rails (4.1.0.beta1) - actionmailer (= 4.1.0.beta1) - actionpack (= 4.1.0.beta1) - actionview (= 4.1.0.beta1) - activemodel (= 4.1.0.beta1) - activerecord (= 4.1.0.beta1) - activesupport (= 4.1.0.beta1) + rails (4.1.0) + actionmailer (= 4.1.0) + actionpack (= 4.1.0) + actionview (= 4.1.0) + activemodel (= 4.1.0) + activerecord (= 4.1.0) + activesupport (= 4.1.0) bundler (>= 1.3.0, < 2.0) - railties (= 4.1.0.beta1) - sprockets-rails (~> 2.0.0) - railties (4.1.0.beta1) - actionpack (= 4.1.0.beta1) - activesupport (= 4.1.0.beta1) + railties (= 4.1.0) + sprockets-rails (~> 2.0) + railties (4.1.0) + actionpack (= 4.1.0) + activesupport (= 4.1.0) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - raindrops (0.12.0) - rake (10.1.1) - rdoc (3.12.2) + raindrops (0.13.0) + rake (10.3.1) + rdoc (4.1.1) json (~> 1.4) - sass (3.2.13) - sass-rails (4.0.1) + ruby-progressbar (1.4.2) + sass (3.2.19) + sass-rails (4.0.3) railties (>= 4.0.0, < 5.0) - sass (>= 3.1.10) - sprockets-rails (~> 2.0.0) - sdoc (0.3.20) - json (>= 1.1.3) - rdoc (~> 3.10) - simple_form (3.0.1) - actionpack (>= 4.0.0, < 4.1) - activemodel (>= 4.0.0, < 4.1) + sass (~> 3.2.0) + sprockets (~> 2.8, <= 2.11.0) + sprockets-rails (~> 2.0) + sdoc (0.4.0) + json (~> 1.8) + rdoc (~> 4.0, < 5.0) + simple_form (3.0.2) + actionpack (~> 4.0) + activemodel (~> 4.0) slim (2.0.2) temple (~> 0.6.6) tilt (>= 1.3.3, < 2.1) - slim-rails (2.0.4) - actionpack (>= 3.0, < 4.1) - activesupport (>= 3.0, < 4.1) - railties (>= 3.0, < 4.1) + slim-rails (2.1.4) + actionpack (>= 3.0, < 4.2) + activesupport (>= 3.0, < 4.2) + railties (>= 3.0, < 4.2) slim (~> 2.0) - slop (3.4.7) - spring (1.0.0) - sprockets (2.10.1) + slop (3.5.0) + spring (1.1.2) + sprockets (2.8.0) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sprockets-rails (2.0.1) + sprockets-rails (2.1.3) actionpack (>= 3.0) activesupport (>= 3.0) sprockets (~> 2.8) temple (0.6.7) - thin (1.6.1) + thin (1.6.2) daemons (>= 1.0.9) eventmachine (>= 1.0.0) rack (>= 1.0.0) - thor (0.18.1) - thread_safe (0.1.3) - atomic + thor (0.19.1) + thread_safe (0.3.3) tilt (1.4.1) treetop (1.4.15) polyglot polyglot (>= 0.3.1) - turbolinks (2.1.0) + turbolinks (2.2.2) coffee-rails tzinfo (1.1.0) thread_safe (~> 0.1) - uglifier (2.4.0) + uglifier (2.5.0) execjs (>= 0.3.0) json (>= 1.8.0) - unicorn (4.7.0) + unicorn (4.8.2) kgio (~> 2.6) rack raindrops (~> 0.7) - yard (0.8.7.3) + yard (0.8.7.4) PLATFORMS ruby @@ -225,30 +223,30 @@ PLATFORMS DEPENDENCIES american_date (~> 1.1.0) autotest-rails - bootstrap-sass (~> 3.0.3.0) + bootstrap-sass (~> 3.1.1.1) coffee-rails (~> 4.0.0) dalli (~> 2.7.0) dotenv-rails font_assets (~> 0.1.10) high_voltage (~> 2.1.0) - jbuilder (~> 1.2) - jquery-rails (~> 3.0.4) + jbuilder (~> 2.0.7) + jquery-rails (~> 3.1.0) minitest-reporters minitest-spec-rails - momentjs-rails (~> 2.5.0) + momentjs-rails (~> 2.6.0) pg (~> 0.17.1) pry-awesome_print pry-plus pry-rails queue_classic (~> 3.0.0rc) - rack-canonical-host (~> 0.0.8) - rails (= 4.1.0.beta1) - sass-rails (~> 4.0.0.rc1) + rack-canonical-host (~> 0.1.0) + rails (= 4.1.0) + sass-rails (~> 4.0.3) sdoc simple_form (~> 3.0.1) - slim-rails (~> 2.0.4) + slim-rails (~> 2.1.4) spring thin - turbolinks (~> 2.1.0) - uglifier (~> 2.4.0) - unicorn (~> 4.7.0) + turbolinks (~> 2.2.2) + uglifier (~> 2.5.0) + unicorn (~> 4.8.2)