aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/formula_support.rb
diff options
context:
space:
mode:
authorJack Nagel2012-07-10 21:45:17 -0500
committerJack Nagel2012-08-18 11:12:09 -0500
commit2ff6c40735be2aca0e37ed94095526abcd115310 (patch)
tree0e6bab0492ac2f44e94a8b1704e4991026395021 /Library/Homebrew/formula_support.rb
parent741a4168d0c5455ecc1574ae1ebe08df1ebfddd8 (diff)
downloadbrew-2ff6c40735be2aca0e37ed94095526abcd115310.tar.bz2
Add support for custom version schemes
A version scheme is a class that inherits from Version and reimplements Version#<=>. This will allow formulae to specify a custom comparison method that will be used instead of the default, for cases where the default is insufficient.
Diffstat (limited to 'Library/Homebrew/formula_support.rb')
-rw-r--r--Library/Homebrew/formula_support.rb13
1 files changed, 8 insertions, 5 deletions
diff --git a/Library/Homebrew/formula_support.rb b/Library/Homebrew/formula_support.rb
index 5c957f422..ec47639e3 100644
--- a/Library/Homebrew/formula_support.rb
+++ b/Library/Homebrew/formula_support.rb
@@ -52,11 +52,14 @@ class SoftwareSpec
end
def version val=nil
- if val.nil?
- @version ||= Version.parse(@url)
- else
- @version = Version.new(val)
- end
+ @version ||= case val
+ when nil then Version.parse(@url)
+ when Hash
+ key, value = val.shift
+ scheme = VersionSchemeDetector.new(value).detect
+ scheme.new(key)
+ else Version.new(val)
+ end
end
def mirror val