Sha256: 27acf5750c17a26fad2eec367f73790be00097a57213deffd0406fbb56055e3f
Contents?: true
Size: 1.37 KB
Versions: 5
Compression:
Stored size: 1.37 KB
Contents
module XCPretty class JSONCompilationDatabase include XCPretty::FormatMethods FILEPATH = 'build/reports/compilation_db.json' 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 def initialize(options) load_dependencies @filepath = options[:path] || FILEPATH @parser = Parser.new(self) @compilation_units = [] @current_file = nil @current_path = nil end def handle(line) @parser.parse(line) end def format_compile(file_name, file_path) @current_file = file_name @current_path = File.dirname(file_path) end def format_compile_command(compiler_command) @compilation_units << { :command => compiler_command, :file => @current_file, :directory => @current_path } end def finish FileUtils.mkdir_p(File.dirname(@filepath)) write_report end private def write_report File.open(@filepath, 'w') do |f| f.write(@compilation_units.to_json) end end end end
Version data entries
5 entries across 5 versions & 2 rubygems