class method
Gem::Platform.new
() -> ::Gem::Platform
new(arch)
lib/rubygems/platform.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/rubygems/platform.rb, line 75
def initialize(arch)
case arch
when Array then
@cpu, @os, @version = arch
when String then
cpu, os = arch.sub(/-+$/, "").split("-", 2)
@cpu = if cpu&.match?(/i\d86/)
"x86"
else
cpu
end
if os.nil?
@cpu = nil
os = cpu
end # legacy jruby
@os, @version = case os
when /aix-?(\d+)?/ then ["aix", $1]
when /cygwin/ then ["cygwin", nil]
when /darwin-?(\d+)?/ then ["darwin", $1]
when "macruby" then ["macruby", nil]
when /^macruby-?(\d+(?:\.\d+)*)?/ then ["macruby", $1]
when /freebsd-?(\d+)?/ then ["freebsd", $1]
when "java", "jruby" then ["java", nil]
when /^java-?(\d+(?:\.\d+)*)?/ then ["java", $1]
when /^dalvik-?(\d+)?$/ then ["dalvik", $1]
when /^dotnet$/ then ["dotnet", nil]
when /^dotnet-?(\d+(?:\.\d+)*)?/ then ["dotnet", $1]
when /linux-?(\w+)?/ then ["linux", $1]
when /mingw32/ then ["mingw32", nil]
when /mingw-?(\w+)?/ then ["mingw", $1]
when /(mswin\d+)(?:[_-](\d+))?/ then
os = $1
version = $2
@cpu = "x86" if @cpu.nil? && os.end_with?("32")
[os, version]
when /netbsdelf/ then ["netbsdelf", nil]
when /openbsd-?(\d+\.\d+)?/ then ["openbsd", $1]
when /solaris-?(\d+\.\d+)?/ then ["solaris", $1]
when /wasi/ then ["wasi", nil]
# test
when /^(\w+_platform)-?(\d+)?/ then [$1, $2]
else ["unknown", nil]
end
when Gem::Platform then
@cpu = arch.cpu
@os = arch.os
@version = arch.version
else
raise ArgumentError, "invalid argument #{arch.inspect}"
end
end
No documentation available
See also
.match_spec?
.os_match
.match_platforms?
.platform_specificity_match
also in
4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0