Class: TF::StatsOutput

Inherits:
Object
  • Object
show all
Defined in:
lib/plugins/tf/stats_output.rb

Constant Summary collapse

RED =
`tput setaf 1`
GREEN =
`tput setaf 2`
YELLOW =
`tput setaf 3`
BLUE =
`tput setaf 4`
RESET =
`tput sgr0`

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStatsOutput

Returns a new instance of StatsOutput.



12
13
14
15
16
17
18
19
# File 'lib/plugins/tf/stats_output.rb', line 12

def initialize
  @counts={}
  @counts[:commands] = 0
  @counts[:tests] = 0
  @counts[:commands_finished] = 0
  @counts[:tests_success] = 0
  @counts[:tests_failure] = 0
end

Class Method Details

.argument_matches?(argument) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/plugins/tf/stats_output.rb', line 8

def self.argument_matches? argument
  [:load] if argument == "--text"
end

Instance Method Details

#command_err(err) ⇒ Object



63
64
# File 'lib/plugins/tf/stats_output.rb', line 63

def command_err err
end

#command_out(out) ⇒ Object



60
61
# File 'lib/plugins/tf/stats_output.rb', line 60

def command_out out
end

#end_command(line, status, env) ⇒ Object



56
57
58
# File 'lib/plugins/tf/stats_output.rb', line 56

def end_command line, status, env
  @counts[:commands_finished] += 1
end

#end_processingObject



40
41
42
# File 'lib/plugins/tf/stats_output.rb', line 40

def end_processing
  puts status
end

#end_test(test) ⇒ Object



50
51
# File 'lib/plugins/tf/stats_output.rb', line 50

def end_test test
end

#start_command(line) ⇒ Object



53
54
# File 'lib/plugins/tf/stats_output.rb', line 53

def start_command line
end

#start_processingObject



21
22
# File 'lib/plugins/tf/stats_output.rb', line 21

def start_processing
end

#start_test(test, env) ⇒ Object



44
45
46
47
48
# File 'lib/plugins/tf/stats_output.rb', line 44

def start_test test, env
  @counts[:commands] += test[:commands].size
  tests_counts = test[:commands].map{|line| line[:tests].nil? ? 0 : line[:tests].size }
  @counts[:tests] += tests_counts.empty? ? 0 : tests_counts.inject(&:+)
end

#statusObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/plugins/tf/stats_output.rb', line 24

def status
  text = "#{BLUE}##### Processed commands #{@counts[:commands_finished]} of #{@counts[:commands]}"
  if @counts[:tests_success] > 0
    text += ", #{GREEN}success tests #{@counts[:tests_success]} of #{@counts[:tests]}"
  end
  if @counts[:tests_failure] > 0
    text += ", #{RED}failure tests #{@counts[:tests_failure]} of #{@counts[:tests]}"
  end
  skipped = @counts[:tests] - @counts[:tests_success] - @counts[:tests_failure]
  if skipped > 0
    text += ", #{YELLOW}skipped tests #{skipped} of #{@counts[:tests]}"
  end
  text += ".#{RESET}"
  text
end

#test_processed(test, status, msg) ⇒ Object



66
67
68
69
70
71
72
# File 'lib/plugins/tf/stats_output.rb', line 66

def test_processed test, status, msg
  if status
    @counts[:tests_success] += 1
  else
    @counts[:tests_failure] += 1
  end
end