aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMike McQuaid2013-08-03 20:02:10 -0700
committerMike McQuaid2013-08-03 22:27:42 -0700
commitcfdd23b3efcfc994908dfb6792c8d062a19f12f1 (patch)
tree56cb67c1eb66d20e4774868c1082696bd2397b5b /Library
parent705a24871993f9eeac108e38f0e587836e4a087a (diff)
downloadbrew-cfdd23b3efcfc994908dfb6792c8d062a19f12f1.tar.bz2
bottles: use dedicated version class.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/bottle_version.rb8
-rw-r--r--Library/Homebrew/bottles.rb3
-rw-r--r--Library/Homebrew/test/test_bottle_versions.rb8
3 files changed, 18 insertions, 1 deletions
diff --git a/Library/Homebrew/bottle_version.rb b/Library/Homebrew/bottle_version.rb
new file mode 100644
index 000000000..6ad8ebeb7
--- /dev/null
+++ b/Library/Homebrew/bottle_version.rb
@@ -0,0 +1,8 @@
+class BottleVersion < Version
+ def self._parse spec
+ spec = Pathname.new(spec) unless spec.is_a? Pathname
+ stem = spec.stem
+
+ super
+ end
+end
diff --git a/Library/Homebrew/bottles.rb b/Library/Homebrew/bottles.rb
index 60a4dcca0..ab484c134 100644
--- a/Library/Homebrew/bottles.rb
+++ b/Library/Homebrew/bottles.rb
@@ -1,6 +1,7 @@
require 'tab'
require 'macos'
require 'extend/ARGV'
+require 'bottle_version'
# TODO: use options={} for some arguments.
@@ -91,8 +92,8 @@ def bottle_tag
end
def bottle_filename_formula_name filename
- version = Version.parse(filename).to_s
path = Pathname.new filename
+ version = BottleVersion.parse(path).to_s
basename = path.basename.to_s
basename.rpartition("-#{version}").first
end
diff --git a/Library/Homebrew/test/test_bottle_versions.rb b/Library/Homebrew/test/test_bottle_versions.rb
new file mode 100644
index 000000000..f418912b7
--- /dev/null
+++ b/Library/Homebrew/test/test_bottle_versions.rb
@@ -0,0 +1,8 @@
+require 'testing_env'
+require 'bottle_version'
+
+class BottleVersionParsingTests < Test::Unit::TestCase
+ def assert_version_detected expected, path
+ assert_equal expected, BottleVersion.parse(path).to_s
+ end
+end