Sha256: e13ec73f83f5fe68b06bf6dd28b41429cfcc985cb830d7b63f33395b0a584998
Contents?: true
Size: 878 Bytes
Versions: 9
Compression:
Stored size: 878 Bytes
Contents
module WebFont class Downloader attr_reader :finder def initialize @finder = Finder.new end # Download font from Google and save it locally # # Returns nothing def download(font_family, destination_path, from_cache = true) item = finder.find(font_family) return if item.empty? font_family = item['family'].gsub(/\s/, '-') item['files'].each do |variant, url| filename = "#{font_family}-#{variant}#{File.extname(url)}" font_path = File.join(destination_path, filename) if from_cache && LocalCache.enable? && cache_path = LocalCache.path(filename) FileUtils.copy(cache_path, destination_path) else unless File.exist?(font_path) Command.wget(url, font_path) LocalCache.save(font_path) end end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems