Skip to content

Commit fac4439

Browse files
committed
rails app:update + railsdiff
1 parent 5cade8a commit fac4439

24 files changed

+250
-148
lines changed

Gemfile

+7-5
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ gem 'premailer-rails', '< 1.10' # 1.10 requires Rails.application.assets_manifes
3131
# Views
3232
gem 'csv_builder', '~> 2.1'
3333
gem 'haml-rails', '~> 0.9'
34-
gem 'jbuilder', '~> 1.2'
34+
gem 'jbuilder', '~> 1.2' # TODO: next?('~> 2.5', '~> 1.2')
3535
gem 'view_components', git: 'https://github.com/manastech/rails-view_components.git', branch: 'master'
3636
gem 'wicked_pdf', '~> 2.1'
3737

@@ -73,7 +73,7 @@ gem 'geojson_import', git: 'https://github.com/instedd/geojson_import', branch:
7373
# end
7474

7575
# Services
76-
gem 'puma', '~> 2.13'
76+
gem 'puma', next?('~> 3.0', '~> 2.13')
7777
gem 'sidekiq', '~> 3.5'
7878
gem 'sinatra', '~> 1.4' unless next? # for sidekiq web FIXME: upgrade sidekiq
7979
gem 'sidekiq-cron', '~> 0.3'
@@ -93,7 +93,7 @@ else
9393
gem 'sass-rails', '~> 4.0'
9494
end
9595
gem 'therubyracer', '~> 0.12' # FIXME: deprecated for years
96-
gem 'turbolinks', '~> 2.5'
96+
gem 'turbolinks', '~> 2.5' # TODO: next?('~> 5', '~> 2.5')
9797
gem 'uglifier', '~> 2.7'
9898

9999
# TODO: externalize frontend dependencies (NPM or YARN)!
@@ -111,16 +111,18 @@ end
111111

112112
group :development do
113113
gem 'letter_opener'
114+
gem 'listen', '~> 3.0.5' if next?
114115
gem 'quiet_assets' unless next?
116+
gem 'spring'
117+
gem 'spring-commands-rspec'
118+
gem 'spring-watcher-listen', '~> 2.0.0' if next?
115119
gem 'web-console', '< 4.0' # last version to support ruby 2.2
116120
end
117121

118122
group :development, :test do
119123
gem 'pry-byebug', '< 2.7.0' unless next? # last version to support ruby 2.2
120124
gem 'pry-rescue'
121125
gem 'pry-stack_explorer'
122-
gem 'spring'
123-
gem 'spring-commands-rspec'
124126
end
125127

126128
group :test do

Gemfile.next.lock

+10-2
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,9 @@ GEM
332332
letter_opener (1.8.0)
333333
launchy (>= 2.2, < 3)
334334
libv8 (3.16.14.19)
335+
listen (3.0.8)
336+
rb-fsevent (~> 0.9, >= 0.9.4)
337+
rb-inotify (~> 0.9, >= 0.9.7)
335338
lodash-rails (3.10.1)
336339
railties (>= 3.1)
337340
loofah (2.15.0)
@@ -395,7 +398,7 @@ GEM
395398
binding_of_caller (~> 0.7)
396399
pry (~> 0.13)
397400
public_suffix (3.1.1)
398-
puma (2.16.0)
401+
puma (3.12.6)
399402
raabro (1.4.0)
400403
rack (2.1.4)
401404
rack-test (0.6.3)
@@ -525,6 +528,9 @@ GEM
525528
activesupport (>= 4.2)
526529
spring-commands-rspec (1.0.4)
527530
spring (>= 0.9.1)
531+
spring-watcher-listen (2.0.1)
532+
listen (>= 2.7, < 4.0)
533+
spring (>= 1.2, < 3.0)
528534
sprockets (3.7.2)
529535
concurrent-ruby (~> 1.0)
530536
rack (> 1, < 3)
@@ -611,6 +617,7 @@ DEPENDENCIES
611617
kaminari (~> 0.16)
612618
leaflet-rails (~> 0.7.4)
613619
letter_opener
620+
listen (~> 3.0.5)
614621
location_service!
615622
lodash-rails (~> 3.10.1)
616623
machinist (~> 2.0)
@@ -626,7 +633,7 @@ DEPENDENCIES
626633
premailer-rails (< 1.10)
627634
pry-rescue
628635
pry-stack_explorer
629-
puma (~> 2.13)
636+
puma (~> 3.0)
630637
rack (< 2.2.0)
631638
rails (~> 5.0.0)
632639
rails-assets-urijs (~> 1.17.0)!
@@ -650,6 +657,7 @@ DEPENDENCIES
650657
site_prism (~> 2.17)
651658
spring
652659
spring-commands-rspec
660+
spring-watcher-listen (~> 2.0.0)
653661
sprockets-rails (< 3.3.0)
654662
therubyracer (~> 0.12)
655663
timecop (~> 0.8)

Rakefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Add your own tasks in files placed in lib/tasks ending in .rake,
22
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
33

4-
require File.expand_path('../config/application', __FILE__)
4+
require_relative 'config/application'
55

66
Rails.application.load_tasks

app/assets/javascripts/application.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
66
//
77
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8-
// compiled file.
8+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
99
//
1010
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
1111
// about supported directives.

bin/bundle

+2-104
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,3 @@
11
#!/usr/bin/env ruby
2-
# frozen_string_literal: true
3-
4-
#
5-
# This file was generated by Bundler.
6-
#
7-
# The application 'bundle' is installed as part of a gem, and
8-
# this file is here to facilitate running it.
9-
#
10-
11-
require "rubygems"
12-
13-
m = Module.new do
14-
module_function
15-
16-
def invoked_as_script?
17-
File.expand_path($0) == File.expand_path(__FILE__)
18-
end
19-
20-
def env_var_version
21-
ENV["BUNDLER_VERSION"]
22-
end
23-
24-
def cli_arg_version
25-
return unless invoked_as_script? # don't want to hijack other binstubs
26-
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
27-
bundler_version = nil
28-
update_index = nil
29-
ARGV.each_with_index do |a, i|
30-
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
31-
bundler_version = a
32-
end
33-
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
34-
bundler_version = $1 || ">= 0.a"
35-
update_index = i
36-
end
37-
bundler_version
38-
end
39-
40-
def gemfile
41-
gemfile = ENV["BUNDLE_GEMFILE"]
42-
return gemfile if gemfile && !gemfile.empty?
43-
44-
File.expand_path("../../Gemfile", __FILE__)
45-
end
46-
47-
def lockfile
48-
lockfile =
49-
case File.basename(gemfile)
50-
when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
51-
else "#{gemfile}.lock"
52-
end
53-
File.expand_path(lockfile)
54-
end
55-
56-
def lockfile_version
57-
return unless File.file?(lockfile)
58-
lockfile_contents = File.read(lockfile)
59-
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
60-
Regexp.last_match(1)
61-
end
62-
63-
def bundler_version
64-
@bundler_version ||= begin
65-
env_var_version || cli_arg_version ||
66-
lockfile_version || "#{Gem::Requirement.default}.a"
67-
end
68-
end
69-
70-
def load_bundler!
71-
ENV["BUNDLE_GEMFILE"] ||= gemfile
72-
73-
# must dup string for RG < 1.8 compatibility
74-
activate_bundler(bundler_version.dup)
75-
end
76-
77-
def activate_bundler(bundler_version)
78-
if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new("2.0")
79-
bundler_version = "< 2"
80-
end
81-
gem_error = activation_error_handling do
82-
gem "bundler", bundler_version
83-
end
84-
return if gem_error.nil?
85-
require_error = activation_error_handling do
86-
require "bundler/version"
87-
end
88-
return if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION))
89-
warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`"
90-
exit 42
91-
end
92-
93-
def activation_error_handling
94-
yield
95-
nil
96-
rescue StandardError, LoadError => e
97-
e
98-
end
99-
end
100-
101-
m.load_bundler!
102-
103-
if m.invoked_as_script?
104-
load Gem.bin_path("bundler", "bundle")
105-
end
2+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3+
load Gem.bin_path('bundler', 'bundle')

bin/rails

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env ruby
2-
APP_PATH = File.expand_path('../../config/application', __FILE__)
2+
APP_PATH = File.expand_path('../config/application', __dir__)
33
require_relative '../config/boot'
44
require 'rails/commands'

bin/setup

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env ruby
2+
require 'pathname'
3+
require 'fileutils'
4+
include FileUtils
5+
6+
# path to your application root.
7+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8+
9+
def system!(*args)
10+
system(*args) || abort("\n== Command #{args} failed ==")
11+
end
12+
13+
chdir APP_ROOT do
14+
# This script is a starting point to setup your application.
15+
# Add necessary setup steps to this file.
16+
17+
puts '== Installing dependencies =='
18+
system! 'gem install bundler --conservative'
19+
system('bundle check') || system!('bundle install')
20+
21+
# puts "\n== Copying sample files =="
22+
# unless File.exist?('config/database.yml')
23+
# cp 'config/database.yml.sample', 'config/database.yml'
24+
# end
25+
26+
puts "\n== Preparing database =="
27+
system! 'bin/rails db:setup'
28+
29+
puts "\n== Removing old logs and tempfiles =="
30+
system! 'bin/rails log:clear tmp:clear'
31+
32+
puts "\n== Restarting application server =="
33+
system! 'bin/rails restart'
34+
end

bin/update

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env ruby
2+
require 'pathname'
3+
require 'fileutils'
4+
include FileUtils
5+
6+
# path to your application root.
7+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8+
9+
def system!(*args)
10+
system(*args) || abort("\n== Command #{args} failed ==")
11+
end
12+
13+
chdir APP_ROOT do
14+
# This script is a way to update your development environment automatically.
15+
# Add necessary update steps to this file.
16+
17+
puts '== Installing dependencies =='
18+
system! 'gem install bundler --conservative'
19+
system('bundle check') || system!('bundle install')
20+
21+
puts "\n== Updating database =="
22+
system! 'bin/rails db:migrate'
23+
24+
puts "\n== Removing old logs and tempfiles =="
25+
system! 'bin/rails log:clear tmp:clear'
26+
27+
puts "\n== Restarting application server =="
28+
system! 'bin/rails restart'
29+
end

config.ru

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# This file is used by Rack-based servers to start the application.
22

3-
require ::File.expand_path('../config/environment', __FILE__)
3+
require_relative 'config/environment'
44
run Rails.application

config/application.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require File.expand_path('../boot', __FILE__)
1+
require_relative 'boot'
22

33
require 'rails/all'
44

config/boot.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
1+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
22

33
require 'bundler/setup' # Set up gems listed in the Gemfile.

config/environment.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Load the Rails application.
2-
require File.expand_path('../application', __FILE__)
2+
require_relative 'application'
33

44
# Initialize the Rails application.
55
Rails.application.initialize!

config/environments/development.rb

+28-6
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,24 @@
99
# Do not eager load code on boot.
1010
config.eager_load = false
1111

12-
# Show full error reports and disable caching.
13-
config.consider_all_requests_local = true
14-
config.action_controller.perform_caching = false
12+
# Show full error reports.
13+
config.consider_all_requests_local = true
14+
15+
if Rails::VERSION::MAJOR >= 5
16+
# Enable/disable caching. By default caching is disabled.
17+
if Rails.root.join('tmp/caching-dev.txt').exist?
18+
config.action_controller.perform_caching = true
19+
20+
config.cache_store = :memory_store
21+
config.public_file_server.headers = {
22+
'Cache-Control' => 'public, max-age=172800'
23+
}
24+
else
25+
config.action_controller.perform_caching = false
26+
27+
config.cache_store = :null_store
28+
end
29+
end
1530

1631
# Don't care if the mailer can't send.
1732
config.action_mailer.raise_delivery_errors = false
@@ -29,9 +44,10 @@
2944
# number of complex assets.
3045
config.assets.debug = true
3146

32-
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
33-
# yet still be able to expire them through the digest params.
34-
config.assets.digest = true
47+
if Rails::VERSION::MAJOR >= 5
48+
# Suppress logger output for asset requests.
49+
config.assets.quiet = true
50+
end
3551

3652
# Adds additional error checking when serving assets at runtime.
3753
# Checks for improperly declared sprockets dependencies.
@@ -41,6 +57,12 @@
4157
# Raises error for missing translations
4258
# config.action_view.raise_on_missing_translations = true
4359

60+
if Rails::VERSION::MAJOR > 5
61+
# Use an evented file watcher to asynchronously detect changes in source code,
62+
# routes, locales, etc. This feature depends on the listen gem.
63+
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
64+
end
65+
4466
config.action_mailer.default_url_options = { host: Settings.host }
4567

4668
config.active_job.queue_adapter = :sidekiq

0 commit comments

Comments
 (0)