| 
									
										
										
										
											2020-10-10 14:16:11 +02:00
										 |  |  | # typed: true | 
					
						
							| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-23 23:04:49 +02:00
										 |  |  | require "unpack_strategy" | 
					
						
							| 
									
										
										
										
											2017-04-21 13:43:13 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  | module Cask | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |   class DSL | 
					
						
							| 
									
										
										
										
											2020-08-24 23:09:43 +02:00
										 |  |  |     # Class corresponding to the `container` stanza. | 
					
						
							|  |  |  |     # | 
					
						
							|  |  |  |     # @api private | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |     class Container | 
					
						
							| 
									
										
										
										
											2019-04-19 21:46:20 +09:00
										 |  |  |       VALID_KEYS = Set.new([ | 
					
						
							| 
									
										
										
										
											2021-02-11 13:24:19 +00:00
										 |  |  |         :type, | 
					
						
							|  |  |  |         :nested, | 
					
						
							|  |  |  |       ]).freeze | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-07 11:29:33 +01:00
										 |  |  |       attr_accessor(*VALID_KEYS, :pairs) | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |       def initialize(pairs = {}) | 
					
						
							|  |  |  |         @pairs = pairs | 
					
						
							|  |  |  |         pairs.each do |key, value| | 
					
						
							| 
									
										
										
										
											2021-01-26 15:21:24 -05:00
										 |  |  |           raise "invalid container key: #{key.inspect}" unless VALID_KEYS.include?(key) | 
					
						
							| 
									
										
										
										
											2018-09-17 02:45:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-21 13:43:13 +02:00
										 |  |  |           send(:"#{key}=", value) | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |         end | 
					
						
							| 
									
										
										
										
											2017-04-21 13:43:13 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return if type.nil? | 
					
						
							| 
									
										
										
										
											2018-07-23 23:04:49 +02:00
										 |  |  |         return unless UnpackStrategy.from_type(type).nil? | 
					
						
							| 
									
										
										
										
											2018-09-17 02:45:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-21 13:43:13 +02:00
										 |  |  |         raise "invalid container type: #{type.inspect}" | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |       end | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |       def to_yaml | 
					
						
							|  |  |  |         @pairs.to_yaml | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |       def to_s | 
					
						
							|  |  |  |         @pairs.inspect | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |   end | 
					
						
							|  |  |  | end |