diff --git a/lib/cask.rb b/lib/cask.rb index f2dc550e249e6..32b1cf1386623 100644 --- a/lib/cask.rb +++ b/lib/cask.rb @@ -137,7 +137,7 @@ def caskroom_path end def destination_path - caskroom_path.join(version) + caskroom_path.join(version.to_s) end def installed? diff --git a/lib/cask/audit.rb b/lib/cask/audit.rb index 7bb0f7f3e5196..83fd298150d89 100644 --- a/lib/cask/audit.rb +++ b/lib/cask/audit.rb @@ -40,12 +40,16 @@ def _check_checksums def _check_sha256_no_check_if_latest odebug "Verifying sha256 :no_check with version 'latest'" - add_error "you should use sha256 :no_check when version is 'latest'" if cask.version == "latest" && cask.sums.is_a?(Array) + if ((cask.version == "latest" or cask.version == :latest) and cask.sums.is_a?(Array)) + add_error "you should use sha256 :no_check when version is 'latest'" + end end def _check_sha256_if_versioned odebug "Verifying a sha256 is present when versioned" - add_error "you must include a sha256 when version is not 'latest'" if cask.version != "latest" && cask.sums == :no_check + if ((cask.version != "latest" and cask.version != :latest) and cask.sums == :no_check) + add_error "you must include a sha256 when version is not 'latest'" + end end def _check_download(download) diff --git a/lib/cask/caveats.rb b/lib/cask/caveats.rb index a5dac120c41a9..7627bb0106a1a 100644 --- a/lib/cask/caveats.rb +++ b/lib/cask/caveats.rb @@ -33,7 +33,7 @@ def caskroom_path end def destination_path - caskroom_path.join(@cask.version) + caskroom_path.join(@cask.version.to_s) end # DSL. Each method should handle output, following the convention of diff --git a/lib/cask/download_strategy.rb b/lib/cask/download_strategy.rb index c08bde573bc29..b41e9af8e46a4 100644 --- a/lib/cask/download_strategy.rb +++ b/lib/cask/download_strategy.rb @@ -17,7 +17,7 @@ def initialize(cask, command=Cask::SystemCommand) cask.title, ::Resource.new(cask.title) do |r| r.url cask.url.to_s - r.version cask.version + r.version cask.version.to_s end ) end diff --git a/lib/cask/dsl.rb b/lib/cask/dsl.rb index c17729b3ad188..8d00ed97f93f4 100644 --- a/lib/cask/dsl.rb +++ b/lib/cask/dsl.rb @@ -59,11 +59,19 @@ def container_type(type=nil) @container_type ||= type end - def version(version=nil) - if @version and !version.nil? + SYMBOLIC_VERSIONS = Set.new [ + :latest, + ] + + def version(arg=nil) + if arg.nil? + @version + elsif @version raise CaskInvalidError.new(self.title, "'version' stanza may only appear once") + elsif !arg.is_a?(String) and !SYMBOLIC_VERSIONS.include?(arg) + raise CaskInvalidError.new(self.title, "invalid 'version' value: '#{arg.inspect}'") end - @version ||= version + @version ||= arg end def depends_on_formula(*args)