class XCPretty::Formatter
Constants
- ASCII_ERROR
- ASCII_WARNING
- ERROR
- WARNING
Attributes
parser[R]
Public Class Methods
new(use_unicode, colorize)
click to toggle source
# File lib/xcpretty/formatters/formatter.rb, line 77 def initialize(use_unicode, colorize) @use_unicode = use_unicode @colorize = colorize @parser = Parser.new(self) end
Public Instance Methods
finish()
click to toggle source
# File lib/xcpretty/formatters/formatter.rb, line 83 def finish end
format_compile_error(file, file_path, reason, line, cursor)
click to toggle source
# File lib/xcpretty/formatters/formatter.rb, line 123 def format_compile_error(file, file_path, reason, line, cursor) "\n#{red(error_symbol + " ")}#{file_path}: #{red(reason)}\n\n" \ "#{line}\n#{cyan(cursor)}\n\n" end
format_compile_warning(file, file_path, reason, line, cursor)
click to toggle source
# File lib/xcpretty/formatters/formatter.rb, line 132 def format_compile_warning(file, file_path, reason, line, cursor) "\n#{yellow(warning_symbol + ' ')}#{file_path}: #{yellow(reason)}\n\n" \ "#{line}\n#{cyan(cursor)}\n\n" end
format_duplicate_symbols(message, file_paths)
click to toggle source
# File lib/xcpretty/formatters/formatter.rb, line 147 def format_duplicate_symbols(message, file_paths) "\n#{red(error_symbol + " " + message)}\n" \ "> #{file_paths.map { |path| path.split('/').last }.join("\n> ")}\n" end
format_error(message)
click to toggle source
# File lib/xcpretty/formatters/formatter.rb, line 119 def format_error(message) "\n#{red(error_symbol + " " + message)}\n\n" end
format_file_missing_error(reason, file_path)
click to toggle source
# File lib/xcpretty/formatters/formatter.rb, line 128 def format_file_missing_error(reason, file_path) "\n#{red(error_symbol + " " + reason)} #{file_path}\n\n" end
format_ld_warning(reason)
click to toggle source
# File lib/xcpretty/formatters/formatter.rb, line 137 def format_ld_warning(reason) "#{yellow(warning_symbol + ' ' + reason)}" end
format_other(text)
click to toggle source
# File lib/xcpretty/formatters/formatter.rb, line 156 def format_other(text) "" end
format_test_summary(executed_message, failures_per_suite)
click to toggle source
Will be printed by default. Override with '' if you don't want summary
# File lib/xcpretty/formatters/formatter.rb, line 101 def format_test_summary(executed_message, failures_per_suite) failures = format_failures(failures_per_suite) if failures.empty? final_message = green(executed_message) else final_message = red(executed_message) end text = [failures, final_message].join("\n\n\n").strip "\n\n#{text}" end
format_undefined_symbols(message, symbol, reference)
click to toggle source
# File lib/xcpretty/formatters/formatter.rb, line 141 def format_undefined_symbols(message, symbol, reference) "\n#{red(error_symbol + " " + message)}\n" \ "> Symbol: #{symbol}\n" \ "> Referenced from: #{reference}\n\n" end
format_will_not_be_code_signed(message)
click to toggle source
# File lib/xcpretty/formatters/formatter.rb, line 152 def format_will_not_be_code_signed(message) "#{yellow(warning_symbol + " " + message)}" end
optional_newline()
click to toggle source
If you want to print inline, override optional_newline
with ''
# File lib/xcpretty/formatters/formatter.rb, line 92 def optional_newline "\n" end
pretty_format(text)
click to toggle source
Override if you want to catch something specific with your regex
# File lib/xcpretty/formatters/formatter.rb, line 87 def pretty_format(text) parser.parse(text) end
use_unicode?()
click to toggle source
# File lib/xcpretty/formatters/formatter.rb, line 96 def use_unicode? !!@use_unicode end
Private Instance Methods
error_symbol()
click to toggle source
# File lib/xcpretty/formatters/formatter.rb, line 190 def error_symbol use_unicode? ? ERROR : ASCII_ERROR end
format_failure(f)
click to toggle source
# File lib/xcpretty/formatters/formatter.rb, line 173 def format_failure(f) snippet = Snippet.from_filepath(f[:file_path]) output = " #{f[:test_case]}, #{red(f[:reason])}" output += "\n #{cyan(f[:file_path])}" return output if snippet.contents.empty? output += "\n ```\n" if @colorize output += Syntax.highlight(snippet) else output += snippet.contents end output += " ```" output end
format_failures(failures_per_suite)
click to toggle source
# File lib/xcpretty/formatters/formatter.rb, line 163 def format_failures(failures_per_suite) failures_per_suite.map do |suite, failures| formatted_failures = failures.map do |failure| format_failure(failure) end.join("\n\n") "\n#{suite}\n#{formatted_failures}" end.join("\n") end
warning_symbol()
click to toggle source
# File lib/xcpretty/formatters/formatter.rb, line 194 def warning_symbol use_unicode? ? WARNING : ASCII_WARNING end