Class: XCPretty::Formatter
- Inherits:
-
Object
- Object
- XCPretty::Formatter
show all
- Includes:
- ANSI, FormatMethods
- Defined in:
- lib/xcpretty/formatters/formatter.rb
Constant Summary
collapse
- ERROR =
'❌ '
- ASCII_ERROR =
'[x]'
- WARNING =
'⚠️ '
- ASCII_WARNING =
'[!]'
XCPretty::FormatMethods::EMPTY
Constants included
from ANSI
ANSI::COLORS, ANSI::EFFECT, ANSI::FORMATTED_MATCHER
Instance Attribute Summary collapse
Attributes included from ANSI
#colorize
Instance Method Summary
collapse
-
#finish ⇒ Object
-
#format_compile_error(file, file_path, reason, line, cursor) ⇒ Object
-
#format_compile_warning(file, file_path, reason, line, cursor) ⇒ Object
-
#format_duplicate_symbols(message, file_paths) ⇒ Object
-
#format_error(message) ⇒ Object
-
#format_file_missing_error(reason, file_path) ⇒ Object
-
#format_ld_warning(reason) ⇒ Object
-
#format_other(text) ⇒ Object
-
#format_test_summary(executed_message, failures_per_suite) ⇒ Object
Will be printed by default.
-
#format_undefined_symbols(message, symbol, reference) ⇒ Object
-
#format_will_not_be_code_signed(message) ⇒ Object
-
#initialize(use_unicode, colorize) ⇒ Formatter
constructor
A new instance of Formatter.
-
#optional_newline ⇒ Object
If you want to print inline, override #optional_newline with ”.
-
#pretty_format(text) ⇒ Object
Override if you want to catch something specific with your regex.
-
#use_unicode? ⇒ Boolean
#format_aggregate_target, #format_analyze, #format_analyze_target, #format_build_target, #format_check_dependencies, #format_clean, #format_clean_remove, #format_clean_target, #format_codesign, #format_compile, #format_compile_command, #format_compile_storyboard, #format_compile_xib, #format_copy_header_file, #format_copy_plist_file, #format_copy_strings_file, #format_cpresource, #format_failing_test, #format_generate_dsym, #format_libtool, #format_linking, #format_measuring_test, #format_passing_test, #format_pbxcp, #format_pending_test, #format_phase_script_execution, #format_phase_success, #format_preprocess, #format_process_info_plist, #format_process_pch, #format_process_pch_command, #format_shell_command, #format_test_run_finished, #format_test_run_started, #format_test_suite_started, #format_tiffutil, #format_touch, #format_warning, #format_write_auxiliary_files, #format_write_file
Methods included from ANSI
#ansi_parse, #applied_effects, #colorize?, #cyan, #green, #red, #strip, #white, #yellow
Constructor Details
#initialize(use_unicode, colorize) ⇒ Formatter
Returns a new instance of Formatter.
77
78
79
80
81
|
# File 'lib/xcpretty/formatters/formatter.rb', line 77
def initialize(use_unicode, colorize)
@use_unicode = use_unicode
@colorize = colorize
@parser = Parser.new(self)
end
|
Instance Attribute Details
#parser ⇒ Object
Returns the value of attribute parser.
75
76
77
|
# File 'lib/xcpretty/formatters/formatter.rb', line 75
def parser
@parser
end
|
Instance Method Details
#finish ⇒ Object
83
84
|
# File 'lib/xcpretty/formatters/formatter.rb', line 83
def finish
end
|
123
124
125
126
|
# 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
|
132
133
134
135
|
# 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
|
147
148
149
150
|
# 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
|
119
120
121
|
# File 'lib/xcpretty/formatters/formatter.rb', line 119
def format_error(message)
"\n#{red(error_symbol + " " + message)}\n\n"
end
|
128
129
130
|
# 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
|
137
138
139
|
# File 'lib/xcpretty/formatters/formatter.rb', line 137
def format_ld_warning(reason)
"#{yellow(warning_symbol + ' ' + reason)}"
end
|
156
157
158
|
# File 'lib/xcpretty/formatters/formatter.rb', line 156
def format_other(text)
""
end
|
Will be printed by default. Override with ” if you don’t want summary
101
102
103
104
105
106
107
108
109
110
111
|
# 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
|
141
142
143
144
145
|
# 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
|
152
153
154
|
# File 'lib/xcpretty/formatters/formatter.rb', line 152
def format_will_not_be_code_signed(message)
"#{yellow(warning_symbol + " " + message)}"
end
|
#optional_newline ⇒ Object
If you want to print inline, override #optional_newline with ”
92
93
94
|
# File 'lib/xcpretty/formatters/formatter.rb', line 92
def optional_newline
"\n"
end
|
Override if you want to catch something specific with your regex
87
88
89
|
# File 'lib/xcpretty/formatters/formatter.rb', line 87
def pretty_format(text)
parser.parse(text)
end
|
#use_unicode? ⇒ Boolean
96
97
98
|
# File 'lib/xcpretty/formatters/formatter.rb', line 96
def use_unicode?
!!@use_unicode
end
|