Class: JSONFormatter
- Inherits:
-
XCPretty::Simple
- Object
- XCPretty::Simple
- JSONFormatter
- Defined in:
- lib/json_formatter.rb
Constant Summary collapse
- FILE_PATH =
'build/reports/errors.json'.freeze
Instance Method Summary collapse
- #finish ⇒ Object
- #format_compile_error(file, file_path, reason, line, cursor) ⇒ Object
- #format_compile_warning(file_name, 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(message) ⇒ Object
- #format_test_summary(message, failures_per_suite) ⇒ Object
- #format_undefined_symbols(message, symbol, reference) ⇒ Object
- #format_warning(message) ⇒ Object
-
#initialize(use_unicode, colorize) ⇒ JSONFormatter
constructor
A new instance of JSONFormatter.
- #json_output ⇒ Object
- #write_to_file ⇒ Object
- #write_to_file_if_needed ⇒ Object
Constructor Details
#initialize(use_unicode, colorize) ⇒ JSONFormatter
Returns a new instance of JSONFormatter.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/json_formatter.rb', line 7 def initialize(use_unicode, colorize) super @warnings = [] @ld_warnings = [] @compile_warnings = [] @errors = [] @compile_errors = [] @file_missing_errors = [] @undefined_symbols_errors = [] @duplicate_symbols_errors = [] @failures = {} @tests_summary_messages = [] end |
Instance Method Details
#finish ⇒ Object
98 99 100 101 |
# File 'lib/json_formatter.rb', line 98 def finish write_to_file super end |
#format_compile_error(file, file_path, reason, line, cursor) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/json_formatter.rb', line 51 def format_compile_error(file, file_path, reason, line, cursor) @compile_errors << { file_name: file, file_path: file_path, reason: reason, line: line, cursor: cursor } write_to_file_if_needed super end |
#format_compile_warning(file_name, file_path, reason, line, cursor) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/json_formatter.rb', line 33 def format_compile_warning(file_name, file_path, reason, line, cursor) @compile_warnings << { file_name: file_name, file_path: file_path, reason: reason, line: line, cursor: cursor } write_to_file_if_needed super end |
#format_duplicate_symbols(message, file_paths) ⇒ Object
82 83 84 85 86 87 88 89 |
# File 'lib/json_formatter.rb', line 82 def format_duplicate_symbols(, file_paths) @duplicate_symbols_errors = { message: , file_paths: file_paths } write_to_file_if_needed super end |
#format_error(message) ⇒ Object
45 46 47 48 49 |
# File 'lib/json_formatter.rb', line 45 def format_error() @errors << write_to_file_if_needed super end |
#format_file_missing_error(reason, file_path) ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/json_formatter.rb', line 63 def format_file_missing_error(reason, file_path) @file_missing_errors << { file_path: file_path, reason: reason } write_to_file_if_needed super end |
#format_ld_warning(message) ⇒ Object
21 22 23 24 25 |
# File 'lib/json_formatter.rb', line 21 def format_ld_warning() @ld_warnings << write_to_file_if_needed super end |
#format_test_summary(message, failures_per_suite) ⇒ Object
91 92 93 94 95 96 |
# File 'lib/json_formatter.rb', line 91 def format_test_summary(, failures_per_suite) @failures.merge!(failures_per_suite) @tests_summary_messages << write_to_file_if_needed super end |
#format_undefined_symbols(message, symbol, reference) ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'lib/json_formatter.rb', line 72 def format_undefined_symbols(, symbol, reference) @undefined_symbols_errors = { message: , symbol: symbol, reference: reference } write_to_file_if_needed super end |
#format_warning(message) ⇒ Object
27 28 29 30 31 |
# File 'lib/json_formatter.rb', line 27 def format_warning() @warnings << write_to_file_if_needed super end |
#json_output ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/json_formatter.rb', line 103 def json_output { warnings: @warnings, ld_warnings: @ld_warnings, compile_warnings: @compile_warnings, errors: @errors, compile_errors: @compile_errors, file_missing_errors: @file_missing_errors, undefined_symbols_errors: @undefined_symbols_errors, duplicate_symbols_errors: @duplicate_symbols_errors, tests_failures: @failures, tests_summary_messages: @tests_summary_messages } end |
#write_to_file ⇒ Object
122 123 124 125 126 127 128 129 130 |
# File 'lib/json_formatter.rb', line 122 def write_to_file file_name = ENV['XCPRETTY_JSON_FILE_OUTPUT'] || FILE_PATH dirname = File.dirname(file_name) FileUtils.mkdir_p dirname File.open(file_name, 'w') do |io| io.write(JSON.pretty_generate(json_output)) end end |
#write_to_file_if_needed ⇒ Object
118 119 120 |
# File 'lib/json_formatter.rb', line 118 def write_to_file_if_needed write_to_file unless XCPretty::Formatter.method_defined? :finish end |