diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2020-12-08 16:33:39 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2020-12-08 17:30:02 +0900 |
commit | 4aca77edde91f826aa243e268bf1ef5214530583 (patch) | |
tree | ef0cf1a95fcced00ca5fa40f3412c567bf95d705 /lib/rubygems/platform.rb | |
parent | 6a6a24df9b72750d12f9b15192bdb7517e668efb (diff) | |
download | ruby-4aca77edde91f826aa243e268bf1ef5214530583.tar.gz |
Merge prepare version of RubyGems 3.2.0
Diffstat (limited to 'lib/rubygems/platform.rb')
-rw-r--r-- | lib/rubygems/platform.rb | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb index 34306fcf83..a500fd24c8 100644 --- a/lib/rubygems/platform.rb +++ b/lib/rubygems/platform.rb @@ -9,11 +9,7 @@ require "rubygems/deprecate" class Gem::Platform @local = nil - attr_accessor :cpu - - attr_accessor :os - - attr_accessor :version + attr_accessor :cpu, :os, :version def self.local arch = RbConfig::CONFIG['arch'] @@ -22,18 +18,33 @@ class Gem::Platform end def self.match(platform) - Gem.platforms.any? do |local_platform| + match_platforms?(platform, Gem.platforms) + end + + def self.match_platforms?(platform, platforms) + platforms.any? do |local_platform| platform.nil? or local_platform == platform or (local_platform != Gem::Platform::RUBY and local_platform =~ platform) end end + private_class_method :match_platforms? + + def self.match_spec?(spec) + match_gem?(spec.platform, spec.name) + end + + def self.match_gem?(platform, gem_name) + # Note: this method might be redefined by Ruby implementations to + # customize behavior per RUBY_ENGINE, gem_name or other criteria. + match_platforms?(platform, Gem.platforms) + end def self.installable?(spec) if spec.respond_to? :installable_platform? spec.installable_platform? else - match spec.platform + match_spec? spec end end |