Class: Fontist::Import::Files::FontDetector
- Inherits:
 - 
      Object
      
        
- Object
 - Fontist::Import::Files::FontDetector
 
 
- Defined in:
 - lib/fontist/import/files/font_detector.rb
 
Constant Summary collapse
- REQUIREMENTS =
 { file: FileRequirement.new }.freeze
- FONT_LABELS =
 ["OpenType font data", "TrueType Font data"].freeze
- COLLECTION_LABELS =
 ["OpenType font collection data", "TrueType font collection data"].freeze
- FONT_EXTENSIONS =
 { "OpenType font data" => "otf", "TrueType Font data" => "ttf", "OpenType font collection data" => "ttc", "TrueType font collection data" => "ttc", }.freeze
Class Method Summary collapse
Class Method Details
.detect(path) ⇒ Object
      22 23 24 25 26 27 28 29 30 31 32  | 
    
      # 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) ⇒ Object
      44 45 46  | 
    
      # File 'lib/fontist/import/files/font_detector.rb', line 44 def self.file_brief(path) REQUIREMENTS[:file].call(path) end  | 
  
.standard_extension(path) ⇒ Object
      34 35 36 37 38 39 40 41 42  | 
    
      # 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  |