Skip to content

Instantly share code, notes, and snippets.

@koshigoe
Created May 10, 2018 22:40
Show Gist options
  • Select an option

  • Save koshigoe/164cdb6579f0aa76782b8d367079b8ba to your computer and use it in GitHub Desktop.

Select an option

Save koshigoe/164cdb6579f0aa76782b8d367079b8ba to your computer and use it in GitHub Desktop.
Rails 5.1.6 と Rails 5.2.0 の新規アプリ間の差分確認
$ rails _5.1.6_ new -d postgresql --api --skip-test --skip-bundle --skip-git rails-api-5.1.6
$ rails _5.2.0_ new -d postgresql --api --skip-test --skip-bundle --skip-git rails-api-5.2.0
$ diff -ur rails-api-5.1.6/ rails-api-5.2.0/
Only in rails-api-5.2.0/: .ruby-version
diff -ur rails-api-5.1.6/Gemfile rails-api-5.2.0/Gemfile
--- rails-api-5.1.6/Gemfile 2018-05-11 07:34:09.000000000 +0900
+++ rails-api-5.2.0/Gemfile 2018-05-11 07:34:14.000000000 +0900
@@ -1,17 +1,14 @@
source 'https://rubygems.org'
+git_source(:github) { |repo| "https://github.com/#{repo}.git" }
-git_source(:github) do |repo_name|
- repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
- "https://github.com/#{repo_name}.git"
-end
-
+ruby '2.4.0'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
-gem 'rails', '~> 5.1.6'
+gem 'rails', '~> 5.2.0'
# Use postgresql as the database for Active Record
gem 'pg', '>= 0.18', '< 2.0'
# Use Puma as the app server
-gem 'puma', '~> 3.7'
+gem 'puma', '~> 3.11'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
# gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
@@ -19,9 +16,15 @@
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
+# Use ActiveStorage variant
+# gem 'mini_magick', '~> 4.8'
+
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
+# Reduces boot times through caching; required in config/boot.rb
+gem 'bootsnap', '>= 1.1.0', require: false
+
# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
# gem 'rack-cors'
@@ -37,5 +40,6 @@
gem 'spring-watcher-listen', '~> 2.0.0'
end
+
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
diff -ur rails-api-5.1.6/bin/bundle rails-api-5.2.0/bin/bundle
--- rails-api-5.1.6/bin/bundle 2018-05-11 07:34:09.000000000 +0900
+++ rails-api-5.2.0/bin/bundle 2018-05-11 07:34:14.000000000 +0900
@@ -1,3 +1,3 @@
#!/usr/bin/env ruby
-ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
load Gem.bin_path('bundler', 'bundle')
diff -ur rails-api-5.1.6/bin/setup rails-api-5.2.0/bin/setup
--- rails-api-5.1.6/bin/setup 2018-05-11 07:34:09.000000000 +0900
+++ rails-api-5.2.0/bin/setup 2018-05-11 07:34:14.000000000 +0900
@@ -1,10 +1,9 @@
#!/usr/bin/env ruby
-require 'pathname'
require 'fileutils'
include FileUtils
# path to your application root.
-APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
+APP_ROOT = File.expand_path('..', __dir__)
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
@@ -18,7 +17,6 @@
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
-
# puts "\n== Copying sample files =="
# unless File.exist?('config/database.yml')
# cp 'config/database.yml.sample', 'config/database.yml'
diff -ur rails-api-5.1.6/bin/update rails-api-5.2.0/bin/update
--- rails-api-5.1.6/bin/update 2018-05-11 07:34:09.000000000 +0900
+++ rails-api-5.2.0/bin/update 2018-05-11 07:34:14.000000000 +0900
@@ -1,10 +1,9 @@
#!/usr/bin/env ruby
-require 'pathname'
require 'fileutils'
include FileUtils
# path to your application root.
-APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
+APP_ROOT = File.expand_path('..', __dir__)
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
diff -ur rails-api-5.1.6/config/application.rb rails-api-5.2.0/config/application.rb
--- rails-api-5.1.6/config/application.rb 2018-05-11 07:34:09.000000000 +0900
+++ rails-api-5.2.0/config/application.rb 2018-05-11 07:34:14.000000000 +0900
@@ -5,6 +5,7 @@
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
+require "active_storage/engine"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
@@ -16,14 +17,15 @@
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
-module RailsApi516
+module RailsApi520
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
- config.load_defaults 5.1
+ config.load_defaults 5.2
# 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.
+ # Application configuration can go into files in config/initializers
+ # -- all .rb files in that directory are automatically loaded after loading
+ # the framework and any gems in your application.
# Only loads a smaller set of middleware suitable for API only apps.
# Middleware like session, flash, cookies can be added back manually.
diff -ur rails-api-5.1.6/config/boot.rb rails-api-5.2.0/config/boot.rb
--- rails-api-5.1.6/config/boot.rb 2018-05-11 07:34:09.000000000 +0900
+++ rails-api-5.2.0/config/boot.rb 2018-05-11 07:34:15.000000000 +0900
@@ -1,3 +1,4 @@
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require 'bundler/setup' # Set up gems listed in the Gemfile.
+require 'bootsnap/setup' # Speed up boot time by caching expensive operations.
diff -ur rails-api-5.1.6/config/cable.yml rails-api-5.2.0/config/cable.yml
--- rails-api-5.1.6/config/cable.yml 2018-05-11 07:34:09.000000000 +0900
+++ rails-api-5.2.0/config/cable.yml 2018-05-11 07:34:14.000000000 +0900
@@ -6,5 +6,5 @@
production:
adapter: redis
- url: redis://localhost:6379/1
- channel_prefix: rails-api-5_1_6_production
+ url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
+ channel_prefix: rails-api-5_2_0_production
Only in rails-api-5.2.0/config: credentials.yml.enc
diff -ur rails-api-5.1.6/config/database.yml rails-api-5.2.0/config/database.yml
--- rails-api-5.1.6/config/database.yml 2018-05-11 07:34:09.000000000 +0900
+++ rails-api-5.2.0/config/database.yml 2018-05-11 07:34:15.000000000 +0900
@@ -23,13 +23,13 @@
development:
<<: *default
- database: rails-api-5_1_6_development
+ database: rails-api-5_2_0_development
# The specified database role being used to connect to postgres.
# To create additional roles in postgres see `$ createuser --help`.
# When left blank, postgres will use the default role. This is
# the same name as the operating system user that initialized the database.
- #username: rails-api-5_1_6
+ #username: rails-api-5_2_0
# The password associated with the postgres role (username).
#password:
@@ -57,7 +57,7 @@
# Do not set this db to the same as development or production.
test:
<<: *default
- database: rails-api-5_1_6_test
+ database: rails-api-5_2_0_test
# As with config/secrets.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
@@ -80,6 +80,6 @@
#
production:
<<: *default
- database: rails-api-5_1_6_production
- username: rails-api-5_1_6
- password: <%= ENV['RAILS-API-5_1_6_DATABASE_PASSWORD'] %>
+ database: rails-api-5_2_0_production
+ username: rails-api-5_2_0
+ password: <%= ENV['RAILS-API-5_2_0_DATABASE_PASSWORD'] %>
diff -ur rails-api-5.1.6/config/environments/development.rb rails-api-5.2.0/config/environments/development.rb
--- rails-api-5.1.6/config/environments/development.rb 2018-05-11 07:34:09.000000000 +0900
+++ rails-api-5.2.0/config/environments/development.rb 2018-05-11 07:34:14.000000000 +0900
@@ -13,12 +13,13 @@
config.consider_all_requests_local = true
# Enable/disable caching. By default caching is disabled.
- if Rails.root.join('tmp/caching-dev.txt').exist?
+ # Run rails dev:cache to toggle caching.
+ if Rails.root.join('tmp', 'caching-dev.txt').exist?
config.action_controller.perform_caching = true
config.cache_store = :memory_store
config.public_file_server.headers = {
- 'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}"
+ 'Cache-Control' => "public, max-age=#{2.days.to_i}"
}
else
config.action_controller.perform_caching = false
@@ -26,6 +27,9 @@
config.cache_store = :null_store
end
+ # Store uploaded files on the local file system (see config/storage.yml for options)
+ config.active_storage.service = :local
+
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
@@ -37,6 +41,9 @@
# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load
+ # Highlight code that triggered database queries in logs.
+ config.active_record.verbose_query_logs = true
+
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
diff -ur rails-api-5.1.6/config/environments/production.rb rails-api-5.2.0/config/environments/production.rb
--- rails-api-5.1.6/config/environments/production.rb 2018-05-11 07:34:09.000000000 +0900
+++ rails-api-5.2.0/config/environments/production.rb 2018-05-11 07:34:14.000000000 +0900
@@ -14,16 +14,14 @@
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
- # Attempt to read encrypted secrets from `config/secrets.yml.enc`.
- # Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or
- # `config/secrets.yml.key`.
- config.read_encrypted_secrets = true
+ # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
+ # or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
+ # config.require_master_key = true
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
-
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
@@ -31,6 +29,9 @@
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
+ # Store uploaded files on the local file system (see config/storage.yml for options)
+ config.active_storage.service = :local
+
# Mount Action Cable outside main process or domain
# config.action_cable.mount_path = nil
# config.action_cable.url = 'wss://example.com/cable'
@@ -51,7 +52,8 @@
# Use a real queuing backend for Active Job (and separate queues per environment)
# config.active_job.queue_adapter = :resque
- # config.active_job.queue_name_prefix = "rails-api-5_1_6_#{Rails.env}"
+ # config.active_job.queue_name_prefix = "rails-api-5_2_0_#{Rails.env}"
+
config.action_mailer.perform_caching = false
# Ignore bad email addresses and do not raise email delivery errors.
diff -ur rails-api-5.1.6/config/environments/test.rb rails-api-5.2.0/config/environments/test.rb
--- rails-api-5.1.6/config/environments/test.rb 2018-05-11 07:34:09.000000000 +0900
+++ rails-api-5.2.0/config/environments/test.rb 2018-05-11 07:34:14.000000000 +0900
@@ -15,7 +15,7 @@
# Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true
config.public_file_server.headers = {
- 'Cache-Control' => "public, max-age=#{1.hour.seconds.to_i}"
+ 'Cache-Control' => "public, max-age=#{1.hour.to_i}"
}
# Show full error reports and disable caching.
@@ -27,6 +27,10 @@
# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false
+
+ # Store uploaded files on the local file system in a temporary directory
+ config.active_storage.service = :test
+
config.action_mailer.perform_caching = false
# Tell Action Mailer not to deliver emails to the real world.
Only in rails-api-5.2.0/config: master.key
diff -ur rails-api-5.1.6/config/puma.rb rails-api-5.2.0/config/puma.rb
--- rails-api-5.1.6/config/puma.rb 2018-05-11 07:34:09.000000000 +0900
+++ rails-api-5.2.0/config/puma.rb 2018-05-11 07:34:14.000000000 +0900
@@ -26,31 +26,9 @@
# Use the `preload_app!` method when specifying a `workers` number.
# This directive tells Puma to first boot the application and load code
# before forking the application. This takes advantage of Copy On Write
-# process behavior so workers use less memory. If you use this option
-# you need to make sure to reconnect any threads in the `on_worker_boot`
-# block.
+# process behavior so workers use less memory.
#
# preload_app!
-# If you are preloading your application and using Active Record, it's
-# recommended that you close any connections to the database before workers
-# are forked to prevent connection leakage.
-#
-# before_fork do
-# ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord)
-# end
-
-# The code in the `on_worker_boot` will be called if you are using
-# clustered mode by specifying a number of `workers`. After each worker
-# process is booted, this block will be run. If you are using the `preload_app!`
-# option, you will want to use this block to reconnect to any threads
-# or connections that may have been created at application boot, as Ruby
-# cannot share connections between processes.
-#
-# on_worker_boot do
-# ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
-# end
-#
-
# Allow puma to be restarted by `rails restart` command.
plugin :tmp_restart
Only in rails-api-5.1.6/config: secrets.yml
diff -ur rails-api-5.1.6/config/spring.rb rails-api-5.2.0/config/spring.rb
--- rails-api-5.1.6/config/spring.rb 2018-05-11 07:34:09.000000000 +0900
+++ rails-api-5.2.0/config/spring.rb 2018-05-11 07:34:14.000000000 +0900
@@ -1,6 +1,6 @@
-%w(
+%w[
.ruby-version
.rbenv-vars
tmp/restart.txt
tmp/caching-dev.txt
-).each { |path| Spring.watch(path) }
+].each { |path| Spring.watch(path) }
Only in rails-api-5.2.0/config: storage.yml
Only in rails-api-5.2.0/: storage
Only in rails-api-5.2.0/tmp: storage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment