diff options
| author | Markus Reiter | 2017-04-21 13:43:13 +0200 |
|---|---|---|
| committer | Markus Reiter | 2017-04-21 14:07:34 +0200 |
| commit | 1e06d1318e3909e3c2c5fdae73f866538b90d25a (patch) | |
| tree | 9303ea0fd38753b489950f8e8c51a3d0a34d123a /Library | |
| parent | 2be7999878702554f1e1b5f4118978e670e6156c (diff) | |
| download | brew-1e06d1318e3909e3c2c5fdae73f866538b90d25a.tar.bz2 | |
Validate `container :type`.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/container.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/dsl/container.rb | 9 |
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 |
