forked from rails/rails
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Version comparison using strings is faulty. Gem::Version is now equip…
…ped with symbols for version comparison.
- Loading branch information
Showing
31 changed files
with
183 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
module ActiveSupport | ||
FrozenObjectError = RUBY_VERSION < '1.9' ? TypeError : RuntimeError | ||
FrozenObjectError = Gem.ruby_version < '1.9' ? TypeError : RuntimeError | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require 'active_support/core_ext/rubygems/version' |
61 changes: 61 additions & 0 deletions
61
activesupport/lib/active_support/core_ext/rubygems/version.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
module Gem | ||
class Version | ||
# Checks if this version is inferior than the other. | ||
# | ||
# Gem::Version.new("1.8.7") < "1.9.2" #=> true | ||
# Gem::Version.new("1.9") < "1.8.7" #=> false | ||
# | ||
# <tt>Gem.ruby_version < "1.9.2"</tt> can be handy, as <tt>Gem.ruby_version</tt> returns | ||
# an object of <tt>Gem::Version</tt> | ||
def < other_version | ||
(self <=> Version.new(other_version)) == -1 | ||
end | ||
|
||
# Checks if this version is superior than the other. | ||
# | ||
# Gem::Version.new("1.8.7") > "1.9.2" #=> false | ||
# Gem::Version.new("1.9") > "1.8.7" #=> true | ||
# | ||
# <tt>Gem.ruby_version > "1.9.2"</tt> can be handy, as <tt>Gem.ruby_version</tt> returns | ||
# an object of <tt>Gem::Version</tt> | ||
def > other_version | ||
(self <=> Version.new(other_version)) == 1 | ||
end | ||
|
||
# Checks if both the versions are similar. | ||
# | ||
# Gem::Version.new("1.9.2") == "1.9.2" #=> true | ||
# Gem::Version.new("1.9") == "1.8.7" #=> false | ||
# | ||
# <tt>Gem.ruby_version == "1.9.2"</tt> can be handy, as <tt>Gem.ruby_version</tt> returns | ||
# an object of <tt>Gem::Version</tt> | ||
def == other_version | ||
(self <=> Version.new(other_version)) == 0 | ||
end | ||
|
||
# Checks if this version is superior or similar to the other. | ||
# | ||
# Gem::Version.new("1.8.7") >= "1.9.2" #=> false | ||
# Gem::Version.new("1.9") >= "1.8.7" #=> true | ||
# Gem::Version.new("1.9") >= "1.9" #=> true | ||
# | ||
# <tt>Gem.ruby_version >= "1.9.2"</tt> can be handy, as <tt>Gem.ruby_version</tt> returns | ||
# an object of <tt>Gem::Version</tt> | ||
def >= other_version | ||
(self > other_version) || (self == other_version) | ||
end | ||
|
||
# Checks if this version is inferior or similar to the other. | ||
# | ||
# Gem::Version.new("1.8.7") <= "1.9.2" #=> true | ||
# Gem::Version.new("1.8.7") <= "1.8.7" #=> true | ||
# Gem::Version.new("1.9") <= "1.8.7" #=> false | ||
# | ||
# <tt>Gem.ruby_version <= "1.9.2"</tt> can be handy, as <tt>Gem.ruby_version</tt> returns | ||
# an object of <tt>Gem::Version</tt> | ||
def <= other_version | ||
(self < other_version) || (self == other_version) | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.