Skip to content

Commit

Permalink
Merge pull request #7935 from rolandwalker/stanza_accessors
Browse files Browse the repository at this point in the history
Be more consistent/liberal about stanza accessors.
  • Loading branch information
rolandwalker committed Dec 9, 2014
2 parents 481f4b9 + 2e2023b commit 1520106
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/cask/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def homepage(homepage=nil)
end

def url(*args)
return @url if args.empty?
if @url and !args.empty?
raise CaskInvalidError.new(self.token, "'url' stanza may only appear once")
end
Expand All @@ -93,6 +94,7 @@ def url(*args)
end

def appcast(*args)
return @appcast if args.empty?
if @appcast and !args.empty?
raise CaskInvalidError.new(self.token, "'appcast' stanza may only appear once")
end
Expand All @@ -104,6 +106,7 @@ def appcast(*args)
end

def gpg(*args)
return @gpg if args.empty?
if @gpg and !args.empty?
raise CaskInvalidError.new(self.token, "'gpg' stanza may only appear once")
end
Expand All @@ -115,6 +118,7 @@ def gpg(*args)
end

def container(*args)
return @container if args.empty?
if @container and !args.empty?
# todo: remove this constraint, and instead merge multiple container stanzas
raise CaskInvalidError.new(self.token, "'container' stanza may only appear once")
Expand Down Expand Up @@ -147,6 +151,7 @@ def version(arg=nil)
end

def tags(*args)
return @tags if args.empty?
if @tags and !args.empty?
# consider removing this limitation
raise CaskInvalidError.new(self.token, "'tags' stanza may only appear once")
Expand All @@ -159,6 +164,7 @@ def tags(*args)
end

def license(arg=nil)
return @license if arg.nil?
if @license and !arg.nil?
raise CaskInvalidError.new(self.token, "'license' stanza may only appear once")
end
Expand All @@ -169,7 +175,9 @@ def license(arg=nil)
end
end

# depends_on uses a load method so that multiple stanzas can be merged
def depends_on(*args)
return @depends_on if args.empty?
@depends_on ||= Cask::DSL::DependsOn.new()
begin
@depends_on.load(*args) unless args.empty?
Expand All @@ -184,6 +192,7 @@ def conflicts_with(*args)
# todo: remove this constraint, and instead merge multiple conflicts_with stanzas
raise CaskInvalidError.new(self.token, "'conflicts_with' stanza may only appear once")
end
return @conflicts_with if args.empty?
@conflicts_with ||= begin
Cask::DSL::ConflictsWith.new(*args) unless args.empty?
rescue StandardError => e
Expand Down

0 comments on commit 1520106

Please sign in to comment.