Created
October 23, 2010 06:33
-
-
Save thbishop/641873 to your computer and use it in GitHub Desktop.
in rubygem package provider
This file contains 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
def with_gem_sources(*sources) | |
sources.compact! | |
original_sources = Gem.sources | |
# Gem.sources = sources unless sources.empty? | |
unless sources.empty? | |
if Gem.respond_to?(:sources=) | |
Gem.sources = sources | |
else | |
Gem.instance_variable_set(:@sources, sources) | |
end | |
end | |
yield | |
ensure | |
if Gem.respond_to?(:sources=) | |
Gem.sources = sources | |
else | |
Gem.instance_variable_set(:@sources, sources) | |
end | |
end |
This file contains 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
# this method doesn't exist in v 1.2.0 of the Gem module, but does in 1.3.7 (haven't checked what version it was introduced yet) | |
def self.sources=(new_sources) | |
@sources = new_sources | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment