Do a stricter version check

A version should always be set when going through the constructor
so tighten this check. Also do some style clean ups here.
This commit is contained in:
Adam Vandenberg 2012-03-09 10:18:12 -08:00
parent 275d22db9e
commit 04088ba96d

View File

@ -24,7 +24,6 @@ class Formula
set_instance_variable 'bottle_sha1' set_instance_variable 'bottle_sha1'
set_instance_variable 'head' set_instance_variable 'head'
set_instance_variable 'specs' set_instance_variable 'specs'
set_instance_variable 'standard' set_instance_variable 'standard'
set_instance_variable 'unstable' set_instance_variable 'unstable'
@ -41,19 +40,21 @@ class Formula
end end
raise "No url provided for formula #{name}" if @url.nil? raise "No url provided for formula #{name}" if @url.nil?
@name=name @name = name
validate_variable :name validate_variable :name
# If we got an explicit path, use that, else determine from the name # If we got an explicit path, use that, else determine from the name
@path = path.nil? ? self.class.path(name) : Pathname.new(path) @path = path.nil? ? self.class.path(name) : Pathname.new(path)
# Use a provided version, if any
set_instance_variable 'version' set_instance_variable 'version'
# Otherwise detect the version from the URL
@version ||= @spec_to_use.detect_version @version ||= @spec_to_use.detect_version
validate_variable :version if @version validate_variable :version
CHECKSUM_TYPES.each { |type| set_instance_variable type } CHECKSUM_TYPES.each { |type| set_instance_variable type }
@downloader=download_strategy.new @spec_to_use.url, name, version, @spec_to_use.specs @downloader = download_strategy.new @spec_to_use.url, name, version, @spec_to_use.specs
end end
# if the dir is there, but it's empty we consider it not installed # if the dir is there, but it's empty we consider it not installed