Module: Tryouts::CLI::FormatterInterface

Included in:
AgentFormatter, CompactFormatter, QuietFormatter, VerboseFormatter
Defined in:
lib/tryouts/cli/formatters/base.rb

Overview

Enhanced interface for all test output formatting

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#current_indentObject (readonly)

Returns the value of attribute current_indent.



11
12
13
# File 'lib/tryouts/cli/formatters/base.rb', line 11

def current_indent
  @current_indent
end

#stderrObject (readonly)

Returns the value of attribute stderr.



11
12
13
# File 'lib/tryouts/cli/formatters/base.rb', line 11

def stderr
  @stderr
end

#stdoutObject (readonly)

Returns the value of attribute stdout.



11
12
13
# File 'lib/tryouts/cli/formatters/base.rb', line 11

def stdout
  @stdout
end

Instance Method Details

#batch_summary(failure_collector) ⇒ Object

Summary operations



85
86
87
# File 'lib/tryouts/cli/formatters/base.rb', line 85

def batch_summary(failure_collector)
  # Default: no output
end

#debug_info(message, level: 0) ⇒ Object

Debug and diagnostic output



94
95
96
# File 'lib/tryouts/cli/formatters/base.rb', line 94

def debug_info(message, level: 0)
  # Default: no output
end

#error_message(message, backtrace: nil) ⇒ Object



102
103
104
# File 'lib/tryouts/cli/formatters/base.rb', line 102

def error_message(message, backtrace: nil)
  # Default: no output
end

#file_end(file_path, context_info: {}) ⇒ Object



30
31
32
# File 'lib/tryouts/cli/formatters/base.rb', line 30

def file_end(file_path, context_info: {})
  # Default: no output
end

#file_execution_start(file_path, test_count:, context_mode:) ⇒ Object



42
43
44
# File 'lib/tryouts/cli/formatters/base.rb', line 42

def file_execution_start(file_path, test_count:, context_mode:)
  # Default: no output
end

#file_parsed(file_path, test_count:, setup_present: false, teardown_present: false) ⇒ Object



34
35
36
# File 'lib/tryouts/cli/formatters/base.rb', line 34

def file_parsed(file_path, test_count:, setup_present: false, teardown_present: false)
  # Default: no output
end

#file_result(file_path, total_tests:, failed_count:, error_count:, elapsed_time: nil) ⇒ Object



46
47
48
# File 'lib/tryouts/cli/formatters/base.rb', line 46

def file_result(file_path, total_tests:, failed_count:, error_count:, elapsed_time: nil)
  # Default: no output
end

#file_start(file_path, context_info: {}) ⇒ Object

File-level operations



26
27
28
# File 'lib/tryouts/cli/formatters/base.rb', line 26

def file_start(file_path, context_info: {})
  # Default: no output
end

#grand_total(total_tests:, failed_count:, error_count:, successful_files:, total_files:, elapsed_time:) ⇒ Object



89
90
91
# File 'lib/tryouts/cli/formatters/base.rb', line 89

def grand_total(total_tests:, failed_count:, error_count:, successful_files:, total_files:, elapsed_time:)
  # Default: no output
end

#initialize(options = {}) ⇒ Object



13
14
15
16
17
18
# File 'lib/tryouts/cli/formatters/base.rb', line 13

def initialize(options = {})
  @stdout = options.fetch(:stdout, $stdout)
  @stderr = options.fetch(:stderr, $stderr)
  @current_indent = 0
  @options = options
end

#live_status_capabilitiesObject

Live status capability negotiation



107
108
109
110
111
112
113
# File 'lib/tryouts/cli/formatters/base.rb', line 107

def live_status_capabilities
  {
    supports_coordination: false,    # Can work with coordinated output
    output_frequency: :medium,       # :low, :medium, :high
    requires_tty: false,             # Must have TTY to function
  }
end

#live_status_managerObject



120
121
122
# File 'lib/tryouts/cli/formatters/base.rb', line 120

def live_status_manager
  @live_status_manager
end

#parser_warnings(file_path, warnings:) ⇒ Object



38
39
40
# File 'lib/tryouts/cli/formatters/base.rb', line 38

def parser_warnings(file_path, warnings:)
  # Default: no output - override in specific formatters
end

#phase_header(message, file_count: nil) ⇒ Object

Phase-level output (major sections)



21
22
23
# File 'lib/tryouts/cli/formatters/base.rb', line 21

def phase_header(message, file_count: nil)
  # Default: no output
end

#puts(text = '') ⇒ Object



133
134
135
# File 'lib/tryouts/cli/formatters/base.rb', line 133

def puts(text = '')
  write("#{text}\n")
end

#set_live_status_manager(manager) ⇒ Object

Live status integration (optional methods)



116
117
118
# File 'lib/tryouts/cli/formatters/base.rb', line 116

def set_live_status_manager(manager)
  @live_status_manager = manager
end

#setup_output(output_text) ⇒ Object



72
73
74
# File 'lib/tryouts/cli/formatters/base.rb', line 72

def setup_output(output_text)
  # Default: no output
end

#setup_start(line_range:) ⇒ Object

Setup/teardown operations



68
69
70
# File 'lib/tryouts/cli/formatters/base.rb', line 68

def setup_start(line_range:)
  # Default: no output
end

#teardown_output(output_text) ⇒ Object



80
81
82
# File 'lib/tryouts/cli/formatters/base.rb', line 80

def teardown_output(output_text)
  # Default: no output
end

#teardown_start(line_range:) ⇒ Object



76
77
78
# File 'lib/tryouts/cli/formatters/base.rb', line 76

def teardown_start(line_range:)
  # Default: no output
end

#test_end(test_case:, index:, total:) ⇒ Object



55
56
57
# File 'lib/tryouts/cli/formatters/base.rb', line 55

def test_end(test_case:, index:, total:)
  # Default: no output
end

#test_output(test_case:, output_text:, result_packet:) ⇒ Object



63
64
65
# File 'lib/tryouts/cli/formatters/base.rb', line 63

def test_output(test_case:, output_text:, result_packet:)
  # Default: no output
end

#test_result(result_packet) ⇒ Object



59
60
61
# File 'lib/tryouts/cli/formatters/base.rb', line 59

def test_result(result_packet)
  # Default: no output
end

#test_start(test_case:, index:, total:) ⇒ Object

Test-level operations



51
52
53
# File 'lib/tryouts/cli/formatters/base.rb', line 51

def test_start(test_case:, index:, total:)
  # Default: no output
end

#trace_info(message, level: 0) ⇒ Object



98
99
100
# File 'lib/tryouts/cli/formatters/base.rb', line 98

def trace_info(message, level: 0)
  # Default: no output
end

#update_live_status(state_updates = {}) ⇒ Object

Optional: formatters can implement this to provide custom live status updates



138
139
140
# File 'lib/tryouts/cli/formatters/base.rb', line 138

def update_live_status(state_updates = {})
  @live_status_manager&.update_status(state_updates)
end

#write(text) ⇒ Object

Standard output methods that coordinate with live status automatically



125
126
127
128
129
130
131
# File 'lib/tryouts/cli/formatters/base.rb', line 125

def write(text)
  if @live_status_manager&.enabled?
    @live_status_manager.write_string(text)
  else
    @stdout.print(text)
  end
end