class Tryouts::CLI::FormatterFactory
Factory for creating formatters and output managers
def self.create_formatter(options = {})
def self.create_formatter(options = {}) # Map boolean flags to format symbols if format not explicitly set format = options[:format]&.to_sym || determine_format_from_flags(options) 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 end
def self.create_output_manager(options = {})
def self.create_output_manager(options = {}) formatter = create_formatter(options) OutputManager.new(formatter) end
def determine_format_from_flags(options)
def determine_format_from_flags(options) return :quiet if options[:quiet] return :verbose if options[:verbose] :compact # Default end