Permalink
Browse files

Rubygems 1.7 removes SourceIndex#from_gems_in, so we adapt

  • Loading branch information...
indirect committed Apr 1, 2011
1 parent b057fe1 commit 7008382d7de4463096784a2a1e667ac930366d94
Showing with 16 additions and 7 deletions.
  1. +16 −7 lib/bundler/shared_helpers.rb
@@ -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

0 comments on commit 7008382

Please sign in to comment.