Module: Fontist::Import::Google

Defined in:
lib/fontist/import/google.rb,
lib/fontist/import/google/new_fonts_fetcher.rb

Defined Under Namespace

Classes: NewFontsFetcher

Class Method Summary collapse

Class Method Details

.digest(path) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/fontist/import/google.rb', line 19

def self.digest(path)
  checksums = Dir.glob(File.join(path, "*.{ttf,otf,ttc}"))
    .sort
    .map { |x| Digest::SHA256.file(x).to_s }

  Digest::SHA256.hexdigest(checksums.to_s)
end

.formula_path(name) ⇒ Object



14
15
16
17
# File 'lib/fontist/import/google.rb', line 14

def self.formula_path(name)
  filename = name.downcase.gsub(" ", "_") + ".yml"
  Fontist.formulas_path.join("google", filename)
end

.metadata_name(path) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/fontist/import/google.rb', line 4

def self.(path)
   = File.join(path, "METADATA.pb")
  return unless File.exists?()

  File.foreach() do |line|
    name = line.match(/^name: "(.+)"/)
    return name[1] if name
  end
end

.style_version(text) ⇒ Object



27
28
29
30
31
# File 'lib/fontist/import/google.rb', line 27

def self.style_version(text)
  return unless text

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