class Fontist::Import::Files::FontDetector

Constants

COLLECTION_LABELS
FONT_EXTENSIONS
FONT_LABELS
REQUIREMENTS

Public Class Methods

detect(path) click to toggle source
# File lib/fontist/import/files/font_detector.rb, line 22
def self.detect(path)
  brief = file_brief(path)

  if brief.start_with?(*FONT_LABELS)
    :font
  elsif brief.start_with?(*COLLECTION_LABELS)
    :collection
  else
    :other
  end
end
file_brief(path) click to toggle source
# File lib/fontist/import/files/font_detector.rb, line 44
def self.file_brief(path)
  REQUIREMENTS[:file].call(path)
end
standard_extension(path) click to toggle source
# File lib/fontist/import/files/font_detector.rb, line 34
def self.standard_extension(path)
  brief = file_brief(path)

  FONT_EXTENSIONS.each do |label, extension|
    return extension if brief.start_with?(label)
  end

  raise Errors::UnknownFontTypeError.new(path)
end