Class: Lutaml::Qea::Validation::Formatters::TextFormatter
- Inherits:
-
Object
- Object
- Lutaml::Qea::Validation::Formatters::TextFormatter
- Defined in:
- lib/lutaml/qea/validation/formatters/text_formatter.rb
Overview
Formats validation results as human-readable text with colors
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
-
#format ⇒ String
Formats the validation result as text.
-
#initialize(result: nil, **options) ⇒ TextFormatter
constructor
Creates a new text formatter.
Constructor Details
#initialize(result: nil, **options) ⇒ TextFormatter
Creates a new text formatter
(default: true) (default: false)
28 29 30 31 32 33 34 35 |
# File 'lib/lutaml/qea/validation/formatters/text_formatter.rb', line 28 def initialize(result: nil, **) @result = result @options = { color: true, verbose: false, limit: nil, }.merge() end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
17 18 19 |
# File 'lib/lutaml/qea/validation/formatters/text_formatter.rb', line 17 def @options end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
17 18 19 |
# File 'lib/lutaml/qea/validation/formatters/text_formatter.rb', line 17 def result @result end |
Instance Method Details
#format ⇒ String
Formats the validation result as text
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/lutaml/qea/validation/formatters/text_formatter.rb', line 40 def format # rubocop:disable Metrics/AbcSize,Metrics/MethodLength lines = [] lines << header lines << "" lines << summary lines << "" if result.has_errors? lines << section_header("ERRORS", result.errors.size) lines << (result.errors) lines << "" end if result.has_warnings? lines << section_header("WARNINGS", result.warnings.size) lines << (result.warnings) lines << "" end if result.has_info? && [:verbose] lines << section_header("INFO", result.info.size) lines << (result.info) lines << "" end lines << lines.join("\n") end |