Class: Recog::VerifyReporter
- Inherits:
-
Object
- Object
- Recog::VerifyReporter
- Defined in:
- lib/recog/verify_reporter.rb
Instance Attribute Summary collapse
-
#failure_count ⇒ Object
readonly
Returns the value of attribute failure_count.
-
#formatter ⇒ Object
readonly
Returns the value of attribute formatter.
-
#success_count ⇒ Object
readonly
Returns the value of attribute success_count.
-
#warning_count ⇒ Object
readonly
Returns the value of attribute warning_count.
Instance Method Summary collapse
- #failure(text, line = nil) ⇒ Object
-
#initialize(options, formatter, path = nil) ⇒ VerifyReporter
constructor
A new instance of VerifyReporter.
- #print_fingerprint_count(count) ⇒ Object
- #print_name(fingerprint) ⇒ Object
- #print_summary ⇒ Object
- #report(fingerprint_count) {|_self| ... } ⇒ Object
- #success(text) ⇒ Object
- #summarize(fingerprint_count) ⇒ Object
- #warning(text, line = nil) ⇒ Object
Constructor Details
#initialize(options, formatter, path = nil) ⇒ VerifyReporter
Returns a new instance of VerifyReporter.
6 7 8 9 10 11 |
# File 'lib/recog/verify_reporter.rb', line 6 def initialize(, formatter, path=nil) @options = @formatter = formatter @path = path reset_counts end |
Instance Attribute Details
#failure_count ⇒ Object (readonly)
Returns the value of attribute failure_count.
4 5 6 |
# File 'lib/recog/verify_reporter.rb', line 4 def failure_count @failure_count end |
#formatter ⇒ Object (readonly)
Returns the value of attribute formatter.
3 4 5 |
# File 'lib/recog/verify_reporter.rb', line 3 def formatter @formatter end |
#success_count ⇒ Object (readonly)
Returns the value of attribute success_count.
4 5 6 |
# File 'lib/recog/verify_reporter.rb', line 4 def success_count @success_count end |
#warning_count ⇒ Object (readonly)
Returns the value of attribute warning_count.
4 5 6 |
# File 'lib/recog/verify_reporter.rb', line 4 def warning_count @warning_count end |
Instance Method Details
#failure(text, line = nil) ⇒ Object
33 34 35 36 |
# File 'lib/recog/verify_reporter.rb', line 33 def failure(text, line=nil) @failure_count += 1 formatter.("#{path_label(line)}#{padding}FAIL: #{text}") end |
#print_fingerprint_count(count) ⇒ Object
50 51 52 |
# File 'lib/recog/verify_reporter.rb', line 50 def print_fingerprint_count(count) formatter.("\nVerified #{count} fingerprints:") end |
#print_name(fingerprint) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/recog/verify_reporter.rb', line 38 def print_name(fingerprint) if detail? && fingerprint.tests.any? name = fingerprint.name.empty? ? '[unnamed]' : fingerprint.name formatter.("\n#{name}") end end |
#print_summary ⇒ Object
54 55 56 |
# File 'lib/recog/verify_reporter.rb', line 54 def print_summary colorize_summary(summary_line) end |
#report(fingerprint_count) {|_self| ... } ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/recog/verify_reporter.rb', line 13 def report(fingerprint_count) reset_counts if detail? and !@path.to_s.empty? formatter.("\n#{@path}:\n") end yield self summarize(fingerprint_count) unless @options.quiet end |
#success(text) ⇒ Object
22 23 24 25 |
# File 'lib/recog/verify_reporter.rb', line 22 def success(text) @success_count += 1 formatter.("#{padding}#{text}") if detail? end |
#summarize(fingerprint_count) ⇒ Object
45 46 47 48 |
# File 'lib/recog/verify_reporter.rb', line 45 def summarize(fingerprint_count) print_fingerprint_count(fingerprint_count) if detail? print_summary end |
#warning(text, line = nil) ⇒ Object
27 28 29 30 31 |
# File 'lib/recog/verify_reporter.rb', line 27 def warning(text, line=nil) return unless @options.warnings @warning_count += 1 formatter.("#{path_label(line)}#{padding}WARN: #{text}") end |