aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorMarkus Reiter2017-04-22 12:53:17 +0200
committerGitHub2017-04-22 12:53:17 +0200
commit44232ab0446f25d0a59ef085870fc620a6337068 (patch)
tree267cc90e358054c7c2d914e6e60f06e6b9d7f634 /Library/Homebrew
parent1772088099973bf19100380f8ed2fe01402d6195 (diff)
parent1e06d1318e3909e3c2c5fdae73f866538b90d25a (diff)
downloadbrew-44232ab0446f25d0a59ef085870fc620a6337068.tar.bz2
Merge pull request #2519 from reitermarkus/validate-container-type
Validate `container :type`.
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/cask/lib/hbc/container.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/dsl/container.rb9
2 files changed, 8 insertions, 3 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/container.rb b/Library/Homebrew/cask/lib/hbc/container.rb
index c6b2c3c37..961e31968 100644
--- a/Library/Homebrew/cask/lib/hbc/container.rb
+++ b/Library/Homebrew/cask/lib/hbc/container.rb
@@ -61,7 +61,7 @@ module Hbc
begin
const_get(type.to_s.split("_").map(&:capitalize).join)
rescue NameError
- false
+ nil
end
end
end
diff --git a/Library/Homebrew/cask/lib/hbc/dsl/container.rb b/Library/Homebrew/cask/lib/hbc/dsl/container.rb
index ab260c98c..caaf25bca 100644
--- a/Library/Homebrew/cask/lib/hbc/dsl/container.rb
+++ b/Library/Homebrew/cask/lib/hbc/dsl/container.rb
@@ -1,3 +1,5 @@
+require "hbc/container"
+
module Hbc
class DSL
class Container
@@ -13,9 +15,12 @@ module Hbc
@pairs = pairs
pairs.each do |key, value|
raise "invalid container key: '#{key.inspect}'" unless VALID_KEYS.include?(key)
- writer_method = "#{key}=".to_sym
- send(writer_method, value)
+ send(:"#{key}=", value)
end
+
+ return if type.nil?
+ return unless Hbc::Container.from_type(type).nil?
+ raise "invalid container type: #{type.inspect}"
end
def to_yaml