diff options
| author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-20 08:39:12 +0000 |
|---|---|---|
| committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-20 08:39:12 +0000 |
| commit | dcf06bd39ea72acbc312758e2df764c4b982b40c (patch) | |
| tree | f6d367888b42848fd6a660fad57fa2020e38c097 /lib/rubygems/version.rb | |
| parent | eb954f44e53ba18225a0e906891c47373ce0d651 (diff) | |
| download | ruby-dcf06bd39ea72acbc312758e2df764c4b982b40c.tar.gz ruby-dcf06bd39ea72acbc312758e2df764c4b982b40c.tar.xz ruby-dcf06bd39ea72acbc312758e2df764c4b982b40c.zip | |
Import RubyGems 1.0.0, r1575
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@14361 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/version.rb')
| -rw-r--r-- | lib/rubygems/version.rb | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/rubygems/version.rb b/lib/rubygems/version.rb index 35dd60a74..87a1bc72e 100644 --- a/lib/rubygems/version.rb +++ b/lib/rubygems/version.rb @@ -75,7 +75,7 @@ class Gem::Version # Strip ignored trailing zeros. def normalize - @ints = @version.to_s.scan(/\d+/).map { |s| s.to_i } + @ints = build_array_from_version_string return if @ints.length == 1 @@ -127,19 +127,26 @@ class Gem::Version @ints <=> other.ints end - def hash + alias eql? == # :nodoc: + + def hash # :nodoc: to_ints.inject { |hash_code, n| hash_code + n } end # Return a new version object where the next to the last revision # number is one greater. (e.g. 5.3.1 => 5.4) def bump - ints = @ints.dup + ints = build_array_from_version_string ints.pop if ints.size > 1 ints[-1] += 1 self.class.new(ints.join(".")) end + def build_array_from_version_string + @version.to_s.scan(/\d+/).map { |s| s.to_i } + end + private :build_array_from_version_string + #:stopdoc: require 'rubygems/requirement' |
