Class: Factorix::API::MODDownloadAPI
- Inherits:
-
Object
- Object
- Factorix::API::MODDownloadAPI
- Defined in:
- lib/factorix/api/mod_download_api.rb
Overview
API client for downloading MOD files with service authentication
Requires username and token authentication via ServiceCredential.
Instance Method Summary collapse
-
#download(download_url, output, expected_sha1: nil, handler: nil) ⇒ void
Download a MOD file to the specified output path.
-
#initialize ⇒ MODDownloadAPI
constructor
Initialize with thread-safe credential loading.
Constructor Details
#initialize ⇒ MODDownloadAPI
Initialize with thread-safe credential loading
25 26 27 28 |
# File 'lib/factorix/api/mod_download_api.rb', line 25 def initialize(...) super @service_credential_mutex = Mutex.new end |
Instance Method Details
#download(download_url, output, expected_sha1: nil, handler: nil) ⇒ void
This method returns an undefined value.
Download a MOD file to the specified output path
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/factorix/api/mod_download_api.rb', line 39 def download(download_url, output, expected_sha1: nil, handler: nil) unless download_url.start_with?("/") logger.error("Invalid download_url", url: download_url) raise ArgumentError, "download_url must be a relative path starting with '/'" end uri = build_download_uri(download_url) downloader = Container[:downloader] downloader.subscribe(handler) if handler begin downloader.download(uri, output, expected_sha1:) ensure downloader.unsubscribe(handler) if handler end end |