Skip to content

Commit

Permalink
Support multiple platforms in a gem.deps.rb
Browse files Browse the repository at this point in the history
Bundler supports multiple platforms but this was not implemented for
gem.deps.rb.  Now RubyGems supports multiple platforms.

Fixes #821
  • Loading branch information
drbrain committed Apr 2, 2014
1 parent f9f7d80 commit c019c07
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
2 changes: 2 additions & 0 deletions History.txt
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions lib/rubygems/request_set/gem_dependency_api.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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?

Expand Down Expand Up @@ -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

##
Expand Down
22 changes: 22 additions & 0 deletions test/rubygems/test_gem_request_set_gem_dependency_api.rb
Expand Up @@ -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

Expand Down

0 comments on commit c019c07

Please sign in to comment.