diff --git a/History.txt b/History.txt index 767c97319e03..ea8dee34d317 100644 --- a/History.txt +++ b/History.txt @@ -35,6 +35,8 @@ Bug fixes: Aaron Patterson. * Commands using the rubygems.org API no longer try to sign-in when a non-rubygems API key has been chosen. Bug #826 by Ben Sedat. +* Gem dependency API supports multiple platforms for #platform and #platforms + now. Bug #821 by johnny5-. * The environment command now shows the system configuration directory where the all-users gemrc lives. Bug #827 by Ben Langfeld. * Improved speed of conflict checking when activating gems. Pull request #843 diff --git a/lib/rubygems/request_set/gem_dependency_api.rb b/lib/rubygems/request_set/gem_dependency_api.rb index efce979177b3..a978acf6675a 100644 --- a/lib/rubygems/request_set/gem_dependency_api.rb +++ b/lib/rubygems/request_set/gem_dependency_api.rb @@ -136,7 +136,7 @@ def initialize set, path @path = path @current_groups = nil - @current_platform = nil + @current_platforms = nil @current_repository = nil @default_sources = true @git_set = @set.git_set @@ -315,7 +315,7 @@ def gem_path name, options # :nodoc: def gem_platforms options # :nodoc: platform_names = Array(options.delete :platforms) - platform_names << @current_platform if @current_platform + platform_names.concat @current_platforms if @current_platforms return true if platform_names.empty? @@ -442,13 +442,13 @@ def pin_gem_source name, type = :default, source = nil # # Block form for restricting gems to a particular platform. - def platform what - @current_platform = what + def platform *platforms + @current_platforms = platforms yield ensure - @current_platform = nil + @current_platforms = nil end ## diff --git a/test/rubygems/test_gem_request_set_gem_dependency_api.rb b/test/rubygems/test_gem_request_set_gem_dependency_api.rb index cadaf7688390..3de68a7e5107 100644 --- a/test/rubygems/test_gem_request_set_gem_dependency_api.rb +++ b/test/rubygems/test_gem_request_set_gem_dependency_api.rb @@ -555,6 +555,28 @@ def test_platform_mswin Gem.win_platform = win_platform end + def test_platform_multiple + win_platform, Gem.win_platform = Gem.win_platform?, false + + with_engine_version 'ruby', '1.8.7' do + @gda.platform :mri_19, :mri_20 do + @gda.gem 'a' + end + end + + assert_empty @set.dependencies + + with_engine_version 'ruby', '2.0.0' do + @gda.platform :mri_19, :mri_20 do + @gda.gem 'a' + end + end + + refute_empty @set.dependencies + ensure + Gem.win_platform = win_platform + end + def test_platform_ruby win_platform, Gem.win_platform = Gem.win_platform?, false