Skip to content

Commit e09de36

Browse files
committed
Remove bundler Ruby version resolution workarounds
With the recent Rubygems server fixes and database backfills, we don't need most of the manual workarounds to resolve dependency Ruby version support.
1 parent cbf4238 commit e09de36

File tree

3 files changed

+41
-89
lines changed

3 files changed

+41
-89
lines changed

Gemfile

Lines changed: 18 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -14,63 +14,33 @@ group :documentation do
1414
gem 'relish', '~> 0.7.1'
1515
end
1616

17-
platforms :jruby do
18-
gem "jruby-openssl"
19-
end
17+
gem 'rake', '~> 12'
2018

21-
case RAILS_VERSION
22-
when /main/
23-
MAJOR = 6
24-
MINOR = 0
25-
when /5-2-stable/
26-
MAJOR = 5
27-
MINOR = 2
28-
when /stable/
29-
MAJOR = 6
30-
MINOR = 0
31-
when nil, false, ""
32-
MAJOR = 6
33-
MINOR = 0
34-
else
35-
match = /(\d+)(\.|-)(\d+)/.match(RAILS_VERSION)
36-
MAJOR, MINOR = match.captures.map(&:to_i).compact
19+
if RUBY_VERSION.to_f >= 2.3
20+
gem 'rubocop', '~> 0.80.1'
3721
end
3822

23+
gem 'capybara'
24+
25+
MAJOR =
26+
case RAILS_VERSION
27+
when /5-2-stable/
28+
5
29+
when /main/, /stable/, nil, false, ''
30+
6
31+
else
32+
/(\d+)[\.|-]\d+/.match(RAILS_VERSION).captures.first.to_i
33+
end
34+
3935
if MAJOR >= 6
40-
gem 'selenium-webdriver', '~> 3.5', require: false
36+
# Rails 6.0 specify '~> 1.4' directly in the adapter.
37+
# This is to prevent breakages when `sqlite3` 1.5.x is out.
4138
gem 'sqlite3', '~> 1.4', platforms: [:ruby]
4239
else
40+
# Rails 5.0 specify '~> 1.3.6', 5.1 and 5.2 - "~> 1.3", ">= 1.3.6" directly in the adapter.
4341
gem 'sqlite3', '~> 1.3.6', platforms: [:ruby]
4442
end
4543

46-
gem 'ffi', '~> 1.9.25'
47-
48-
gem 'rake', '~> 12'
49-
50-
gem 'mime-types', "~> 3"
51-
52-
if RUBY_VERSION.to_f < 2.3
53-
gem 'capybara', '~> 3.1.0'
54-
elsif RUBY_VERSION.to_f < 2.4
55-
gem 'capybara', '< 3.16'
56-
elsif RUBY_VERSION.to_f < 2.5
57-
gem 'capybara', '< 3.33'
58-
else
59-
gem 'capybara', '>= 2.13', '< 4.0', require: false
60-
end
61-
62-
if MAJOR < 6
63-
gem 'nokogiri', '1.9.1'
64-
else
65-
gem 'nokogiri', '>= 1.10.8'
66-
end
67-
68-
gem "rubyzip", '~> 1.2'
69-
70-
if RUBY_VERSION.to_f >= 2.3
71-
gem 'rubocop', '~> 0.80.1'
72-
end
73-
7444
custom_gemfile = File.expand_path('Gemfile-custom', __dir__)
7545
eval_gemfile custom_gemfile if File.exist?(custom_gemfile)
7646

Gemfile-rails-dependencies

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ when /main/
1414
gem 'sprockets-rails', :git => 'https://github.com/rails/sprockets-rails.git', :branch => 'master'
1515
gem 'puma', "3.12.1"
1616
gem 'activerecord-jdbcsqlite3-adapter', git: 'https://github.com/jruby/activerecord-jdbc-adapter', platforms: [:jruby]
17+
gem 'selenium-webdriver', require: false
1718
when /stable$/
1819
gem_list = %w[rails railties actionmailer actionpack activerecord activesupport activejob actionview]
1920
gem 'puma', "3.12.1" if version > '5-0-stable'
2021
gem 'activerecord-jdbcsqlite3-adapter', git: 'https://github.com/jruby/activerecord-jdbc-adapter', platforms: [:jruby]
21-
gem "sprockets", '~> 3.0' if RUBY_VERSION < '2.5'
2222

2323
gem_list.each do |rails_gem|
2424
gem rails_gem, :git => "https://github.com/rails/rails.git", :branch => version
@@ -27,14 +27,13 @@ when nil, false, ""
2727
gem "rails", "~> 6.0.0"
2828
gem "puma"
2929
gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
30+
gem 'selenium-webdriver', require: false
3031
else
3132
gem "rails", version
3233
gem "sprockets", '~> 3.0' if RUBY_VERSION < '2.5'
3334
gem "puma" if version >= '5-1-stable'
34-
35-
if version.gsub(/[^\d\.]/,'').to_f >= 6.0
36-
gem "activerecord-jdbcsqlite3-adapter", "~> 60.0.rc1", platforms: [:jruby]
37-
else
38-
gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
39-
end
35+
gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
36+
gem 'selenium-webdriver', require: false if version >= '5'
4037
end
38+
39+
gem 'jruby-openssl', platforms: [:jruby]

example_app_generator/generate_app.rb

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,54 +21,37 @@
2121
gsub_file 'Gemfile', /^.*\bgem 'rails.*$/, ''
2222
gsub_file "Gemfile", /.*web-console.*/, ''
2323
gsub_file "Gemfile", /.*debugger.*/, ''
24-
gsub_file "Gemfile", /.*byebug.*/, "gem 'byebug', '~> 9.0.6'"
25-
gsub_file "Gemfile", /.*puma.*/, ""
26-
gsub_file "Gemfile", /.*gem..sqlite3.*/, "gem 'sqlite3', '~> 1.3.6'"
27-
gsub_file "Gemfile", /.*bootsnap.*/, ""
28-
29-
if Rails::VERSION::STRING >= '5.0.0'
30-
append_to_file('Gemfile', "gem 'rails-controller-testing'\n")
31-
end
24+
gsub_file "Gemfile", /.*puma.*/, ''
25+
gsub_file "Gemfile", /.*bootsnap.*/, ''
3226

3327
if Rails::VERSION::STRING >= '6'
28+
# Rails 6.0 specify '~> 1.4' directly in the adapter.
29+
# This is to prevent breakages when `sqlite3` 1.5.x is out.
3430
gsub_file "Gemfile", /.*gem..sqlite3.*/, "gem 'sqlite3', '~> 1.4'"
35-
gsub_file "Gemfile", /.*rails-controller-testing.*/, "gem 'rails-controller-testing', git: 'https://github.com/rails/rails-controller-testing'"
31+
else
32+
# Rails 5.0 specify '~> 1.3.6', 5.1 and 5.2 - "~> 1.3", ">= 1.3.6" directly in the adapter.
33+
gsub_file "Gemfile", /.*gem..sqlite3.*/, "gem 'sqlite3', '~> 1.3.6'"
3634
end
3735

38-
if RUBY_VERSION < "2.3.0"
39-
gsub_file "Gemfile", /.*childprocess.*/, "gem 'childprocess', '< 2.0.0'"
40-
gsub_file "Gemfile", /.*i18n.*/, "gem 'i18n', '< 1.5.2'"
41-
gsub_file "Gemfile", /.*nio4r.*/, "gem 'nio4r', '< 2.4.0'"
42-
gsub_file "Gemfile", /.*public_suffix.*/, "gem 'public_suffix', '< 4.0.0'"
43-
gsub_file "Gemfile", /.*rack.*/, "gem 'rack', '< 2.2.0', '!= 2.1.0'"
44-
gsub_file "Gemfile", /.*xpath.*/, "gem 'xpath', '< 3.2.0'"
36+
append_to_file 'Gemfile', "gem 'rails-controller-testing'\n"
37+
38+
if Rails::VERSION::STRING >= '6'
39+
gsub_file "Gemfile", /.*rails-controller-testing.*/, "gem 'rails-controller-testing', git: 'https://github.com/rails/rails-controller-testing'"
4540
end
4641

4742
if Rails::VERSION::STRING >= "5.1.0"
48-
if RUBY_VERSION < "2.3"
49-
gsub_file "Gemfile", /.*capybara.*/, "gem 'capybara', '~> 3.1.0'"
50-
elsif RUBY_VERSION < "2.4"
51-
gsub_file "Gemfile", /.*capybara.*/, "gem 'capybara', '~> 3.15.0'"
52-
elsif RUBY_VERSION < "2.5"
53-
gsub_file "Gemfile", /.*capybara.*/, "gem 'capybara', '~> 3.32.0'"
54-
end
55-
if Rails::VERSION::STRING >= "5.2.0"
56-
gsub_file "Gemfile", /.*chromedriver-helper.*/, "gem 'webdrivers', '< 4.0.0'"
57-
else
58-
gsub_file "Gemfile", /.*chromedriver-helper.*/, "gem 'webdrivers'"
59-
end
43+
# webdrivers 4 up until 4.3.0 don't specify `required_ruby_version`, but contain
44+
# Ruby 2.2-incompatible syntax (safe navigation).
45+
# That basically means we use pre-4.0 for Ruby 2.2, and 4.3+ for newer Rubies.
46+
gsub_file "Gemfile", /.*chromedriver-helper.*/, "gem 'webdrivers', '!= 4.0.0', '!= 4.0.1', '!= 4.1.0', '!= 4.1.1', '!= 4.1.2', '!= 4.1.3', '!= 4.2.0'"
6047
end
6148

6249
if Rails::VERSION::STRING >= '5.2.0' && Rails::VERSION::STRING < '6'
6350
copy_file sqlite_initializer, 'config/initializers/sqlite3_fix.rb'
6451
end
6552

66-
# Nokogiri version is pinned in rspec-rails' Gemfile since it tend to cause installation problems
67-
# on Travis CI, so we pin nokogiri in this example app also.
68-
if RUBY_ENGINE != "jruby"
69-
append_to_file 'Gemfile', "gem 'nokogiri', '#{Nokogiri::VERSION}'\n"
70-
else
71-
gsub_file "Gemfile", /.*jdbc.*/, ""
53+
if RUBY_ENGINE == "jruby"
54+
gsub_file "Gemfile", /.*jdbc.*/, ''
7255
end
7356

7457
# Use our version of RSpec and Rails

0 commit comments

Comments
 (0)