Class: Recog::MatchReporter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, formatter) ⇒ MatchReporter

Returns a new instance of MatchReporter.


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

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

Instance Attribute Details

#fail_countObject (readonly)

Returns the value of attribute fail_count.


4
5
6
# File 'lib/recog/match_reporter.rb', line 4

def fail_count
  @fail_count
end

#formatterObject (readonly)

Returns the value of attribute formatter.


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

def formatter
  @formatter
end

#line_countObject (readonly)

Returns the value of attribute line_count.


4
5
6
# File 'lib/recog/match_reporter.rb', line 4

def line_count
  @line_count
end

#match_countObject (readonly)

Returns the value of attribute match_count.


4
5
6
# File 'lib/recog/match_reporter.rb', line 4

def match_count
  @match_count
end

Instance Method Details

#failure(text) ⇒ Object


32
33
34
35
# File 'lib/recog/match_reporter.rb', line 32

def failure(text)
  @fail_count += 1
  formatter.failure_message(text)
end

#increment_line_countObject


23
24
25
# File 'lib/recog/match_reporter.rb', line 23

def increment_line_count
  @line_count += 1
end

#match(text) ⇒ Object


27
28
29
30
# File 'lib/recog/match_reporter.rb', line 27

def match(text)
  @match_count += 1
  formatter.success_message(text)
end

37
38
39
# File 'lib/recog/match_reporter.rb', line 37

def print_summary
  colorize_summary(summary_line)
end

#report {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:


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

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

#stop?Boolean

Returns:

  • (Boolean)

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

def stop?
  return false unless @options.fail_fast
  @fail_count >= @options.stop_after
end