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_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_generate_dsym, #format_libtool, #format_linking, #format_measuring_test, #format_passing_test, #format_pbxcp, #format_pending_test, #format_phase_script_execution, #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.
22
23
24
25
26
27
28
29
30
|
# File 'lib/xcpretty/reporters/json_compilation_database.rb', line 22
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
53
54
55
56
|
# File 'lib/xcpretty/reporters/json_compilation_database.rb', line 53
def finish
FileUtils.mkdir_p(File.dirname(@file_path))
write_report
end
|
40
41
42
43
|
# File 'lib/xcpretty/reporters/json_compilation_database.rb', line 40
def format_compile(file_name, file_path)
@current_file = file_name
@current_path = file_path
end
|
45
46
47
48
49
50
51
|
# File 'lib/xcpretty/reporters/json_compilation_database.rb', line 45
def format_compile_command(compiler_command, file_path)
directory = file_path.gsub("#{@current_path}", '').gsub(/\/$/, '')
directory = '/' if directory.empty?
@compilation_units << {:command => compiler_command.gsub(/(\-include)\s.*\.pch/, "\\1 #{@pch_path}"),
:file => @current_path,
:directory => directory}
end
|
36
37
38
|
# File 'lib/xcpretty/reporters/json_compilation_database.rb', line 36
def format_process_pch_command(file_path)
@pch_path = file_path
end
|
#handle(line) ⇒ Object
32
33
34
|
# File 'lib/xcpretty/reporters/json_compilation_database.rb', line 32
def handle(line)
@parser.parse(line)
end
|
#load_dependencies ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/xcpretty/reporters/json_compilation_database.rb', line 7
def load_dependencies
unless @@loaded ||= false
require 'fileutils'
require 'pathname'
unless Object.const_defined?(:JSON)
begin
require 'json'
rescue LoadError
require File.expand_path(File.join(File.dirname(__FILE__), '../../../vendor/json_pure/generator'))
end
end
@@loaded = true
end
end
|