lib/xcpretty/reporters/json_compilation_database.rb in xcpretty-0.2.2 vs lib/xcpretty/reporters/json_compilation_database.rb in xcpretty-0.2.3

- old
+ new

@@ -1,10 +1,9 @@ module XCPretty - class JSONCompilationDatabase + class JSONCompilationDatabase < Reporter - include XCPretty::FormatMethods - FILE_PATH = 'build/reports/compilation_db.json' + FILEPATH = 'build/reports/compilation_db.json' def load_dependencies unless @@loaded ||= false require 'fileutils' require 'pathname' @@ -12,23 +11,17 @@ @@loaded = true end end def initialize(options) - load_dependencies - @file_path = options[:path] || FILE_PATH - @parser = Parser.new(self) + super(options) @compilation_units = [] @pch_path = nil @current_file = nil @current_path = nil end - def handle(line) - @parser.parse(line) - end - def format_process_pch_command(file_path) @pch_path = file_path end def format_compile(file_name, file_path) @@ -46,18 +39,11 @@ @compilation_units << {command: cmd, file: @current_path, directory: directory} end - def finish - FileUtils.mkdir_p(File.dirname(@file_path)) - write_report - end - - private - def write_report - File.open(@file_path, 'w') do |f| + File.open(@filepath, 'w') do |f| f.write(@compilation_units.to_json) end end end end