Sha256: 9ce8bbadceb7477615850ccd0ba326dfb2f17ae75b24a661f8013f0b6e50111b

Contents?: true

Size: 656 Bytes

Versions: 5

Compression:

Stored size: 656 Bytes

Contents

module WebFont
  class Downloader

    attr_reader :finder

    def initialize
      @finder = WebFont::Finder.new
    end

    # Download font from Google and save it locally
    #
    # Returns nothing
    def download(font_family, destination_path)
      item = finder.find(font_family)

      return if item.empty?

      font_family = item['family'].gsub(/\s/, '-')

      item['files'].each do |variant, url|
        filename = File.join(destination_path, "#{font_family}-#{variant}")
        extname  = File.extname(url)

        system("wget -O #{filename}#{extname} #{url}") unless File.exist?("#{filename}#{extname}")
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
web_font-0.0.5 lib/web_font/downloader.rb
web_font-0.0.4 lib/web_font/downloader.rb
web_font-0.0.3 lib/web_font/downloader.rb
web_font-0.0.2 lib/web_font/downloader.rb
web_font-0.0.1 lib/web_font/downloader.rb