aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test
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/test
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/test')
-rw-r--r--Library/Homebrew/test/test_formula.rb7
-rw-r--r--Library/Homebrew/test/testball.rb14
2 files changed, 21 insertions, 0 deletions
diff --git a/Library/Homebrew/test/test_formula.rb b/Library/Homebrew/test/test_formula.rb
index 4f9bb3930..5c6b78772 100644
--- a/Library/Homebrew/test/test_formula.rb
+++ b/Library/Homebrew/test/test_formula.rb
@@ -278,4 +278,11 @@ class FormulaTests < Test::Unit::TestCase
when :mountainlion then '8badf00d8badf00d8badf00d8badf00d8badf00d'
end, f.bottle.checksum.hexdigest
end
+
+ def test_custom_version_scheme
+ f = CustomVersionSchemeTestBall.new
+
+ assert_version_equal '1.0', f.version
+ assert_instance_of CustomVersionScheme, f.version
+ end
end
diff --git a/Library/Homebrew/test/testball.rb b/Library/Homebrew/test/testball.rb
index c7118d3ee..8e4c745d3 100644
--- a/Library/Homebrew/test/testball.rb
+++ b/Library/Homebrew/test/testball.rb
@@ -271,3 +271,17 @@ class RevisedBottleSpecTestBall < Formula
super "revisedbottlespectestball"
end
end
+
+class CustomVersionScheme < Version
+end
+
+class CustomVersionSchemeTestBall < Formula
+ homepage 'http://example.com'
+ url 'file:///foo.com/testball-0.1.tbz'
+ sha1 '482e737739d946b7c8cbaf127d9ee9c148b999f5'
+ version '1.0' => CustomVersionScheme
+
+ def initialize name=nil
+ super "customversionschemetestball"
+ end
+end