Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DSL: allow version :latest (symbol not string) #4849

Merged
merged 1 commit into from
Jun 28, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/cask.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def caskroom_path
end

def destination_path
caskroom_path.join(version)
caskroom_path.join(version.to_s)
end

def installed?
Expand Down
8 changes: 6 additions & 2 deletions lib/cask/audit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/cask/caveats.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,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
Expand Down
2 changes: 1 addition & 1 deletion lib/cask/download_strategy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions lib/cask/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,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)
Expand Down