bottles: use dedicated version class.

This commit is contained in:
Mike McQuaid 2013-08-03 20:02:10 -07:00
parent 705a248719
commit cfdd23b3ef
3 changed files with 18 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -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