Method: Gem::Platform#initialize
- Defined in:
- lib/rubygems/platform.rb
#initialize(arch) ⇒ Platform
Returns a new instance of Platform.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File '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 |