module Fontist::Import::Google

Constants

DEFAULT_MAX_COUNT

Public Class Methods

digest(path) click to toggle source
# File lib/fontist/import/google.rb, line 21
def self.digest(path)
  checksums = Dir.glob(File.join(path,
                       "*.{[t|T][t|T][f|F],[o|O][t|T][f|F],[t|T][t|T][c|C]}"))
    .sort
    .map { |x| Digest::SHA256.file(x).to_s }

  Digest::SHA256.hexdigest(checksums.to_s)
end
formula_path(name) click to toggle source
# File lib/fontist/import/google.rb, line 16
def self.formula_path(name)
  filename = name.downcase.gsub(" ", "_") + ".yml"
  Fontist.formulas_path.join("google", filename)
end
metadata_name(path) click to toggle source
# File lib/fontist/import/google.rb, line 6
def self.metadata_name(path)
  metadata_path = File.join(path, "METADATA.pb")
  return unless File.exist?(metadata_path)

  File.foreach(metadata_path) do |line|
    name = line.match(/^name: "(.+)"/)
    return name[1] if name
  end
end
style_version(text) click to toggle source
# File lib/fontist/import/google.rb, line 30
def self.style_version(text)
  return unless text

  text.gsub("Version ", "")
end