Class: Fontist::Import::FontParsingErrorCollector
- Inherits:
-
Object
- Object
- Fontist::Import::FontParsingErrorCollector
- Defined in:
- lib/fontist/import/font_parsing_error_collector.rb
Overview
Collects font parsing errors during import for later reporting
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
- #add(file_path, error_message, backtrace: nil) ⇒ Object
- #any? ⇒ Boolean
- #count ⇒ Object
-
#grouped_errors ⇒ Object
Group errors by file for cleaner display.
-
#initialize ⇒ FontParsingErrorCollector
constructor
A new instance of FontParsingErrorCollector.
Constructor Details
#initialize ⇒ FontParsingErrorCollector
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
#errors ⇒ Object (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, , backtrace: nil) @errors << { path: file_path, message: , backtrace: backtrace, } end |
#any? ⇒ Boolean
19 20 21 |
# File 'lib/fontist/import/font_parsing_error_collector.rb', line 19 def any? @errors.any? end |
#count ⇒ Object
23 24 25 |
# File 'lib/fontist/import/font_parsing_error_collector.rb', line 23 def count @errors.count end |
#grouped_errors ⇒ Object
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 |