Class: Glossarist::Agent::HttpCacheDownloader

Inherits:
Object
  • Object
show all
Defined in:
lib/glossarist/agent/http_cache_downloader.rb

Constant Summary collapse

CACHE_EXPIRY_DAYS =
7

Instance Method Summary collapse

Constructor Details

#initialize(cache_dir, fetch: true) ⇒ HttpCacheDownloader

Returns a new instance of HttpCacheDownloader.



11
12
13
14
15
16
# File 'lib/glossarist/agent/http_cache_downloader.rb', line 11

def initialize(cache_dir, fetch: true)
  @cache_dir = cache_dir
  @fetch = fetch
  FileUtils.mkdir_p(@cache_dir)
  @client = Faraday.new { |faraday| faraday.adapter Faraday.default_adapter }
end

Instance Method Details

#download_files(url_map) ⇒ Object



18
19
20
21
# File 'lib/glossarist/agent/http_cache_downloader.rb', line 18

def download_files(url_map)
  url_map.each { |filename, url| process_file(filename, url) }
  puts "All files are up to date in the cache."
end