lib/bundler/rubygems_ext.rb in bundler-2.2.22 vs lib/bundler/rubygems_ext.rb in bundler-2.2.23

- old
+ new

@@ -172,23 +172,39 @@ prepend CorrectHashForLambdaOperator end end + require "rubygems/platform" + class Platform JAVA = Gem::Platform.new("java") unless defined?(JAVA) MSWIN = Gem::Platform.new("mswin32") unless defined?(MSWIN) MSWIN64 = Gem::Platform.new("mswin64") unless defined?(MSWIN64) MINGW = Gem::Platform.new("x86-mingw32") unless defined?(MINGW) X64_MINGW = Gem::Platform.new("x64-mingw32") unless defined?(X64_MINGW) + end - undef_method :hash if method_defined? :hash - def hash - @cpu.hash ^ @os.hash ^ @version.hash - end + Platform.singleton_class.module_eval do + unless Platform.singleton_methods.include?(:match_spec?) + def match_spec?(spec) + match_gem?(spec.platform, spec.name) + end - undef_method :eql? if method_defined? :eql? - alias_method :eql?, :== + def match_gem?(platform, gem_name) + match_platforms?(platform, Gem.platforms) + end + + private + + def match_platforms?(platform, platforms) + platforms.any? do |local_platform| + platform.nil? || + local_platform == platform || + (local_platform != Gem::Platform::RUBY && local_platform =~ platform) + end + end + end end require "rubygems/util" Util.singleton_class.module_eval do