| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | require "tmpdir" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | require "hbc/container/base" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  | module Hbc | 
					
						
							|  |  |  |   class Container | 
					
						
							|  |  |  |     class GenericUnar < Base | 
					
						
							|  |  |  |       def self.me?(criteria) | 
					
						
							|  |  |  |         lsar = Hbc.homebrew_prefix.join("bin", "lsar") | 
					
						
							|  |  |  |         lsar.exist? && | 
					
						
							|  |  |  |           criteria.command.run(lsar, | 
					
						
							|  |  |  |                                args:         ["-l", "-t", "--", criteria.path], | 
					
						
							|  |  |  |                                print_stderr: false).stdout.chomp.end_with?("passed, 0 failed.") | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |       def extract | 
					
						
							|  |  |  |         unar = Hbc.homebrew_prefix.join("bin", "unar") | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |         unless unar.exist? | 
					
						
							|  |  |  |           raise CaskError, "Expected to find unar executable. Cask #{@cask} must add: depends_on formula: 'unar'" | 
					
						
							|  |  |  |         end | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |         Dir.mktmpdir do |unpack_dir| | 
					
						
							|  |  |  |           @command.run!(unar, args: ["-force-overwrite", "-quiet", "-no-directory", "-output-directory", unpack_dir, "--", @path]) | 
					
						
							|  |  |  |           @command.run!("/usr/bin/ditto", args: ["--", unpack_dir, @cask.staged_path]) | 
					
						
							|  |  |  |         end | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |