Class: XCPretty::JSONCompilationDatabase
- Inherits:
-
Object
- Object
- XCPretty::JSONCompilationDatabase
show all
- Includes:
- FormatMethods
- Defined in:
- lib/xcpretty/reporters/json_compilation_database.rb
Constant Summary
collapse
- FILE_PATH =
'build/reports/compilation_db.json'
FormatMethods::EMPTY
Instance Method Summary
collapse
#format_analyze, #format_analyze_target, #format_build_target, #format_check_dependencies, #format_clean, #format_clean_remove, #format_clean_target, #format_codesign, #format_compile_error, #format_compile_storyboard, #format_compile_warning, #format_compile_xib, #format_copy_header_file, #format_copy_plist_file, #format_copy_strings_file, #format_cpresource, #format_duplicate_symbols, #format_error, #format_failing_test, #format_file_missing_error, #format_generate_dsym, #format_ld_warning, #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_shell_command, #format_test_run_finished, #format_test_run_started, #format_test_suite_started, #format_test_summary, #format_tiffutil, #format_touch, #format_undefined_symbols, #format_warning, #format_write_auxiliary_files, #format_write_file
Constructor Details
Returns a new instance of JSONCompilationDatabase.
16
17
18
19
20
21
22
23
24
|
# File 'lib/xcpretty/reporters/json_compilation_database.rb', line 16
def initialize(options)
load_dependencies
@file_path = options[:path] || FILE_PATH
@parser = Parser.new(self)
@compilation_units = []
@pch_path = nil
@current_file = nil
@current_path = nil
end
|
Instance Method Details
#finish ⇒ Object
48
49
50
51
|
# File 'lib/xcpretty/reporters/json_compilation_database.rb', line 48
def finish
FileUtils.mkdir_p(File.dirname(@file_path))
write_report
end
|
34
35
36
37
|
# File 'lib/xcpretty/reporters/json_compilation_database.rb', line 34
def format_compile(file_name, file_path)
@current_file = file_name
@current_path = file_path
end
|
39
40
41
42
43
44
45
46
|
# File 'lib/xcpretty/reporters/json_compilation_database.rb', line 39
def format_compile_command(compiler_command, file_path)
directory = file_path.gsub("#{@current_path}", '').gsub(/\/$/, '')
directory = '/' if directory.empty?
cmd = compiler_command.gsub(/(\-include)\s.*\.pch/, "\\1 #{@pch_path}")
@compilation_units << {command: cmd,
file: @current_path,
directory: directory}
end
|
30
31
32
|
# File 'lib/xcpretty/reporters/json_compilation_database.rb', line 30
def format_process_pch_command(file_path)
@pch_path = file_path
end
|
#handle(line) ⇒ Object
26
27
28
|
# File 'lib/xcpretty/reporters/json_compilation_database.rb', line 26
def handle(line)
@parser.parse(line)
end
|
#load_dependencies ⇒ Object
7
8
9
10
11
12
13
14
|
# File 'lib/xcpretty/reporters/json_compilation_database.rb', line 7
def load_dependencies
unless @@loaded ||= false
require 'fileutils'
require 'pathname'
require 'json'
@@loaded = true
end
end
|