Class: XCPretty::Formatter

Inherits:
Object
  • Object
show all
Includes:
ANSI, FormatMethods
Defined in:
lib/xcpretty/formatters/formatter.rb

Direct Known Subclasses

RSpec, Simple

Constant Summary

Constants included from FormatMethods

XCPretty::FormatMethods::EMPTY_STRING

Constants included from ANSI

ANSI::COLORS, ANSI::EFFECT, ANSI::FORMATTED_MATCHER

Instance Attribute Summary collapse

Attributes included from ANSI

#colorize

Instance Method Summary collapse

Methods included from FormatMethods

#format_analyze, #format_build_target, #format_check_dependencies, #format_clean, #format_clean_remove, #format_clean_target, #format_codesign, #format_compile, #format_compile_error, #format_compile_xib, #format_copy_strings_file, #format_cpresource, #format_error, #format_failing_test, #format_generate_dsym, #format_libtool, #format_linking, #format_passing_test, #format_pbxcp, #format_phase_script_execution, #format_preprocess, #format_process_info_plist, #format_process_pch, #format_test_run_finished, #format_test_run_started, #format_test_suite_started

Methods included from ANSI

#ansi_parse, #applied_effects, #colorize?, #cyan, #green, #red, #strip, #white, #yellow

Constructor Details

#initialize(use_unicode, colorize) ⇒ Formatter



46
47
48
49
50
# File 'lib/xcpretty/formatters/formatter.rb', line 46

def initialize(use_unicode, colorize)
  @use_unicode = use_unicode
  @colorize = colorize
  @parser = Parser.new(self)
end

Instance Attribute Details

#parserObject (readonly)

Returns the value of attribute parser.



44
45
46
# File 'lib/xcpretty/formatters/formatter.rb', line 44

def parser
  @parser
end

Instance Method Details

#format_test_summary(executed_message, failures_per_suite) ⇒ Object

Will be printed by default. Override with ” if you don’t want summary



67
68
69
70
71
72
73
# File 'lib/xcpretty/formatters/formatter.rb', line 67

def format_test_summary(executed_message, failures_per_suite)
  failures = format_failures(failures_per_suite)
  final_message = failures.empty? ? green(executed_message) : red(executed_message)

  text = [failures, final_message].join("\n\n\n").strip
  "\n\n#{text}"
end

#optional_newlineObject

If you want to print inline, override #optional_newline with ”



58
59
60
# File 'lib/xcpretty/formatters/formatter.rb', line 58

def optional_newline
  "\n"
end

#pretty_format(text) ⇒ Object

Override if you want to catch something specific with your regex



53
54
55
# File 'lib/xcpretty/formatters/formatter.rb', line 53

def pretty_format(text)
  parser.parse(text)
end

#use_unicode?Boolean



62
63
64
# File 'lib/xcpretty/formatters/formatter.rb', line 62

def use_unicode?
  !!@use_unicode
end