Class: RightConf::StdoutReporter

Inherits:
BaseReporter show all
Defined in:
lib/rconf/progress_reporters/stdout_reporter.rb

Overview

STDOUT progress reporter, logs progress to console

Instance Method Summary collapse

Methods inherited from BaseReporter

#method_missing, #report_result

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RightConf::BaseReporter

Instance Method Details

#format_check(check) ⇒ Object

Format check, should be followed by report_success or report_failure

Parameters

check(String)

Check title

Return

text(String)

Formatted text



64
65
66
67
# File 'lib/rconf/progress_reporters/stdout_reporter.rb', line 64

def format_check(check)
  @in_check = true
  text = super(check)
end

#format_failureObject

Format check failure

Return

text(String)

Formatted text



82
83
84
85
# File 'lib/rconf/progress_reporters/stdout_reporter.rb', line 82

def format_failure
  @in_check = false
  text = super.red
end

#format_fatal(error) ⇒ Object

Format fatal error and raise exception to stop execution

Return

text(String)

Formatted text



91
92
93
94
95
96
# File 'lib/rconf/progress_reporters/stdout_reporter.rb', line 91

def format_fatal(error)
  text = super.split("\n")
  text[0] = text[0].red.bold
  text[1] = text[1].red.bold if text.size > 1
  text.join("\n") + "\n"
end

#format_message(msg) ⇒ Object

Format standard message

Parameters

message(String)

Message

Return

text(String)

Formatted text



38
39
40
41
42
43
# File 'lib/rconf/progress_reporters/stdout_reporter.rb', line 38

def format_message(msg)
  text = @in_check ? "\n" : ''
  text += super(msg)
  @in_check = false
  text
end

#format_section(section) ⇒ Object

Format new progress report section

Parameters

section(String)

Section title

Return

text(String)

Formatted text



52
53
54
55
# File 'lib/rconf/progress_reporters/stdout_reporter.rb', line 52

def format_section(section)
  @in_check = false
  text = super(section).green
end

#format_successObject

Format check success

Return

text(String)

Formatted text



73
74
75
76
# File 'lib/rconf/progress_reporters/stdout_reporter.rb', line 73

def format_success
  @in_check = false
  text = super.blue
end

#write(text) ⇒ Object

Print given text to STDOUT

Parameters

text(String)

Text to be printed

Return

true

Always return true



26
27
28
29
# File 'lib/rconf/progress_reporters/stdout_reporter.rb', line 26

def write(text)
  $stdout.print(text)
  true
end