summaryrefslogtreecommitdiff
path: root/lib/bundler/gem_helpers.rb
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2016-08-03 18:43:24 -0500
committerSamuel Giddins <segiddins@segiddins.me>2016-08-25 11:16:40 -0500
commita7163e32c3045b25c7bf2b90329971f3788da358 (patch)
tree806d10f9ec7df71df758f13c611fb0a269684157 /lib/bundler/gem_helpers.rb
parent8513ed1481dde5b47eead96dd0a1cfe3d77c4c84 (diff)
downloadbundler-a7163e32c3045b25c7bf2b90329971f3788da358.tar.gz
Resolve for specific platforms
Diffstat (limited to 'lib/bundler/gem_helpers.rb')
-rw-r--r--lib/bundler/gem_helpers.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/bundler/gem_helpers.rb b/lib/bundler/gem_helpers.rb
index 5c824ffefc..03c1f33fe2 100644
--- a/lib/bundler/gem_helpers.rb
+++ b/lib/bundler/gem_helpers.rb
@@ -28,5 +28,38 @@ module Bundler
generic(Gem::Platform.local)
end
module_function :generic_local_platform
+
+ def platform_specificity_match(spec_platform, user_platform)
+ spec_platform = Gem::Platform.new(spec_platform)
+ return [-1, -1, -1] if spec_platform == user_platform
+ return [5, 5, 5] if spec_platform.nil? || spec_platform == Gem::Platform::RUBY || user_platform == Gem::Platform::RUBY
+
+ [
+ if spec_platform.os == user_platform.os
+ 0
+ else
+ 1
+ end,
+
+ if spec_platform.cpu == user_platform.cpu
+ 0
+ elsif spec_platform.cpu == "arm" && user_platform.cpu.to_s.start_with?("arm")
+ 0
+ elsif spec_platform.cpu.nil? || spec_platform.cpu == "universal"
+ 1
+ else
+ 2
+ end,
+
+ if spec_platform.version == user_platform.version
+ 0
+ elsif spec_platform.version.nil?
+ 1
+ else
+ 2
+ end,
+ ]
+ end
+ module_function :platform_specificity_match
end
end