Skip to content

Commit dc7c665

Browse files
Edouard-chinhsbt
authored andcommitted
[rubygems/rubygems] Consolidated the Ruby version list:
- We keep 2 list of supported ruby versions and each time a new ruby version is released we need to maintain both list. Forgetting to update one would prevent users from adding gem for a specific plaftorm (i.e. ruby/rubygems@7cd19d824d17 and ruby/rubygems@5462322f8f0c). Extracted the list from the Dependency class and moved it to the CurrentRuby class (which I believe was originally added for that reason). ruby/rubygems@a91edd6c1f
1 parent 57fec1e commit dc7c665

File tree

2 files changed

+10
-28
lines changed

2 files changed

+10
-28
lines changed

lib/bundler/current_ruby.rb

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,9 @@ def self.current_ruby
99
end
1010

1111
class CurrentRuby
12-
KNOWN_MINOR_VERSIONS = %w[
13-
1.8
14-
1.9
15-
2.0
16-
2.1
17-
2.2
18-
2.3
19-
2.4
20-
2.5
21-
2.6
22-
2.7
23-
3.0
24-
3.1
25-
3.2
26-
3.3
27-
3.4
28-
3.5
29-
].freeze
30-
31-
KNOWN_MAJOR_VERSIONS = KNOWN_MINOR_VERSIONS.map {|v| v.split(".", 2).first }.uniq.freeze
12+
ALL_RUBY_VERSIONS = (18..27).to_a.concat((30..35).to_a).freeze
13+
KNOWN_MINOR_VERSIONS = ALL_RUBY_VERSIONS.map {|v| v.digits.reverse.join(".") }.freeze
14+
KNOWN_MAJOR_VERSIONS = ALL_RUBY_VERSIONS.map {|v| v.digits.last.to_s }.uniq.freeze
3215

3316
KNOWN_PLATFORMS = %w[
3417
jruby

lib/bundler/dependency.rb

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,18 @@ class Dependency < Gem::Dependency
99
attr_reader :autorequire
1010
attr_reader :groups, :platforms, :gemfile, :path, :git, :github, :branch, :ref, :glob
1111

12-
ALL_RUBY_VERSIONS = (18..27).to_a.concat((30..35).to_a).freeze
1312
PLATFORM_MAP = {
14-
ruby: [Gem::Platform::RUBY, ALL_RUBY_VERSIONS],
15-
mri: [Gem::Platform::RUBY, ALL_RUBY_VERSIONS],
13+
ruby: [Gem::Platform::RUBY, CurrentRuby::ALL_RUBY_VERSIONS],
14+
mri: [Gem::Platform::RUBY, CurrentRuby::ALL_RUBY_VERSIONS],
1615
rbx: [Gem::Platform::RUBY],
1716
truffleruby: [Gem::Platform::RUBY],
1817
jruby: [Gem::Platform::JAVA, [18, 19]],
19-
windows: [Gem::Platform::WINDOWS, ALL_RUBY_VERSIONS],
18+
windows: [Gem::Platform::WINDOWS, CurrentRuby::ALL_RUBY_VERSIONS],
2019
# deprecated
21-
mswin: [Gem::Platform::MSWIN, ALL_RUBY_VERSIONS],
22-
mswin64: [Gem::Platform::MSWIN64, ALL_RUBY_VERSIONS - [18]],
23-
mingw: [Gem::Platform::MINGW, ALL_RUBY_VERSIONS],
24-
x64_mingw: [Gem::Platform::X64_MINGW, ALL_RUBY_VERSIONS - [18, 19]],
20+
mswin: [Gem::Platform::MSWIN, CurrentRuby::ALL_RUBY_VERSIONS],
21+
mswin64: [Gem::Platform::MSWIN64, CurrentRuby::ALL_RUBY_VERSIONS - [18]],
22+
mingw: [Gem::Platform::MINGW, CurrentRuby::ALL_RUBY_VERSIONS],
23+
x64_mingw: [Gem::Platform::X64_MINGW, CurrentRuby::ALL_RUBY_VERSIONS - [18, 19]],
2524
}.each_with_object({}) do |(platform, spec), hash|
2625
hash[platform] = spec[0]
2726
spec[1]&.each {|version| hash[:"#{platform}_#{version}"] = spec[0] }

0 commit comments

Comments
 (0)