├── .gitignore ├── README.md ├── app ├── assets │ └── stylesheets │ │ └── application.css.scss └── views │ └── layouts │ ├── application.html.haml │ └── mailer.html.haml ├── app_template.rb ├── config ├── initializers │ └── airbrake.rb ├── puma.rb └── unicorn │ ├── development.rb │ ├── heroku.rb │ ├── production.rb │ └── staging.rb └── root ├── .haml-lint.yml ├── .overcommit.yml ├── .rubocop.yml └── wercker.yml /.gitignore: -------------------------------------------------------------------------------- 1 | ### https://raw.github.com/github/gitignore/master/Global/OSX.gitignore 2 | 3 | .DS_Store 4 | .AppleDouble 5 | .LSOverride 6 | 7 | # Icon must ends with two \r. 8 | Icon 9 | 10 | # Thumbnails 11 | ._* 12 | 13 | # Files that might appear on external disk 14 | .Spotlight-V100 15 | .Trashes 16 | 17 | 18 | ### https://raw.github.com/github/gitignore/master/Ruby.gitignore 19 | 20 | *.gem 21 | *.rbc 22 | /.config 23 | /coverage/ 24 | /InstalledFiles 25 | /pkg/ 26 | /spec/reports/ 27 | /test/tmp/ 28 | /test/version_tmp/ 29 | /tmp/ 30 | 31 | ## Documentation cache and generated files: 32 | /.yardoc/ 33 | /_yardoc/ 34 | /doc/ 35 | /rdoc/ 36 | 37 | ## Environment normalisation: 38 | /.bundle/ 39 | /lib/bundler/man/ 40 | 41 | # for a library or gem, you might want to ignore these files since the code is 42 | # intended to run in multiple environments; otherwise, check them in: 43 | # Gemfile.lock 44 | # .ruby-version 45 | # .ruby-gemset 46 | 47 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this: 48 | .rvmrc 49 | 50 | 51 | ### https://raw.github.com/github/gitignore/master/Rails.gitignore 52 | 53 | *.rbc 54 | *.sassc 55 | .sass-cache 56 | capybara-*.html 57 | .rspec 58 | /log 59 | /tmp 60 | /db/*.sqlite3 61 | /public/system 62 | /coverage/ 63 | /spec/tmp 64 | **.orig 65 | rerun.txt 66 | pickle-email-*.html 67 | config/initializers/secret_token.rb 68 | config/secrets.yml 69 | 70 | ## Environment normalisation: 71 | /.bundle 72 | /vendor/bundle 73 | 74 | # these should all be checked in to normalise the environment: 75 | # Gemfile.lock, .ruby-version, .ruby-gemset 76 | 77 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this: 78 | .rvmrc 79 | 80 | 81 | ### https://raw.github.com/github/gitignore/master/Global/JetBrains.gitignore 82 | 83 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode 84 | 85 | ## Directory-based project format 86 | .idea/ 87 | # if you remove the above rule, at least ignore user-specific stuff: 88 | # .idea/workspace.xml 89 | # .idea/tasks.xml 90 | # and these sensitive or high-churn files: 91 | # .idea/dataSources.ids 92 | # .idea/dataSources.xml 93 | # .idea/sqlDataSources.xml 94 | # .idea/dynamic.xml 95 | 96 | ## File-based project format 97 | *.ipr 98 | *.iws 99 | *.iml 100 | 101 | ## Additional for IntelliJ 102 | out/ 103 | 104 | # generated by mpeltonen/sbt-idea plugin 105 | .idea_modules/ 106 | 107 | 108 | ### https://raw.github.com/github/gitignore/master/Global/SASS.gitignore 109 | 110 | ### Sass Ignores - "Sassy CSS" http://sass-lang.com/ 111 | *.sass-cache 112 | 113 | 114 | ### https://raw.github.com/github/gitignore/master/Global/SublimeText.gitignore 115 | 116 | # workspace files are user-specific 117 | *.sublime-workspace 118 | 119 | # project files should be checked into the repository, unless a significant 120 | # proportion of contributors will probably not be using SublimeText 121 | # *.sublime-project 122 | 123 | 124 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Rails5 application template 2 | 3 | Rails5 Application Template. - [Rails Application Templates — Ruby on Rails Guides](http://guides.rubyonrails.org/rails_application_templates.html) 4 | 5 | It's easy to start Rails5 application with useful gems. 6 | 7 | ## Preparation 8 | 9 | ### Upgrading ruby version in rbenv 10 | 11 | Fill following commands: 12 | 13 | ``` 14 | # Update Homebrew 15 | $ brew update 16 | 17 | # Generate modern .gitignore 18 | $ brew install wget gibo 19 | 20 | # Update ruby-build 21 | $ brew upgrade ruby-build 22 | 23 | # Show some ruby versions which rbenv can install 24 | $ rbenv install --list 25 | 26 | # Install latest Ruby(e.g. 2.4.1) 27 | $ rbenv install 2.4.1 28 | ``` 29 | 30 | ### Install latest Rails gem 31 | 32 | ``` 33 | # Set to use rails latest version(e.g. 5.1.2) 34 | $ gem install rails -v 5.1.2 35 | ``` 36 | 37 | ## Execution command 38 | 39 | Execute following commands: 40 | 41 | ``` 42 | # if you want to use PostgreSQL, please execute following command; 43 | $ rails _5.1.2_ new test_app --database=postgresql -T --skip-bundle -m https://raw.githubusercontent.com/morizyun/rails5_application_template/master/app_template.rb 44 | 45 | # if you want to use MySQL, please execute following command; 46 | $ rails _5.1.2_ new test_app --database=mysql -T --skip-bundle -m https://raw.githubusercontent.com/morizyun/rails5_application_template/master/app_template.rb 47 | ``` 48 | 49 | ## Detail explanation 50 | 51 | Description of this template in Japanese is as follows; 52 | 53 | **[Rails 5.0.0 + Bootstrap 1コマンドで! - 酒と泪とRubyとRailsと](http://morizyun.github.io/blog/rails5-application-templates/)** 54 | 55 | ## Supported versions 56 | 57 | - Ruby 2.4.1 58 | - Rails 5.1 59 | 60 | ## Contributing 61 | 62 | 1. Fork it 63 | 2. Create your feature branch (`git checkout -b my-new-feature`) 64 | 3. Commit your changes (`git commit -am 'Add some feature'`) 65 | 4. Push to the branch (`git push origin my-new-feature`) 66 | 5. Create new Pull Request 67 | -------------------------------------------------------------------------------- /app/assets/stylesheets/application.css.scss: -------------------------------------------------------------------------------- 1 | // First import cerulean variables 2 | @import "bootswatch/yeti/variables"; 3 | 4 | // Then bootstrap itself 5 | @import "bootstrap"; 6 | 7 | // And finally bootswatch style itself 8 | @import "bootswatch/yeti/bootswatch"; 9 | 10 | @import "font-awesome"; 11 | 12 | // Bootstrap body padding for fixed navbar 13 | body { 14 | color: #455A64; 15 | padding-top: 60px; 16 | font-family: -apple-system, BlinkMacSystemFont, Roboto, "Segoe UI", sans-serif; 17 | } 18 | 19 | // https://goo.gl/oeMHBV Fixing Bootstrap style 20 | h1, h2, h3, h4 { 21 | font-weight: normal; 22 | } 23 | 24 | h1, h2, h3, h4, h5, h6 { 25 | line-height: 1.5em; 26 | letter-spacing: .1em; 27 | @media screen and (max-width: 543px) { 28 | letter-spacing: .05em; 29 | } 30 | } 31 | 32 | p { 33 | line-height: 1.65em; 34 | text-align: justify; 35 | letter-spacing: .05em; 36 | @media screen and (max-width: 543px) { 37 | letter-spacing: .025em; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/views/layouts/application.html.haml: -------------------------------------------------------------------------------- 1 | !!! 2 | %html 3 | %head 4 | %meta{ content: 'text/html; charset=UTF-8', 'http-equiv' => 'Content-Type'} 5 | %meta{ content: 'width=device-width, initial-scale=1', name: 'viewport' } 6 | %title TestApp 7 | = csrf_meta_tags 8 | = stylesheet_link_tag('application', media: 'all', 'data-turbolinks-track' => 'reload') 9 | = javascript_include_tag('application', 'data-turbolinks-track' => 'reload') 10 | %body 11 | = yield 12 | -------------------------------------------------------------------------------- /app/views/layouts/mailer.html.haml: -------------------------------------------------------------------------------- 1 | !!! 2 | %html 3 | %head 4 | %meta{ content: 'text/html; charset=utf-8', 'http-equiv' => 'Content-Type' } 5 | %meta{ content: 'width=device-width, initial-scale=1', name: 'viewport' } 6 | :css 7 | /* Email styles need to be inline */ 8 | %body 9 | = yield 10 | -------------------------------------------------------------------------------- /app_template.rb: -------------------------------------------------------------------------------- 1 | require 'bundler' 2 | 3 | # .gitignore 4 | run 'gibo OSX Ruby Rails JetBrains SASS SublimeText > .gitignore' rescue nil 5 | gsub_file '.gitignore', /^config\/initializers\/secret_token\.rb$/, '' 6 | gsub_file '.gitignore', /^config\/secrets\.yml$/, '' 7 | 8 | # Ruby Version 9 | ruby_version = `ruby -v`.scan(/\d\.\d\.\d/).flatten.first 10 | insert_into_file 'Gemfile',%( 11 | ruby '#{ruby_version}' 12 | ), after: "source 'https://rubygems.org'" 13 | run "echo '#{ruby_version}' > ./.ruby-version" 14 | 15 | # add to Gemfile 16 | append_file 'Gemfile', <<-CODE 17 | # ============================ 18 | # Controller 19 | # ============================ 20 | # Controller action arguments parameterizer 21 | gem 'action_args' 22 | 23 | # ============================ 24 | # View 25 | # ============================ 26 | # Bootstrap & Bootswatch & font-awesome 27 | gem 'bootstrap-sass' 28 | gem 'bootswatch-rails' 29 | gem 'font-awesome-rails' 30 | 31 | # Fast Haml 32 | gem 'faml' 33 | 34 | # Form Builders 35 | gem 'simple_form' 36 | 37 | # Pagenation 38 | gem 'kaminari' 39 | 40 | # ============================ 41 | # Utils 42 | # ============================ 43 | # Process Management 44 | gem 'foreman' 45 | 46 | # Configuration using ENV 47 | gem 'dotenv-rails' 48 | 49 | # Annotate schema and routes info 50 | gem 'annotate' 51 | 52 | # ============================ 53 | # Environment Group 54 | # ============================ 55 | group :development do 56 | gem 'erb2haml' 57 | 58 | # help to kill N+1 59 | gem 'bullet' 60 | 61 | # To generate haml view by scaffold or other generate command 62 | gem 'haml-rails' 63 | 64 | # Syntax Checker 65 | # hook event pre-commit, pre-push 66 | gem 'overcommit', require: false 67 | 68 | # A static analysis security vulnerability scanner 69 | gem 'brakeman', require: false 70 | 71 | # Checks for vulnerable versions of gems 72 | gem 'bundler-audit', require: false 73 | 74 | # Style checker that helps keep CoffeeScript code clean and consistent 75 | gem 'coffeelint', require: false 76 | 77 | # Syntax checker for HAML 78 | gem 'haml-lint', require: false 79 | 80 | # Syntax checker for CSS 81 | gem 'ruby_css_lint', require: false 82 | 83 | # A Ruby static code analyzer 84 | gem 'rubocop', require: false 85 | end 86 | 87 | group :development, :test do 88 | # Pry & extensions 89 | gem 'pry-rails' 90 | gem 'pry-byebug' 91 | 92 | # Show SQL result in Pry console 93 | gem 'hirb' 94 | gem 'awesome_print' 95 | 96 | # PG/MySQL Log Formatter 97 | gem 'rails-flog' 98 | 99 | # Rspec 100 | gem 'rspec-rails' 101 | 102 | # test fixture 103 | gem 'factory_girl_rails' 104 | 105 | # Handle events on file modifications 106 | gem 'guard-rspec', require: false 107 | gem 'guard-rubocop', require: false 108 | gem 'guard-livereload', require: false 109 | end 110 | 111 | group :test do 112 | # Mock for HTTP requests 113 | gem 'webmock' 114 | gem 'vcr' 115 | 116 | # Time Mock 117 | gem 'timecop' 118 | 119 | # Support to generate Test Data 120 | gem 'faker' 121 | 122 | # Cleaning test data 123 | gem 'database_rewinder' 124 | 125 | # This gem brings back assigns to your controller tests 126 | gem 'rails-controller-testing' 127 | 128 | # Coverage 129 | gem 'simplecov', require: false 130 | end 131 | CODE 132 | 133 | Bundler.with_clean_env do 134 | run 'bundle install --path vendor/bundle --jobs=4 --without production' 135 | end 136 | 137 | # set config/application.rb 138 | application do 139 | %q{ 140 | # Set timezone 141 | config.time_zone = 'Tokyo' 142 | config.active_record.default_timezone = :local 143 | 144 | # Set locale 145 | I18n.enforce_available_locales = true 146 | config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}').to_s] 147 | config.i18n.default_locale = :ja 148 | 149 | # Set generator 150 | config.generators do |g| 151 | g.orm :active_record 152 | g.template_engine :haml 153 | g.test_framework :rspec, :fixture => true 154 | g.fixture_replacement :factory_girl, :dir => "spec/factories" 155 | g.view_specs false 156 | g.controller_specs true 157 | g.routing_specs false 158 | g.helper_specs false 159 | g.request_specs false 160 | g.assets false 161 | g.helper false 162 | end 163 | } 164 | end 165 | 166 | # For Bullet (N+1 Problem) 167 | insert_into_file 'config/environments/development.rb', %( 168 | # Bullet Setting (help to kill N + 1 query) 169 | config.after_initialize do 170 | Bullet.enable = true # enable Bullet gem, otherwise do nothing 171 | Bullet.alert = true # pop up a JavaScript alert in the browser 172 | Bullet.console = true # log warnings to your browser's console.log 173 | Bullet.rails_logger = true # add warnings directly to the Rails log 174 | end 175 | ), after: 'config.assets.debug = true' 176 | 177 | # Improve security 178 | insert_into_file 'config/environments/production.rb',%q{ 179 | 180 | # Sanitizing parameter 181 | config.filter_parameters += [/(password|private_token|api_endpoint)/i] 182 | }, after: 'config.active_record.dump_schema_after_migration = false' 183 | 184 | # set Japanese locale 185 | get 'https://raw.githubusercontent.com/svenfuchs/rails-i18n/master/rails/locale/ja.yml', 'config/locales/ja.yml' 186 | 187 | # erb => haml 188 | Bundler.with_clean_env do 189 | run 'bundle exec rake haml:replace_erbs' 190 | end 191 | 192 | # Bootstrap/Bootswach/Font-Awesome 193 | run 'rm -rf app/assets/stylesheets/application.css' 194 | get 'https://raw.github.com/morizyun/rails5_application_template/master/app/assets/stylesheets/application.css.scss', 'app/assets/stylesheets/application.css.scss' 195 | 196 | # Initialize SimpleForm 197 | Bundler.with_clean_env do 198 | run 'bundle exec rails g simple_form:install --bootstrap' 199 | end 200 | 201 | # Initialize Kaminari config 202 | Bundler.with_clean_env do 203 | run 'bundle exec rails g kaminari:config' 204 | end 205 | 206 | # Initialize dotenv config 207 | run 'touch .env' 208 | run 'touch .env.development' 209 | run 'touch .env.test' 210 | run "echo '\n.env\n.env*' >> .gitignore" 211 | 212 | # Puma(App Server) 213 | run 'rm -rf config/puma.rb' 214 | get 'https://raw.github.com/morizyun/rails5_application_template/master/config/puma.rb', 'config/puma.rb' 215 | 216 | # Procfile 217 | run "echo 'web: bundle exec puma -C config/puma.rb' > Procfile" 218 | 219 | # Annotate (Generating rake task) 220 | # ---------------------------------------------------------------- 221 | run 'bundle exec rails g annotate:install' 222 | 223 | # Error Notification 224 | # ---------------------------------------------------------------- 225 | if yes?('Do you use Airbrake/Errbit? [yes or ELSE]') 226 | insert_into_file 'Gemfile',%q{ 227 | 228 | # Exception Catcher 229 | gem 'airbrake' 230 | }, after: "gem 'foreman'" 231 | 232 | run 'wget https://raw.github.com/morizyun/rails5_application_template/tree/master/config/initializers/airbrake.rb -P config/initializers' 233 | run "echo '\nAIRBRAKE_HOST=\nAIRBRAKE_PROJECT_ID=\nAIRBRAKE_PROJECT_KEY=\n'" 234 | run "echo 'Please Set AIRBRAKE_HOST, AIRBRAKE_PROJECT_ID, AIRBRAKE_PROJECT_KEY in your environment variables'" 235 | 236 | run 'bundle install --path vendor/bundle --jobs=4 --without production' 237 | end 238 | 239 | # Rspec 240 | # ---------------------------------------------------------------- 241 | Bundler.with_clean_env do 242 | run 'bundle exec rails g rspec:install' 243 | end 244 | 245 | run "echo '--color -f d' > .rspec" 246 | 247 | insert_into_file 'spec/rails_helper.rb',%( 248 | # Coverage 249 | require 'simplecov' 250 | SimpleCov.start 'rails' 251 | ), after: "require 'rspec/rails'" 252 | 253 | insert_into_file 'spec/rails_helper.rb',%( 254 | config.order = 'random' 255 | 256 | config.before :suite do 257 | DatabaseRewinder.clean_all 258 | end 259 | 260 | config.after :each do 261 | DatabaseRewinder.clean 262 | end 263 | 264 | config.before :all do 265 | FactoryGirl.reload 266 | FactoryGirl.factories.clear 267 | FactoryGirl.sequences.clear 268 | FactoryGirl.find_definitions 269 | end 270 | 271 | config.include FactoryGirl::Syntax::Methods 272 | 273 | VCR.configure do |c| 274 | c.cassette_library_dir = 'spec/vcr' 275 | c.hook_into :webmock 276 | c.allow_http_connections_when_no_cassette = true 277 | end 278 | 279 | [:controller, :view, :request].each do |type| 280 | config.include ::Rails::Controller::Testing::TestProcess, type: type 281 | config.include ::Rails::Controller::Testing::TemplateAssertions, type: type 282 | config.include ::Rails::Controller::Testing::Integration, type: type 283 | end 284 | 285 | config.define_derived_metadata do |meta| 286 | meta[:aggregate_failures] = true unless meta.key?(:aggregate_failures) 287 | end 288 | ), after: 'RSpec.configure do |config|' 289 | 290 | insert_into_file 'spec/rails_helper.rb', "\nrequire 'factory_girl_rails'", after: "require 'rspec/rails'" 291 | run 'rm -rf test' 292 | 293 | # Checker 294 | # ---------------------------------------------------------------- 295 | get 'https://raw.github.com/morizyun/rails5_application_template/master/root/.rubocop.yml', '.rubocop.yml' 296 | get 'https://raw.github.com/morizyun/rails5_application_template/master/root/.overcommit.yml', '.overcommit.yml' 297 | get 'https://raw.github.com/morizyun/rails5_application_template/master/root/.haml-lint.yml', '.haml-lint.yml' 298 | 299 | # Rake DB Create 300 | # ---------------------------------------------------------------- 301 | Bundler.with_clean_env do 302 | run 'bundle exec rake db:create' 303 | end 304 | 305 | # Remove Invalid Files 306 | run 'rm -rf ./lib/templates' 307 | 308 | # Bundler-audit 309 | # ---------------------------------------------------------------- 310 | Bundler.with_clean_env do 311 | run 'bundle-audit update' 312 | end 313 | 314 | # Guard 315 | # ---------------------------------------------------------------- 316 | if yes?('Do you use Guard? [yes or ELSE]') 317 | insert_into_file 'Gemfile',%q{ 318 | 319 | # Handle events on file modifications 320 | gem 'guard-rspec', require: false 321 | gem 'guard-rubocop', require: false 322 | gem 'guard-livereload', require: false 323 | }, after: "gem 'factory_girl_rails'" 324 | 325 | Bundler.with_clean_env do 326 | run 'bundle install --path vendor/bundle --jobs=4 --without production' 327 | run 'bundle exec guard init rspec rubocop livereload' 328 | end 329 | end 330 | 331 | # Wercker(CI) 332 | # ---------------------------------------------------------------- 333 | if yes?('Do you use wercker? [yes or ELSE]') 334 | run 'wget https://raw.githubusercontent.com/morizyun/rails5_application_template/master/root/wercker.yml' 335 | gsub_file 'wercker.yml', /%RUBY_VERSION/, ruby_version 336 | run "echo 'Please Set SLACK_URL to https://app.wercker.com'" 337 | end 338 | 339 | # Rubocop Auto correct 340 | # ---------------------------------------------------------------- 341 | Bundler.with_clean_env do 342 | run 'bundle exec rubocop --auto-correct' 343 | run 'bundle exec rubocop --auto-gen-config' 344 | end 345 | 346 | # git init 347 | # ---------------------------------------------------------------- 348 | git :init 349 | git :add => '.' 350 | 351 | # overcommit 352 | # ---------------------------------------------------------------- 353 | Bundler.with_clean_env do 354 | run 'bundle exec overcommit --sign' 355 | end 356 | 357 | # git commit 358 | # ---------------------------------------------------------------- 359 | git :commit => "-a -m 'Initial commit'" 360 | -------------------------------------------------------------------------------- /config/initializers/airbrake.rb: -------------------------------------------------------------------------------- 1 | Airbrake.configure do |config| 2 | config.host = ENV['AIRBRAKE_HOST'] 3 | config.project_id = 1 4 | config.project_key = ENV['AIRBRAKE_PROJECT_KEY'] 5 | config.ignore_environments = [:development, :test] 6 | config.timeout = 120 7 | config.environment = Rails.env.to_s 8 | end 9 | -------------------------------------------------------------------------------- /config/puma.rb: -------------------------------------------------------------------------------- 1 | # Workers are forked web-server processes 2 | workers ENV.fetch('RAILS_WORKERS') { Rails.env.development? ? 0 : 2 }.to_i 3 | 4 | # Puma can serve each request in a thread from an internal thread pool. 5 | # The `threads` method setting takes two numbers a minimum and maximum. 6 | threads_count = ENV.fetch('RAILS_MAX_THREADS') { Rails.env.development? ? 1 : 5 }.to_i 7 | threads threads_count, threads_count 8 | 9 | # Specifies the `port` that Puma will listen on to receive requests, default is 3000. 10 | port ENV.fetch('PORT') { 3000 } 11 | 12 | # Specifies the `environment` that Puma will run in. 13 | environment ENV.fetch('RAILS_ENV') { 'development' } 14 | 15 | # Use the `preload_app!` method when specifying a `workers` number. 16 | preload_app! 17 | 18 | before_fork do 19 | ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord) 20 | end 21 | 22 | on_worker_boot do 23 | # Worker specific setup for Rails 4.1+ 24 | # See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot 25 | ActiveRecord::Base.establish_connection if defined?(ActiveRecord) 26 | end 27 | 28 | # Allow puma to be restarted by `rails restart` command. 29 | plugin :tmp_restart 30 | -------------------------------------------------------------------------------- /config/unicorn/development.rb: -------------------------------------------------------------------------------- 1 | worker_processes 2 2 | 3 | pid File.expand_path('tmp/pids/unicorn.pid', ENV['RAILS_ROOT']).to_s 4 | listen 3000 5 | 6 | stderr_path File.expand_path('log/error.log', ENV['RAILS_ROOT']) 7 | stdout_path File.expand_path('log/development.log', ENV['RAILS_ROOT']) 8 | 9 | preload_app true 10 | 11 | before_fork do |server, worker| 12 | ENV['BUNDLE_GEMFILE'] = "#{ENV['RAILS_ROOT']}/Gemfile" 13 | defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect! 14 | end 15 | 16 | after_fork do |server, worker| 17 | defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection 18 | end -------------------------------------------------------------------------------- /config/unicorn/heroku.rb: -------------------------------------------------------------------------------- 1 | # https://devcenter.heroku.com/articles/rails-unicorn 2 | worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3) 3 | timeout 15 4 | preload_app true 5 | 6 | before_fork do |_server, _worker| 7 | Signal.trap 'TERM' do 8 | puts 'Unicorn master intercepting TERM and sending myself QUIT instead' 9 | Process.kill 'QUIT', Process.pid 10 | end 11 | 12 | defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect! 13 | end 14 | 15 | after_fork do |_server, _worker| 16 | Signal.trap 'TERM' do 17 | puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT' 18 | end 19 | 20 | defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection 21 | end -------------------------------------------------------------------------------- /config/unicorn/production.rb: -------------------------------------------------------------------------------- 1 | worker_processes 3 2 | 3 | pid File.expand_path('tmp/pids/unicorn.pid', ENV['RAILS_ROOT']).to_s 4 | listen 5001 5 | 6 | stderr_path File.expand_path('log/error.log', ENV['RAILS_ROOT']) 7 | stdout_path File.expand_path('log/production.log', ENV['RAILS_ROOT']) 8 | 9 | preload_app true 10 | 11 | before_fork do |server, worker| 12 | ENV['BUNDLE_GEMFILE'] = File.expand_path('Gemfile', ENV['RAILS_ROOT']) 13 | 14 | defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect! 15 | end 16 | 17 | after_fork do |server, worker| 18 | defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection 19 | end 20 | -------------------------------------------------------------------------------- /config/unicorn/staging.rb: -------------------------------------------------------------------------------- 1 | worker_processes 3 2 | 3 | pid File.expand_path('tmp/pids/unicorn.pid', ENV['RAILS_ROOT']).to_s 4 | listen 5001 5 | 6 | stderr_path File.expand_path('log/error.log', ENV['RAILS_ROOT']) 7 | stdout_path File.expand_path('log/staging.log', ENV['RAILS_ROOT']) 8 | 9 | preload_app true 10 | 11 | before_fork do |server, worker| 12 | ENV['BUNDLE_GEMFILE'] = File.expand_path('Gemfile', ENV['RAILS_ROOT']) 13 | 14 | defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect! 15 | end 16 | 17 | after_fork do |server, worker| 18 | defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection 19 | end 20 | -------------------------------------------------------------------------------- /root/.haml-lint.yml: -------------------------------------------------------------------------------- 1 | linters: 2 | SpaceInsideHashAttributes: 3 | enabled: false 4 | 5 | LineLength: 6 | max: 200 7 | -------------------------------------------------------------------------------- /root/.overcommit.yml: -------------------------------------------------------------------------------- 1 | gemfile: 'Gemfile' 2 | 3 | PostCheckout: 4 | BundleInstall: 5 | enabled: true 6 | 7 | PreCommit: 8 | # Checks for vulnerable versions of gems 9 | BundleAudit: 10 | enabled: true 11 | on_warn: fail 12 | 13 | # Dependency Check 14 | BundleCheck: 15 | enabled: true 16 | on_warn: fail 17 | 18 | # Style checker for CoffeeScript 19 | CoffeeLint: 20 | enabled: true 21 | on_warn: fail 22 | 23 | # Style Check in HAML 24 | HamlLint: 25 | enabled: true 26 | on_warn: fail 27 | 28 | # Checks for hard tabs in files 29 | HardTabs: 30 | enabled: true 31 | on_warn: fail 32 | 33 | # Migration Check 34 | RailsSchemaUpToDate: 35 | enabled: true 36 | on_warn: fail 37 | 38 | # Style Check 39 | RuboCop: 40 | enabled: true 41 | command: ['bundle', 'exec', 'rubocop', '-c', './.rubocop.yml'] 42 | on_warn: fail 43 | 44 | # YAML Check 45 | YamlSyntax: 46 | enabled: true 47 | on_warn: fail 48 | 49 | PrePush: 50 | # Security Check 51 | Brakeman: 52 | enabled: true 53 | command: ['bundle', 'exec', 'brakeman'] 54 | on_warn: fail 55 | 56 | BundleInstall: 57 | enabled: true 58 | on_warn: fail 59 | 60 | # Unit & Integration TEST 61 | RSpec: 62 | enabled: true 63 | command: ['bundle', 'exec', 'rspec', 'spec'] 64 | on_warn: fail 65 | -------------------------------------------------------------------------------- /root/.rubocop.yml: -------------------------------------------------------------------------------- 1 | inherit_from: .rubocop_todo.yml 2 | 3 | AllCops: 4 | TargetRubyVersion: 2.4 5 | Exclude: 6 | - bin/**/* 7 | - config/boot.rb 8 | - db/schema.rb 9 | - script/**/* 10 | - tmp/**/* 11 | - vendor/**/* 12 | - Rakefile 13 | - Gemfile 14 | - config/unicorn/* 15 | DisplayCopNames: true 16 | 17 | Rails: 18 | Enabled: true 19 | 20 | Layout/AccessModifierIndentation: 21 | Enabled: false 22 | 23 | Layout/AlignArray: 24 | Enabled: false 25 | 26 | Layout/AlignHash: 27 | Enabled: false 28 | 29 | Layout/AlignParameters: 30 | Enabled: false 31 | 32 | Layout/BlockEndNewline: 33 | Enabled: false 34 | 35 | Layout/CaseIndentation: 36 | Enabled: false 37 | 38 | Layout/CommentIndentation: 39 | Enabled: false 40 | 41 | Layout/DotPosition: 42 | Enabled: false 43 | 44 | Layout/ElseAlignment: 45 | Enabled: false 46 | 47 | Layout/EmptyLineBetweenDefs: 48 | Enabled: false 49 | 50 | Layout/EmptyLines: 51 | Enabled: false 52 | 53 | Layout/EmptyLinesAroundAccessModifier: 54 | Enabled: false 55 | 56 | Layout/EmptyLinesAroundBlockBody: 57 | Enabled: false 58 | 59 | Layout/EmptyLinesAroundClassBody: 60 | Enabled: false 61 | 62 | Layout/EmptyLinesAroundModuleBody: 63 | Enabled: false 64 | 65 | Layout/EmptyLinesAroundMethodBody: 66 | Enabled: false 67 | 68 | Layout/EndOfLine: 69 | Enabled: false 70 | 71 | Layout/FirstParameterIndentation: 72 | Enabled: false 73 | 74 | Layout/IndentationConsistency: 75 | Enabled: false 76 | 77 | Layout/IndentationWidth: 78 | Enabled: false 79 | 80 | Layout/IndentArray: 81 | Enabled: false 82 | 83 | Layout/IndentHash: 84 | Enabled: false 85 | 86 | Layout/LeadingCommentSpace: 87 | Enabled: false 88 | 89 | Layout/MultilineBlockLayout: 90 | Enabled: false 91 | 92 | Layout/MultilineOperationIndentation: 93 | Enabled: false 94 | 95 | Layout/SpaceAfterColon: 96 | Enabled: false 97 | 98 | Layout/SpaceAfterComma: 99 | Enabled: false 100 | 101 | Layout/SpaceAroundKeyword: 102 | Enabled: false 103 | 104 | Layout/SpaceAfterMethodName: 105 | Enabled: false 106 | 107 | Layout/SpaceAfterNot: 108 | Enabled: false 109 | 110 | Layout/SpaceAfterSemicolon: 111 | Enabled: false 112 | 113 | Layout/SpaceBeforeBlockBraces: 114 | Enabled: false 115 | 116 | Layout/SpaceBeforeComma: 117 | Enabled: false 118 | 119 | Layout/SpaceBeforeComment: 120 | Enabled: false 121 | 122 | Layout/SpaceBeforeSemicolon: 123 | Enabled: false 124 | 125 | Layout/SpaceInsideBlockBraces: 126 | Enabled: false 127 | 128 | Layout/SpaceAroundBlockParameters: 129 | Enabled: false 130 | 131 | Layout/SpaceAroundEqualsInParameterDefault: 132 | Enabled: false 133 | 134 | Layout/SpaceAroundOperators: 135 | Enabled: false 136 | 137 | Layout/SpaceAroundKeyword: 138 | Enabled: false 139 | 140 | Layout/SpaceInsideBrackets: 141 | Enabled: false 142 | 143 | Layout/SpaceInsideHashLiteralBraces: 144 | Enabled: false 145 | 146 | Layout/SpaceInsideParens: 147 | Enabled: false 148 | 149 | Layout/SpaceInsideRangeLiteral: 150 | Enabled: false 151 | 152 | Layout/Tab: 153 | Enabled: false 154 | 155 | Layout/TrailingBlankLines: 156 | Enabled: false 157 | 158 | Layout/TrailingWhitespace: 159 | Enabled: false 160 | 161 | Style/AccessorMethodName: 162 | Enabled: false 163 | 164 | Style/Alias: 165 | Enabled: false 166 | 167 | Style/AndOr: 168 | Enabled: true 169 | 170 | Style/ArrayJoin: 171 | Enabled: false 172 | 173 | # Allow Asian comment 174 | #Style/AsciiComments: 175 | # Enabled: false 176 | 177 | Style/AsciiIdentifiers: 178 | Enabled: false 179 | 180 | Style/Attr: 181 | Enabled: false 182 | 183 | Style/BeginBlock: 184 | Enabled: false 185 | 186 | Style/BarePercentLiterals: 187 | Enabled: false 188 | 189 | Style/BlockComments: 190 | Enabled: false 191 | 192 | Style/BracesAroundHashParameters: 193 | Enabled: false 194 | 195 | Style/CaseEquality: 196 | Enabled: false 197 | 198 | Style/CharacterLiteral: 199 | Enabled: false 200 | 201 | Style/ClassAndModuleCamelCase: 202 | Enabled: false 203 | 204 | Style/ClassAndModuleChildren: 205 | Enabled: false 206 | 207 | Style/ClassCheck: 208 | Enabled: false 209 | 210 | Style/ClassMethods: 211 | Enabled: false 212 | 213 | Style/ClassVars: 214 | Enabled: false 215 | 216 | Style/ColonMethodCall: 217 | Enabled: false 218 | 219 | Style/CommentAnnotation: 220 | Enabled: false 221 | 222 | Style/ConstantName: 223 | Enabled: false 224 | 225 | Style/DefWithParentheses: 226 | Enabled: false 227 | 228 | Style/PreferredHashMethods: 229 | Enabled: false 230 | 231 | Style/Documentation: 232 | Enabled: false 233 | 234 | Style/DoubleNegation: 235 | Enabled: false 236 | 237 | Style/EachWithObject: 238 | Enabled: false 239 | 240 | Style/EmptyElse: 241 | Enabled: false 242 | 243 | Style/EmptyLiteral: 244 | Enabled: false 245 | 246 | Style/EndBlock: 247 | Enabled: false 248 | 249 | Style/EvenOdd: 250 | Enabled: false 251 | 252 | Style/FileName: 253 | Enabled: false 254 | 255 | Style/FlipFlop: 256 | Enabled: false 257 | 258 | Style/For: 259 | Enabled: false 260 | 261 | Style/FormatString: 262 | Enabled: false 263 | 264 | Style/GlobalVars: 265 | Enabled: true 266 | 267 | Style/GuardClause: 268 | Enabled: false 269 | 270 | Style/HashSyntax: 271 | Enabled: false 272 | 273 | Style/IfUnlessModifier: 274 | Enabled: false 275 | 276 | Style/IfWithSemicolon: 277 | Enabled: false 278 | 279 | Style/InfiniteLoop: 280 | Enabled: false 281 | 282 | Style/Lambda: 283 | Enabled: false 284 | 285 | Style/LambdaCall: 286 | Enabled: false 287 | 288 | Style/LineEndConcatenation: 289 | Enabled: false 290 | 291 | Style/MethodCallWithoutArgsParentheses: 292 | Enabled: false 293 | 294 | Style/MethodDefParentheses: 295 | Enabled: false 296 | 297 | Style/MethodName: 298 | Enabled: false 299 | 300 | Style/ModuleFunction: 301 | Enabled: false 302 | 303 | Style/MultilineBlockChain: 304 | Enabled: false 305 | 306 | Style/MultilineIfThen: 307 | Enabled: false 308 | 309 | Style/MultilineTernaryOperator: 310 | Enabled: false 311 | 312 | Style/NegatedIf: 313 | Enabled: false 314 | 315 | Style/NegatedWhile: 316 | Enabled: false 317 | 318 | Style/NestedTernaryOperator: 319 | Enabled: false 320 | 321 | Style/Next: 322 | Enabled: false 323 | 324 | Style/NilComparison: 325 | Enabled: false 326 | 327 | Style/NonNilCheck: 328 | Enabled: false 329 | 330 | Style/Not: 331 | Enabled: false 332 | 333 | Style/NumericLiterals: 334 | Enabled: false 335 | 336 | Style/OneLineConditional: 337 | Enabled: false 338 | 339 | Style/OpMethod: 340 | Enabled: false 341 | 342 | Style/ParenthesesAroundCondition: 343 | Enabled: false 344 | 345 | Style/PercentLiteralDelimiters: 346 | Enabled: false 347 | 348 | Style/PercentQLiterals: 349 | Enabled: false 350 | 351 | Style/PerlBackrefs: 352 | Enabled: false 353 | 354 | Style/PredicateName: 355 | Enabled: false 356 | 357 | Style/Proc: 358 | Enabled: false 359 | 360 | Style/RaiseArgs: 361 | Enabled: false 362 | 363 | Style/RedundantBegin: 364 | Enabled: false 365 | 366 | Style/RedundantException: 367 | Enabled: false 368 | 369 | Style/RedundantReturn: 370 | Enabled: false 371 | 372 | Style/RedundantSelf: 373 | Enabled: false 374 | 375 | Style/RegexpLiteral: 376 | Enabled: false 377 | 378 | Style/RescueModifier: 379 | Enabled: false 380 | 381 | Style/SelfAssignment: 382 | Enabled: false 383 | 384 | Style/Semicolon: 385 | Enabled: false 386 | 387 | Style/SignalException: 388 | Enabled: false 389 | 390 | Style/SingleLineBlockParams: 391 | Enabled: false 392 | 393 | Style/SingleLineMethods: 394 | Enabled: false 395 | 396 | Style/SpecialGlobalVars: 397 | Enabled: false 398 | 399 | Style/StringLiterals: 400 | Enabled: false 401 | 402 | Style/StringLiteralsInInterpolation: 403 | Enabled: false 404 | 405 | Style/StructInheritance: 406 | Enabled: false 407 | 408 | Style/SymbolProc: 409 | Enabled: false 410 | 411 | Style/TrailingCommaInLiteral: 412 | Enabled: false 413 | 414 | Style/TrivialAccessors: 415 | Enabled: false 416 | 417 | Style/UnlessElse: 418 | Enabled: false 419 | 420 | Style/UnneededCapitalW: 421 | Enabled: false 422 | 423 | Style/UnneededPercentQ: 424 | Enabled: false 425 | 426 | Style/VariableInterpolation: 427 | Enabled: false 428 | 429 | Style/VariableName: 430 | Enabled: false 431 | 432 | Style/WhenThen: 433 | Enabled: false 434 | 435 | Style/WhileUntilDo: 436 | Enabled: false 437 | 438 | Style/WhileUntilModifier: 439 | Enabled: false 440 | 441 | Style/WordArray: 442 | Enabled: false 443 | 444 | Style/FrozenStringLiteralComment: 445 | Enabled: false 446 | 447 | Lint/DeprecatedClassMethods: 448 | Enabled: false 449 | 450 | Lint/StringConversionInInterpolation: 451 | Enabled: false 452 | 453 | Metrics/AbcSize: 454 | Enabled: false 455 | 456 | Metrics/BlockNesting: 457 | Enabled: false 458 | 459 | Metrics/ClassLength: 460 | Enabled: false 461 | 462 | Metrics/CyclomaticComplexity: 463 | Enabled: false 464 | 465 | Metrics/LineLength: 466 | Enabled: false 467 | 468 | Metrics/MethodLength: 469 | Enabled: false 470 | 471 | Metrics/ParameterLists: 472 | Enabled: false 473 | 474 | Metrics/PerceivedComplexity: 475 | Enabled: false 476 | -------------------------------------------------------------------------------- /root/wercker.yml: -------------------------------------------------------------------------------- 1 | box: ruby:%RUBY_VERSION 2 | 3 | # You can also use services such as databases. Read more on our dev center: 4 | # http://devcenter.wercker.com/docs/services/index.html 5 | # http://devcenter.wercker.com/docs/services/postgresql.html 6 | services: 7 | - id: postgres 8 | env: 9 | POSTGRES_PASSWORD: secret_password 10 | 11 | # http://devcenter.wercker.com/docs/pipelines/index.html 12 | unit-test: 13 | # http://devcenter.wercker.com/docs/steps/index.html 14 | steps: 15 | - bundle-install: 16 | jobs: 4 17 | 18 | # Prepare postgresql for Rails 19 | - rails-database-yml: 20 | service: postgresql-docker 21 | 22 | - install-packages: 23 | name: Install node.js, build-essential, libpq-dev 24 | packages: build-essential libpq-dev nodejs 25 | 26 | - script: 27 | name: Set up db 28 | code: | 29 | RAILS_ENV=test bundle exec rake db:schema:load 30 | 31 | - script: 32 | name: Run RSpec 33 | code: bundle exec rspec 34 | 35 | after-steps: 36 | - slack-notifier: 37 | url: $SLACK_URL 38 | channel: price-seek-notify 39 | username: werckerbot 40 | notify_on: failed 41 | --------------------------------------------------------------------------------