| 
									
										
										
										
											2024-08-13 12:23:33 -06:00
										 |  |  | # typed: strict | 
					
						
							| 
									
										
										
										
											2023-04-18 00:22:13 +01:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | require "downloadable" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module Homebrew | 
					
						
							|  |  |  |   module API | 
					
						
							|  |  |  |     class DownloadStrategy < CurlDownloadStrategy | 
					
						
							|  |  |  |       sig { override.returns(Pathname) } | 
					
						
							|  |  |  |       def symlink_location | 
					
						
							|  |  |  |         cache/name | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-14 21:03:08 -04:00
										 |  |  |     class Download | 
					
						
							|  |  |  |       include Downloadable | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-18 00:22:13 +01:00
										 |  |  |       sig { | 
					
						
							|  |  |  |         params( | 
					
						
							|  |  |  |           url:      String, | 
					
						
							|  |  |  |           checksum: T.nilable(Checksum), | 
					
						
							|  |  |  |           mirrors:  T::Array[String], | 
					
						
							|  |  |  |           cache:    T.nilable(Pathname), | 
					
						
							|  |  |  |         ).void | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       def initialize(url, checksum, mirrors: [], cache: nil) | 
					
						
							|  |  |  |         super() | 
					
						
							| 
									
										
										
										
											2024-08-13 12:23:33 -06:00
										 |  |  |         @url = T.let(URL.new(url, using: API::DownloadStrategy), URL) | 
					
						
							| 
									
										
										
										
											2023-04-18 00:22:13 +01:00
										 |  |  |         @checksum = checksum | 
					
						
							|  |  |  |         @mirrors = mirrors | 
					
						
							|  |  |  |         @cache = cache | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-14 21:03:08 -04:00
										 |  |  |       sig { override.returns(API::DownloadStrategy) } | 
					
						
							|  |  |  |       def downloader | 
					
						
							|  |  |  |         T.cast(super, API::DownloadStrategy) | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       sig { override.returns(String) } | 
					
						
							|  |  |  |       def name | 
					
						
							| 
									
										
										
										
											2024-07-15 21:02:09 -04:00
										 |  |  |         download_name | 
					
						
							| 
									
										
										
										
											2024-07-14 21:03:08 -04:00
										 |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       sig { override.returns(String) } | 
					
						
							|  |  |  |       def download_type | 
					
						
							| 
									
										
										
										
											2024-07-15 21:02:09 -04:00
										 |  |  |         "API source" | 
					
						
							| 
									
										
										
										
											2024-07-14 21:03:08 -04:00
										 |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-18 00:22:13 +01:00
										 |  |  |       sig { override.returns(Pathname) } | 
					
						
							|  |  |  |       def cache | 
					
						
							|  |  |  |         @cache || super | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       sig { returns(Pathname) } | 
					
						
							|  |  |  |       def symlink_location | 
					
						
							| 
									
										
										
										
											2024-07-14 21:03:08 -04:00
										 |  |  |         downloader.symlink_location | 
					
						
							| 
									
										
										
										
											2023-04-18 00:22:13 +01:00
										 |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |