Skip to content

Commit ed6a963

Browse files
committed
Remove Ruby version constraint workarounds
1 parent cc30ae4 commit ed6a963

File tree

3 files changed

+30
-135
lines changed

3 files changed

+30
-135
lines changed

Gemfile

Lines changed: 7 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -18,42 +18,6 @@ group :documentation do
1818
end
1919
end
2020

21-
platforms :jruby do
22-
gem "jruby-openssl"
23-
end
24-
25-
gem 'sqlite3', '~> 1.3.6'
26-
27-
if RUBY_VERSION >= '2.4.0'
28-
gem 'json', '>= 2.0.2'
29-
end
30-
31-
if RUBY_VERSION < '1.9'
32-
gem 'ffi', '< 1.9.19' # ffi dropped Ruby 1.8 support in 1.9.19
33-
elsif RUBY_VERSION < '2.0'
34-
gem 'ffi', '< 1.11.0' # ffi dropped Ruby 2.0 support in 1.11.0
35-
elsif RUBY_VERSION < '2.3'
36-
gem 'ffi', '< 1.13.0'
37-
end
38-
39-
if RUBY_VERSION >= '2.0.0'
40-
gem 'rake', '>= 10.0.0'
41-
elsif RUBY_VERSION >= '1.9.3'
42-
gem 'rake', '< 12.0.0' # rake 12 requires Ruby 2.0.0 or later
43-
else
44-
gem 'rake', '< 11.0.0' # rake 11 requires Ruby 1.9.3 or later
45-
end
46-
47-
# Version 3 of mime-types 3 requires Ruby 2.0
48-
if RUBY_VERSION < '2.0.0'
49-
gem 'mime-types', '< 3'
50-
end
51-
52-
# Version 5.12 of minitest requires Ruby 2.4
53-
if RUBY_VERSION < '2.4.0'
54-
gem 'minitest', '< 5.12.0'
55-
end
56-
5721
# Capybara versions that support RSpec 3 only support RUBY_VERSION >= 1.9.3
5822
if RUBY_VERSION >= '1.9.3'
5923
if /5(\.|-)[1-9]\d*/ === RAILS_VERSION || "master" == RAILS_VERSION
@@ -63,28 +27,14 @@ if RUBY_VERSION >= '1.9.3'
6327
end
6428
end
6529

66-
# Rack::Cache 1.3.0 requires Ruby >= 2.0.0
67-
gem 'rack-cache', '< 1.3.0' if RUBY_VERSION < '2.0.0'
68-
69-
if RUBY_VERSION < '1.9.2'
70-
gem 'nokogiri', '~> 1.5.0'
71-
elsif RUBY_VERSION < '1.9.3'
72-
gem 'nokogiri', '1.5.2'
73-
elsif RUBY_VERSION < '2.1.0'
74-
gem 'nokogiri', '1.6.8.1'
75-
elsif RUBY_VERSION < '2.3.0'
76-
gem 'nokogiri', '1.8.5'
77-
else
78-
gem 'nokogiri', '~> 1.10'
79-
end
30+
# Minitest version 5.12.0 rely on Ruby 2.4 features and doesn't specify a Ruby version constraint
31+
gem 'minitest', '!= 5.12.0'
8032

81-
if RUBY_VERSION <= '1.8.7'
82-
# cucumber and gherkin require rubyzip as a runtime dependency on 1.8.7
83-
# Only < 1.0 supports 1.8.7
84-
gem 'rubyzip', '< 1.0'
85-
elsif RUBY_VERSION < '2.4'
86-
gem 'rubyzip', '>= 1.2.2', '< 2.0.0'
87-
end
33+
gem 'mime-types'
34+
gem 'nokogiri'
35+
gem 'rake'
36+
gem 'rack-cache'
37+
gem 'rubyzip'
8838

8939
if RUBY_VERSION >= '2.0.0' && RUBY_VERSION < '2.2.0'
9040
# our current rubocop version doesn't support the json version required by Ruby 2.4

Gemfile-rails-dependencies

Lines changed: 18 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ when /master/
1414
gem 'i18n', :git => 'https://github.com/svenfuchs/i18n.git', :branch => 'master'
1515
gem 'sprockets', :git => 'https://github.com/rails/sprockets.git', :branch => 'master'
1616
gem 'sprockets-rails', :git => 'https://github.com/rails/sprockets-rails.git', :branch => 'master'
17-
if RUBY_VERSION >= "2.2"
18-
gem 'puma', :git => 'https://github.com/puma/puma', :branch => 'master'
19-
end
17+
gem 'puma', :git => 'https://github.com/puma/puma', :branch => 'master'
18+
# sqlite3 is an optional, unspecified, dependency and Rails 6.0 only supports `~> 1.4`
19+
gem 'sqlite3', '~> 1.4', :platforms => [:ruby]
2020
when /stable$/
2121
gem_list = %w[rails railties actionmailer actionpack activerecord activesupport]
2222
gem_list << 'activejob' if version > '4-1-stable'
@@ -26,65 +26,31 @@ when /stable$/
2626
gem rails_gem, :git => "https://github.com/rails/rails.git", :branch => version
2727
end
2828

29-
gem 'puma' if RUBY_VERSION >= '2.2' && version > '5-0-stable'
30-
31-
gem "sprockets", '~> 3.0' if RUBY_VERSION < '2.5' && version >= '4-0-stable'
29+
gem 'puma' if version > '5-0-stable'
30+
# Similarly, Rails 5.0 only supports '~> 1.3.6'. Rails 5.1-5.2 support '~> 1.3', '>= 1.3.6'
31+
gem 'sqlite3', '~> 1.3.6', :platforms => [:ruby]
3232
when nil, false, ""
33-
if RUBY_VERSION < '1.9.3'
34-
# Rails 4+ requires 1.9.3+, so on earlier versions default to the last 3.x release.
35-
gem "rails", "~> 3.2.17"
36-
elsif RUBY_VERSION < '2.2.0'
37-
# Rails 5+ requires 2.2+, so on earlier versions default to the last 4.x release.
38-
gem "rails", "~> 4.2.0"
39-
else
40-
gem "rails", "~> 5.0.0"
41-
end
33+
gem "rails"
34+
gem 'sqlite3', '~> 1.4', :platforms => [:ruby]
4235
else
4336
gem "rails", version
4437

4538
major_minor_version = version.gsub(/[^\d\.]/,'').to_f
4639

47-
if major_minor_version >= 5.1 && RUBY_VERSION >= "2.2"
48-
gem "puma"
49-
end
40+
gem "puma" if major_minor_version >= 5.1
5041

51-
gem "sprockets", '~> 3.0' if RUBY_VERSION < '2.5' && major_minor_version >= 4.0
42+
gem 'activerecord-jdbcsqlite3-adapter', :platforms => [:jruby]
5243

53-
if major_minor_version >= 6.0
54-
gem "activerecord-jdbcsqlite3-adapter", "~> 60.0.rc1", :platforms => [:jruby]
44+
if major_minor_version >= 6
45+
# sqlite3 is an optional, unspecified, dependency and Rails 6.0 only supports `~> 1.4`
46+
gem 'sqlite3', '~> 1.4', :platforms => [:ruby]
5547
else
56-
gem 'activerecord-jdbcsqlite3-adapter', :platforms => [:jruby]
48+
# Similarly, Rails 5.0 only supports '~> 1.3.6'. Rails 5.1-5.2 support '~> 1.3', '>= 1.3.6'
49+
gem 'sqlite3', '~> 1.3.6', :platforms => [:ruby]
5750
end
5851
end
5952

60-
gem "childprocess", '< 2.0.0' if RUBY_VERSION < '2.3'
61-
62-
if RUBY_VERSION < '1.9.3'
63-
gem "i18n", '< 0.7.0'
64-
elsif RUBY_VERSION < '2.3.0'
65-
gem "i18n", '< 1.5.2'
66-
end
67-
68-
gem "nio4r", '< 2.4.0' if RUBY_VERSION < '2.3'
69-
70-
if RUBY_VERSION < '1.9.3'
71-
gem "public_suffix", '< 1.4.0'
72-
elsif RUBY_VERSION < '2.0'
73-
gem "public_suffix", '< 2.0.0'
74-
elsif RUBY_VERSION < '2.1'
75-
gem "public_suffix", '< 3.0.0'
76-
elsif RUBY_VERSION < '2.3'
77-
gem "public_suffix", '< 4.0.0'
78-
end
79-
80-
# rack 2.1.0 introduces a deprecation warning that rails is triggering,
81-
# but in later versions this warning is removed.
82-
if RUBY_VERSION < '2.2'
83-
gem "rack", '< 2.0.0', '!= 2.1.0'
84-
elsif RUBY_VERSION < '2.3'
85-
gem "rack", '< 2.2.0', '!= 2.1.0'
86-
end
87-
88-
gem "test-unit" if RUBY_VERSION >= '2.2.0' && version =~ /3[.-]2[.-]/
53+
# `test-unit` was removed from the core in Ruby 2.2
54+
gem 'test-unit' if RUBY_VERSION >= '2.2.0' && version =~ /3[.-]2[.-]/
8955

90-
gem "xpath", '< 3.2.0' if RUBY_VERSION < '2.3'
56+
gem 'jruby-openssl', :platforms => [:jruby]

example_app_generator/generate_app.rb

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,18 @@
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'"
2524
gsub_file "Gemfile", /.*puma.*/, ""
26-
gsub_file "Gemfile", /.*sqlite3.*/, "gem 'sqlite3', '~> 1.3.6'"
27-
if RUBY_VERSION < '2.2.2'
28-
gsub_file "Gemfile", /.*rdoc.*/, "gem 'rdoc', '< 6'"
29-
end
25+
gsub_file "Gemfile", /.*sqlite3.*/, ""
3026

3127
if Rails::VERSION::STRING >= '5.0.0'
3228
append_to_file('Gemfile', "gem 'rails-controller-testing', :git => 'https://github.com/rails/rails-controller-testing'\n")
3329
end
3430

3531
if Rails::VERSION::STRING >= "5.1.0"
36-
if Rails::VERSION::STRING >= "5.2.0" && RUBY_VERSION < '2.3.0'
37-
gsub_file "Gemfile", /.*chromedriver-helper.*/, "gem 'webdrivers', '< 4.0.0'"
38-
else
39-
gsub_file "Gemfile", /.*chromedriver-helper.*/, "gem 'webdrivers'"
40-
end
32+
# webdrivers 4 up until 4.3.0 don't specify `required_ruby_version`, but contain
33+
# Ruby 2.2-incompatible syntax (safe navigation).
34+
# That basically means we use pre-4.0 for Ruby 2.2, and 4.3+ for newer Rubies.
35+
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'"
4136
end
4237

4338
if Rails::VERSION::STRING >= '5.2.0' && Rails::VERSION::STRING < '6'
@@ -50,22 +45,6 @@
5045

5146
# Use our version of RSpec and Rails
5247
append_to_file 'Gemfile', <<-EOT.gsub(/^ +\|/, '')
53-
|# Rack::Cache 1.3.0 requires Ruby >= 2.0.0
54-
|gem 'rack-cache', '< 1.3.0' if RUBY_VERSION < '2.0.0'
55-
|
56-
|if RUBY_VERSION >= '2.0.0'
57-
| gem 'rake', '>= 10.0.0'
58-
|elsif RUBY_VERSION >= '1.9.3'
59-
| gem 'rake', '< 12.0.0' # rake 12 requires Ruby 2.0.0 or later
60-
|else
61-
| gem 'rake', '< 11.0.0' # rake 11 requires Ruby 1.9.3 or later
62-
|end
63-
|
64-
|# Version 3 of mime-types 3 requires Ruby 2.0
65-
|if RUBY_VERSION < '2.0.0'
66-
| gem 'mime-types', '< 3'
67-
|end
68-
|
6948
|gem 'rspec-rails',
7049
| :path => '#{rspec_rails_repo_path}',
7150
| :groups => [:development, :test]

0 commit comments

Comments
 (0)