summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Arko <andre@arko.net>2011-08-08 14:55:11 -0700
committerAndre Arko <andre@arko.net>2011-08-08 14:57:41 -0700
commit1ef523331b484e2f27d7945fbdd55b862f156fdb (patch)
tree22e242791b30d51f9dbd6f5f44af3eb666474892
parenta2ecae7590b57beb528449edcf51c0717ca5b525 (diff)
downloadbundler-1ef523331b484e2f27d7945fbdd55b862f156fdb.tar.gz
move the backport of Gem::Version#segment to RubygemsIntegration
-rw-r--r--lib/bundler/rubygems_ext.rb10
-rw-r--r--lib/bundler/rubygems_integration.rb24
2 files changed, 22 insertions, 12 deletions
diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb
index 55356b0149..54e72c53b7 100644
--- a/lib/bundler/rubygems_ext.rb
+++ b/lib/bundler/rubygems_ext.rb
@@ -158,16 +158,6 @@ module Gem
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
diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb
index 6460fab5a5..1c0c55050a 100644
--- a/lib/bundler/rubygems_integration.rb
+++ b/lib/bundler/rubygems_integration.rb
@@ -250,7 +250,17 @@ module Bundler
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 @@ module Bundler
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 @@ module Bundler
@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