diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2016-12-27 11:09:43 -0600 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2016-12-27 11:09:43 -0600 |
commit | a962d77f1953fee8553275560a89c40c2777489e (patch) | |
tree | 371cbbddc0a5b2944c6c67e09ea0b0d74573762f | |
parent | e176163a950a7f36b87e93355d2750d32dc13488 (diff) | |
download | bundler-a962d77f1953fee8553275560a89c40c2777489e.tar.gz |
[MatchPlatform] Allow matching two platforms as a functionseg-rg-1.3.6
-rw-r--r-- | lib/bundler/definition.rb | 6 | ||||
-rw-r--r-- | lib/bundler/match_platform.rb | 16 |
2 files changed, 13 insertions, 9 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 6e3b655706..1c0b0de6b0 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -499,14 +499,10 @@ module Bundler end end - # TODO: refactor this so that `match_platform` can be called with two platforms - DummyPlatform = Struct.new(:platform) - class DummyPlatform; include MatchPlatform; end def validate_platforms! return if @platforms.any? do |bundle_platform| - bundle_platform = DummyPlatform.new(bundle_platform) Bundler.rubygems.platforms.any? do |local_platform| - bundle_platform.match_platform(local_platform) + MatchPlatform.platforms_match?(bundle_platform, local_platform) end end diff --git a/lib/bundler/match_platform.rb b/lib/bundler/match_platform.rb index 0a4e4c7e3a..050cd0efd3 100644 --- a/lib/bundler/match_platform.rb +++ b/lib/bundler/match_platform.rb @@ -6,10 +6,18 @@ module Bundler include GemHelpers def match_platform(p) - Gem::Platform::RUBY == platform || - platform.nil? || p == platform || - generic(Gem::Platform.new(platform)) === p || - Gem::Platform.new(platform) === p + MatchPlatform.platforms_match?(platform, p) + end + + def self.platforms_match?(gemspec_platform, local_platform) + return true if gemspec_platform.nil? + return true if Gem::Platform::RUBY == gemspec_platform + return true if local_platform == gemspec_platform + gemspec_platform = Gem::Platform.new(gemspec_platform) + return true if GemHelpers.generic(gemspec_platform) === local_platform + return true if gemspec_platform === local_platform + + false end end end |