Skip to content
Snippets Groups Projects
Commit f446e958 authored by Jack Nagel's avatar Jack Nagel
Browse files

Remove support for version "schemes", just pass version objects directly

I'm not sure why I thought reinventing object instantiation was a good
idea.
parent 33cdff99
No related branches found
No related tags found
No related merge requests found
......@@ -118,9 +118,9 @@ class Resource
def detect_version(val)
case val
when nil then Version.detect(url, specs)
when String then Version.new(val)
when Hash then Version.new_with_scheme(*val.shift)
when nil then Version.detect(url, specs)
when String then Version.new(val)
when Version then val
else
raise TypeError, "version '#{val.inspect}' should be a string"
end
......
......@@ -61,10 +61,10 @@ class ResourceTests < Test::Unit::TestCase
end
def test_version_with_scheme
scheme = Class.new(Version)
@resource.version('1.0' => scheme)
klass = Class.new(Version)
@resource.version klass.new("1.0")
assert_version_equal '1.0', @resource.version
assert_instance_of scheme, @resource.version
assert_instance_of klass, @resource.version
end
def test_version_from_tag
......
......@@ -155,14 +155,6 @@ class Version
StringToken::PATTERN
)
def self.new_with_scheme(value, scheme)
if Class === scheme && scheme.ancestors.include?(Version)
scheme.new(value)
else
raise TypeError, "Unknown version scheme #{scheme.inspect}"
end
end
def self.detect(url, specs={})
if specs.has_key?(:tag)
new(specs[:tag][/((?:\d+\.)*\d+)/, 1], true)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment