Skip to content

Commit

Permalink
move arch formatting logic from Gem::Platform.local to Gem::Platform.…
Browse files Browse the repository at this point in the history
…initialize
  • Loading branch information
gustavothecoder committed May 24, 2023
1 parent 76ee89c commit 9284bda
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/rubygems/platform.rb
Expand Up @@ -14,7 +14,6 @@ class Gem::Platform

def self.local
arch = RbConfig::CONFIG["arch"]
arch = "#{arch}_60" if /mswin(?:32|64)$/.match?(arch)
@local ||= new(arch)
end

Expand Down Expand Up @@ -70,6 +69,7 @@ def initialize(arch)
when Array then
@cpu, @os, @version = arch
when String then # Update Bundler::Standalone#add_arch_formatter whenever this case is changed.
arch = "#{arch}_60" if /mswin(?:32|64)$/.match?(arch)
arch = arch.split "-"

if arch.length > 2 && arch.last !~ /\d+(\.\d+)?$/ # reassemble x86-linux-{libc}
Expand Down
10 changes: 5 additions & 5 deletions test/rubygems/test_gem_platform.rb
Expand Up @@ -123,17 +123,17 @@ def test_initialize
"i386-linux-gnu" => ["x86", "linux", "gnu"],
"i386-mingw32" => ["x86", "mingw32", nil],
"x64-mingw-ucrt" => ["x64", "mingw", "ucrt"],
"i386-mswin32" => ["x86", "mswin32", nil],
"i386-mswin32" => ["x86", "mswin32", "60"],
"i386-mswin32_80" => ["x86", "mswin32", "80"],
"i386-mswin32-80" => ["x86", "mswin32", "80"],
"x86-mswin32" => ["x86", "mswin32", nil],
"x86-mswin32" => ["x86", "mswin32", "60"],
"x86-mswin32_60" => ["x86", "mswin32", "60"],
"x86-mswin32-60" => ["x86", "mswin32", "60"],
"i386-netbsdelf" => ["x86", "netbsdelf", nil],
"i386-openbsd4.0" => ["x86", "openbsd", "4.0"],
"i386-solaris2.10" => ["x86", "solaris", "2.10"],
"i386-solaris2.8" => ["x86", "solaris", "2.8"],
"mswin32" => ["x86", "mswin32", nil],
"mswin32" => ["x86", "mswin32", "60"],
"x86_64-linux" => ["x86_64", "linux", nil],
"x86_64-linux-gnu" => ["x86_64", "linux", "gnu"],
"x86_64-linux-musl" => ["x86_64", "linux", "musl"],
Expand All @@ -155,7 +155,7 @@ def test_initialize
end

def test_initialize_command_line
expected = ["x86", "mswin32", nil]
expected = ["x86", "mswin32", "60"]

platform = Gem::Platform.new "i386-mswin32"

Expand All @@ -178,7 +178,7 @@ def test_initialize_mswin32_vc6
orig_ruby_so_name = RbConfig::CONFIG["RUBY_SO_NAME"]
RbConfig::CONFIG["RUBY_SO_NAME"] = "msvcrt-ruby18"

expected = ["x86", "mswin32", nil]
expected = ["x86", "mswin32", "60"]

platform = Gem::Platform.new "i386-mswin32"

Expand Down

0 comments on commit 9284bda

Please sign in to comment.