Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Rubygems 1.7 removes SourceIndex#from_gems_in, so we adapt
Browse files Browse the repository at this point in the history
  • Loading branch information
indirect committed Apr 1, 2011
1 parent b057fe1 commit 7008382
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions lib/bundler/shared_helpers.rb
Expand Up @@ -123,13 +123,22 @@ def cripple_rubygems(specs)
# === Following hacks are to improve on the generated bin wrappers ===

# Yeah, talk about a hack
source_index_class = (class << Gem::SourceIndex ; self ; end)
source_index_class.send(:remove_method, :from_gems_in)
source_index_class.send(:define_method, :from_gems_in) do |*args|
source_index = Gem::SourceIndex.new
source_index.spec_dirs = *args
source_index.add_specs(*specs)
source_index
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.7.0')
Gem::SourceIndex.send(:define_method, :initialize) do |*args|
@gems = {}
spec_dirs = *args
add_specs(*specs)
end
else
# Rubygems versions lower than 1.7 use SourceIndex#from_gems_in
source_index_class = (class << Gem::SourceIndex ; self ; end)
source_index_class.send(:remove_method, :from_gems_in)
source_index_class.send(:define_method, :from_gems_in) do |*args|
source_index = Gem::SourceIndex.new
source_index.spec_dirs = *args
source_index.add_specs(*specs)
source_index
end
end

# OMG more hacks
Expand Down

0 comments on commit 7008382

Please sign in to comment.