Permalink
Browse files

move the backport of Gem::Version#segment to RubygemsIntegration

  • Loading branch information...
1 parent a2ecae7 commit 1ef523331b484e2f27d7945fbdd55b862f156fdb @indirect indirect committed Aug 8, 2011
Showing with 22 additions and 12 deletions.
  1. +0 −10 lib/bundler/rubygems_ext.rb
  2. +22 −2 lib/bundler/rubygems_integration.rb
@@ -158,16 +158,6 @@ def hash
alias eql? ==
end
- # fix bug in Rubygems < 1.4 by backporting the segment code
- if Gem::Version.new(Gem::VERSION) < Gem::Version.new("1.4.0")
- class Version
- def segments # :nodoc:
- @segments ||= @version.scan(/[0-9]+|[a-z]+/i).map do |s|
- /^\d+$/ =~ s ? s.to_i : s
- end
- end
- end
- end
end
module Bundler
@@ -250,7 +250,17 @@ def replace_entrypoints(specs)
Gem.clear_paths
end
- # Rubygems versions 1.3.6 through 1.6.2
+ # This backports the correct segment generation code from Rubygems 1.4+
+ # by monkeypatching it into the method in Rubygems 1.3.6 and 1.3.7.
+ def backport_segment_generation
+ Gem::Version.send(:define_method, :segments) do
+ @segments ||= @version.scan(/[0-9]+|[a-z]+/i).map do |s|
+ /^\d+$/ =~ s ? s.to_i : s
+ end
+ end
+ end
+
+ # Rubygems 1.4 through 1.6
class Legacy < RubygemsIntegration
def stub_rubygems(specs)
stub_source_index137(specs)
@@ -265,6 +275,14 @@ def find_name(name)
end
end
+ # Rubygems versions 1.3.6 and 1.3.7
+ class Ancient < Legacy
+ def initialize
+ super
+ backport_segment_generation
+ end
+ end
+
# Rubygems 1.7
class Transitional < Legacy
def stub_rubygems(specs)
@@ -313,8 +331,10 @@ def preserve_paths
@rubygems = RubygemsIntegration::AlmostModern.new
elsif Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.7.0')
@rubygems = RubygemsIntegration::Transitional.new
- else # Rubygems 1.3.6 through 1.6.2
+ elsif Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.4.0')
@rubygems = RubygemsIntegration::Legacy.new
+ else # Rubygems 1.3.6 and 1.3.7
+ @rubygems = RubygemsIntegration::Ancient.new
end
class << self

0 comments on commit 1ef5233

Please sign in to comment.