Class: Recog::VerifyReporter

Inherits:
Object
  • Object
show all
Defined in:
lib/recog/verify_reporter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, formatter) ⇒ VerifyReporter

Returns a new instance of VerifyReporter.



6
7
8
9
10
# File 'lib/recog/verify_reporter.rb', line 6

def initialize(options, formatter)
  @options = options
  @formatter = formatter
  reset_counts
end

Instance Attribute Details

#failure_countObject (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

#formatterObject (readonly)

Returns the value of attribute formatter.



3
4
5
# File 'lib/recog/verify_reporter.rb', line 3

def formatter
  @formatter
end

#success_countObject (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_countObject (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) ⇒ Object



29
30
31
32
# File 'lib/recog/verify_reporter.rb', line 29

def failure(text)
  @failure_count += 1
  formatter.failure_message("#{padding}#{text}")
end


46
47
48
# File 'lib/recog/verify_reporter.rb', line 46

def print_fingerprint_count(count)
  formatter.status_message("\nVerified #{count} fingerprints:")
end


34
35
36
37
38
39
# File 'lib/recog/verify_reporter.rb', line 34

def print_name(fingerprint)
  if detail? && fingerprint.tests.any?
    name = fingerprint.name.empty? ? '[unnamed]' : fingerprint.name
    formatter.status_message("\n#{name}")
  end
end


50
51
52
# File 'lib/recog/verify_reporter.rb', line 50

def print_summary
  colorize_summary(summary_line)
end

#report(fingerprint_count) {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



12
13
14
15
16
# File 'lib/recog/verify_reporter.rb', line 12

def report(fingerprint_count)
  reset_counts
  yield self
  summarize(fingerprint_count) unless @options.quiet
end

#success(text) ⇒ Object



18
19
20
21
# File 'lib/recog/verify_reporter.rb', line 18

def success(text)
  @success_count += 1
  formatter.success_message("#{padding}#{text}") if detail?
end

#summarize(fingerprint_count) ⇒ Object



41
42
43
44
# File 'lib/recog/verify_reporter.rb', line 41

def summarize(fingerprint_count)
  print_fingerprint_count(fingerprint_count) if detail?
  print_summary
end

#warning(text) ⇒ Object



23
24
25
26
27
# File 'lib/recog/verify_reporter.rb', line 23

def warning(text)
  return unless @options.warnings
  @warning_count += 1
  formatter.warning_message("#{padding}#{text}")
end