Class: Transpec::Report
- Inherits:
-
Object
- Object
- Transpec::Report
- Defined in:
- lib/transpec/report.rb
Instance Attribute Summary collapse
-
#conversion_errors ⇒ Object
readonly
Returns the value of attribute conversion_errors.
-
#file_errors ⇒ Object
readonly
Returns the value of attribute file_errors.
-
#records ⇒ Object
readonly
Returns the value of attribute records.
Instance Method Summary collapse
- #<<(other) ⇒ Object
- #colored_stats ⇒ Object
- #colored_summary(options = nil) ⇒ Object
-
#initialize ⇒ Report
constructor
A new instance of Report.
- #stats ⇒ Object
- #summary(options = nil) ⇒ Object
- #unique_record_counts ⇒ Object
Constructor Details
#initialize ⇒ Report
Returns a new instance of Report.
9 10 11 12 13 |
# File 'lib/transpec/report.rb', line 9 def initialize @records = [] @conversion_errors = [] @file_errors = [] end |
Instance Attribute Details
#conversion_errors ⇒ Object (readonly)
Returns the value of attribute conversion_errors.
7 8 9 |
# File 'lib/transpec/report.rb', line 7 def conversion_errors @conversion_errors end |
#file_errors ⇒ Object (readonly)
Returns the value of attribute file_errors.
7 8 9 |
# File 'lib/transpec/report.rb', line 7 def file_errors @file_errors end |
#records ⇒ Object (readonly)
Returns the value of attribute records.
7 8 9 |
# File 'lib/transpec/report.rb', line 7 def records @records end |
Instance Method Details
#<<(other) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/transpec/report.rb', line 15 def <<(other) records.concat(other.records) conversion_errors.concat(other.conversion_errors) file_errors.concat(other.file_errors) self end |
#colored_stats ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/transpec/report.rb', line 53 def colored_stats base_color = if !conversion_errors.empty? :magenta elsif annotation_count.nonzero? :yellow else :green end conversion_incomplete_warning_stats(base_color) + error_stats(base_color) end |
#colored_summary(options = nil) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/transpec/report.rb', line 36 def colored_summary( = nil) ||= { bullet: nil, separate_by_blank_line: false } summary = '' unique_record_counts.each do |record, count| summary << "\n" if [:separate_by_blank_line] && !summary.empty? summary << format_record(record, count, [:bullet]) end summary end |
#stats ⇒ Object
65 66 67 |
# File 'lib/transpec/report.rb', line 65 def stats without_color { colored_stats } end |
#summary(options = nil) ⇒ Object
49 50 51 |
# File 'lib/transpec/report.rb', line 49 def summary( = nil) without_color { colored_summary() } end |
#unique_record_counts ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/transpec/report.rb', line 22 def unique_record_counts record_counts = Hash.new(0) records.each do |record| record_counts[record] += 1 end sorted_record_counts = record_counts.sort_by do |record, count| [-count, record] end Hash[sorted_record_counts] end |