Class: Fontist::Import::FontParsingErrorCollector

Inherits:
Object
  • Object
show all
Defined in:
lib/fontist/import/font_parsing_error_collector.rb

Overview

Collects font parsing errors during import for later reporting

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFontParsingErrorCollector

Returns a new instance of FontParsingErrorCollector.



7
8
9
# File 'lib/fontist/import/font_parsing_error_collector.rb', line 7

def initialize
  @errors = []
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



5
6
7
# File 'lib/fontist/import/font_parsing_error_collector.rb', line 5

def errors
  @errors
end

Instance Method Details

#add(file_path, error_message, backtrace: nil) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/fontist/import/font_parsing_error_collector.rb', line 11

def add(file_path, error_message, backtrace: nil)
  @errors << {
    path: file_path,
    message: error_message,
    backtrace: backtrace,
  }
end

#any?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/fontist/import/font_parsing_error_collector.rb', line 19

def any?
  @errors.any?
end

#countObject



23
24
25
# File 'lib/fontist/import/font_parsing_error_collector.rb', line 23

def count
  @errors.count
end

#grouped_errorsObject

Group errors by file for cleaner display



28
29
30
# File 'lib/fontist/import/font_parsing_error_collector.rb', line 28

def grouped_errors
  @errors.group_by { |e| File.basename(e[:path]) }
end