| 
									
										
										
										
											2017-04-06 00:33:31 +02:00
										 |  |  | require "hbc/artifact/abstract_artifact" | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  | module Hbc | 
					
						
							|  |  |  |   module Artifact | 
					
						
							| 
									
										
										
										
											2017-04-06 00:33:31 +02:00
										 |  |  |     class NestedContainer < AbstractArtifact | 
					
						
							|  |  |  |       attr_reader :path | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       def initialize(cask, path) | 
					
						
							|  |  |  |         super(cask) | 
					
						
							|  |  |  |         @path = cask.staged_path.join(path) | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       def install_phase(**options) | 
					
						
							|  |  |  |         extract(**options) | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |       end | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-06 00:33:31 +02:00
										 |  |  |       private | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-01 23:33:52 +02:00
										 |  |  |       def summarize | 
					
						
							|  |  |  |         path.relative_path_from(cask.staged_path).to_s | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-06 00:33:31 +02:00
										 |  |  |       def extract(command: nil, verbose: nil, **_) | 
					
						
							| 
									
										
										
										
											2018-07-16 09:16:50 +02:00
										 |  |  |         container = Container.for_path(path) | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |         unless container | 
					
						
							|  |  |  |           raise CaskError, "Aw dang, could not identify nested container at '#{source}'" | 
					
						
							|  |  |  |         end | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-06 00:33:31 +02:00
										 |  |  |         ohai "Extracting nested container #{path.relative_path_from(cask.staged_path)}" | 
					
						
							| 
									
										
										
										
											2018-07-16 20:22:37 +02:00
										 |  |  |         container.new(cask, path, command, verbose: verbose).extract(to: cask.staged_path) | 
					
						
							| 
									
										
										
										
											2017-04-06 00:33:31 +02:00
										 |  |  |         FileUtils.remove_entry_secure(path) | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |   end | 
					
						
							|  |  |  | end |