Created
December 3, 2008 00:59
-
-
Save halorgium/31375 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/rubygems.rb b/rubygems.rb | |
| index e85d97c..8fa9466 100644 | |
| --- a/rubygems.rb | |
| +++ b/rubygems.rb | |
| @@ -102,6 +102,7 @@ module Gem | |
| @configuration = nil | |
| @loaded_specs = {} | |
| + @loaded_stacks = {} | |
| @platforms = [] | |
| @ruby = nil | |
| @sources = [] | |
| @@ -128,6 +129,8 @@ module Gem | |
| # Gem::Requirement and Gem::Version documentation. | |
| def self.activate(gem, *version_requirements) | |
| + options = version_requirements.last.is_a?(Hash) ? version_requirements.pop : {} | |
| + sources = options[:sources] || [] | |
| if version_requirements.empty? then | |
| version_requirements = Gem::Requirement.default | |
| end | |
| @@ -146,8 +149,10 @@ module Gem | |
| existing_spec = @loaded_specs[gem.name] | |
| unless matches.any? { |spec| spec.version == existing_spec.version } then | |
| + sources_message = sources.map { |spec| spec.full_name } | |
| + stack_message = @loaded_stacks[gem.name].map { |spec| spec.full_name } | |
| raise Gem::Exception, | |
| - "can't activate #{gem}, already activated #{existing_spec.full_name}" | |
| + "can't activate #{gem} for #{sources_message.inspect}, already activated #{existing_spec.full_name} for #{stack_message.inspect}" | |
| end | |
| return false | |
| @@ -159,10 +164,11 @@ module Gem | |
| spec.loaded = true | |
| @loaded_specs[spec.name] = spec | |
| + @loaded_stacks[spec.name] = sources.dup | |
| # Load dependent gems first | |
| spec.runtime_dependencies.each do |dep_gem| | |
| - activate dep_gem | |
| + activate dep_gem, :sources => [spec, *sources] | |
| end | |
| # bin directory must come before library directories |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment