Class: Tryouts::CLI::FormatterFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/tryouts/cli/formatters/factory.rb

Overview

Factory for creating formatters and output managers

Class Method Summary collapse

Class Method Details

.create_formatter(options = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/tryouts/cli/formatters/factory.rb', line 14

def self.create_formatter(options = {})
  # Check for agent mode first (takes precedence)
  if options[:agent]
    return AgentFormatter.new(options)
  end

  # Map boolean flags to format symbols if format not explicitly set
  format = options[:format]&.to_sym || determine_format_from_flags(options)

  # Create base formatter first
  base_formatter = case format
  when :verbose
    if options[:fails_only]
      VerboseFailsFormatter.new(options)
    else
      VerboseFormatter.new(options)
    end
  when :compact
    if options[:fails_only]
      CompactFailsFormatter.new(options)
    else
      CompactFormatter.new(options)
    end
  when :quiet
    if options[:fails_only]
      QuietFailsFormatter.new(options)
    else
      QuietFormatter.new(options)
    end
  else
    CompactFormatter.new(options) # Default to compact
  end

  # Return base formatter - live status is now handled by OutputManager/LiveStatusManager
  base_formatter
end

.create_output_manager(options = {}) ⇒ Object



9
10
11
12
# File 'lib/tryouts/cli/formatters/factory.rb', line 9

def self.create_output_manager(options = {})
  formatter = create_formatter(options)
  OutputManager.new(formatter, options)
end