Class: Slk::Services::EmojiDownloader
- Inherits:
-
Object
- Object
- Slk::Services::EmojiDownloader
- Defined in:
- lib/slk/services/emoji_downloader.rb
Overview
Downloads workspace custom emoji to local cache
Constant Summary collapse
- NETWORK_ERRORS =
[ SocketError, Errno::ECONNREFUSED, Errno::ETIMEDOUT, Net::OpenTimeout, Net::ReadTimeout, URI::InvalidURIError, OpenSSL::SSL::SSLError ].freeze
Instance Method Summary collapse
-
#download(workspace_name, emoji_map) ⇒ Hash
Download custom emoji for a workspace.
-
#initialize(emoji_dir:, on_progress: nil, on_debug: nil) ⇒ EmojiDownloader
constructor
A new instance of EmojiDownloader.
Constructor Details
#initialize(emoji_dir:, on_progress: nil, on_debug: nil) ⇒ EmojiDownloader
Returns a new instance of EmojiDownloader.
17 18 19 20 21 |
# File 'lib/slk/services/emoji_downloader.rb', line 17 def initialize(emoji_dir:, on_progress: nil, on_debug: nil) @emoji_dir = emoji_dir @on_progress = on_progress @on_debug = on_debug end |
Instance Method Details
#download(workspace_name, emoji_map) ⇒ Hash
Download custom emoji for a workspace
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/slk/services/emoji_downloader.rb', line 27 def download(workspace_name, emoji_map) workspace_dir = File.join(@emoji_dir, workspace_name) FileUtils.mkdir_p(workspace_dir) to_download = emoji_map.reject { |_, url| url.start_with?('alias:') } stats = initial_stats(emoji_map.size, to_download.size) download_all(workspace_dir, to_download, stats) stats end |