[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. https://github.com/rubygems/rubygems/commit/7cd19d824d17 and https://github.com/rubygems/rubygems/commit/5462322f8f0c).

  Extracted the list from the Dependency class and moved it to the
  CurrentRuby class (which I believe was originally added for that
  reason).

https://github.com/rubygems/rubygems/commit/a91edd6c1f
This commit is contained in:
Edouard CHIN 2025-01-23 15:45:48 +01:00 committed by Hiroshi SHIBATA
parent 57fec1e85f
commit dc7c665105
2 changed files with 10 additions and 28 deletions

View File

@ -9,26 +9,9 @@ module Bundler
end end
class CurrentRuby class CurrentRuby
KNOWN_MINOR_VERSIONS = %w[ ALL_RUBY_VERSIONS = (18..27).to_a.concat((30..35).to_a).freeze
1.8 KNOWN_MINOR_VERSIONS = ALL_RUBY_VERSIONS.map {|v| v.digits.reverse.join(".") }.freeze
1.9 KNOWN_MAJOR_VERSIONS = ALL_RUBY_VERSIONS.map {|v| v.digits.last.to_s }.uniq.freeze
2.0
2.1
2.2
2.3
2.4
2.5
2.6
2.7
3.0
3.1
3.2
3.3
3.4
3.5
].freeze
KNOWN_MAJOR_VERSIONS = KNOWN_MINOR_VERSIONS.map {|v| v.split(".", 2).first }.uniq.freeze
KNOWN_PLATFORMS = %w[ KNOWN_PLATFORMS = %w[
jruby jruby

View File

@ -9,19 +9,18 @@ module Bundler
attr_reader :autorequire attr_reader :autorequire
attr_reader :groups, :platforms, :gemfile, :path, :git, :github, :branch, :ref, :glob attr_reader :groups, :platforms, :gemfile, :path, :git, :github, :branch, :ref, :glob
ALL_RUBY_VERSIONS = (18..27).to_a.concat((30..35).to_a).freeze
PLATFORM_MAP = { PLATFORM_MAP = {
ruby: [Gem::Platform::RUBY, ALL_RUBY_VERSIONS], ruby: [Gem::Platform::RUBY, CurrentRuby::ALL_RUBY_VERSIONS],
mri: [Gem::Platform::RUBY, ALL_RUBY_VERSIONS], mri: [Gem::Platform::RUBY, CurrentRuby::ALL_RUBY_VERSIONS],
rbx: [Gem::Platform::RUBY], rbx: [Gem::Platform::RUBY],
truffleruby: [Gem::Platform::RUBY], truffleruby: [Gem::Platform::RUBY],
jruby: [Gem::Platform::JAVA, [18, 19]], jruby: [Gem::Platform::JAVA, [18, 19]],
windows: [Gem::Platform::WINDOWS, ALL_RUBY_VERSIONS], windows: [Gem::Platform::WINDOWS, CurrentRuby::ALL_RUBY_VERSIONS],
# deprecated # deprecated
mswin: [Gem::Platform::MSWIN, ALL_RUBY_VERSIONS], mswin: [Gem::Platform::MSWIN, CurrentRuby::ALL_RUBY_VERSIONS],
mswin64: [Gem::Platform::MSWIN64, ALL_RUBY_VERSIONS - [18]], mswin64: [Gem::Platform::MSWIN64, CurrentRuby::ALL_RUBY_VERSIONS - [18]],
mingw: [Gem::Platform::MINGW, ALL_RUBY_VERSIONS], mingw: [Gem::Platform::MINGW, CurrentRuby::ALL_RUBY_VERSIONS],
x64_mingw: [Gem::Platform::X64_MINGW, ALL_RUBY_VERSIONS - [18, 19]], x64_mingw: [Gem::Platform::X64_MINGW, CurrentRuby::ALL_RUBY_VERSIONS - [18, 19]],
}.each_with_object({}) do |(platform, spec), hash| }.each_with_object({}) do |(platform, spec), hash|
hash[platform] = spec[0] hash[platform] = spec[0]
spec[1]&.each {|version| hash[:"#{platform}_#{version}"] = spec[0] } spec[1]&.each {|version| hash[:"#{platform}_#{version}"] = spec[0] }