Class: CukeCataloger::TextReportFormatter
- Inherits:
-
Object
- Object
- CukeCataloger::TextReportFormatter
- Defined in:
- lib/cuke_cataloger/formatters/text_report_formatter.rb
Overview
Not a part of the public API. Subject to change at any time.
Instance Method Summary collapse
-
#format_data(data) ⇒ Object
Formats validation results into a readable text report.
Instance Method Details
#format_data(data) ⇒ Object
Formats validation results into a readable text report
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/cuke_cataloger/formatters/text_report_formatter.rb', line 10 def format_data(data) report_text = "Validation Results\nProblems found: #{data.count}\n\n" results_by_category = Hash.new { |hash, key| hash[key] = [] } data.each do |result| results_by_category[result[:problem]] << result end results_by_category.each_key do |problem_category| report_text << "#{problem_category} problems: #{results_by_category[problem_category].count}\n" end results_by_category.each_key do |problem_category| report_text << "\n\n#{problem_category} problems (#{results_by_category[problem_category].count}):\n" results_by_category[problem_category].each do |result| report_text << "#{result[:test]}\n" end end report_text end |