Class: Fontist::Utils::Downloader
- Inherits:
-
Object
- Object
- Fontist::Utils::Downloader
- Defined in:
- lib/fontist/utils/downloader.rb
Class Method Summary collapse
Instance Method Summary collapse
- #download ⇒ Object
-
#initialize(file, file_size: nil, sha: nil, progress_bar: nil, use_content_length: true, cache_path: nil) ⇒ Downloader
constructor
A new instance of Downloader.
Constructor Details
#initialize(file, file_size: nil, sha: nil, progress_bar: nil, use_content_length: true, cache_path: nil) ⇒ Downloader
Returns a new instance of Downloader.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/fontist/utils/downloader.rb', line 15 def initialize(file, file_size: nil, sha: nil, progress_bar: nil, use_content_length: true, cache_path: nil) # TODO: If the first mirror fails, try the second one @file = file @sha = [sha].flatten.compact @file_size = file_size.to_i if file_size @progress_bar = @verbose = == :verbose @use_content_length = use_content_length @cache = Cache.new(cache_path: cache_path) end |
Class Method Details
.download(*args) ⇒ Object
9 10 11 |
# File 'lib/fontist/utils/downloader.rb', line 9 def download(*args) new(*args).download end |
Instance Method Details
#download ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/fontist/utils/downloader.rb', line 31 def download file = @cache.fetch(url) do download_file end check_tampered(file) file end |