class XCPretty::JSONCompilationDatabase

Constants

FILEPATH

Public Class Methods

new(options) click to toggle source
Calls superclass method
# File lib/xcpretty/reporters/json_compilation_database.rb, line 15
def initialize(options)
  super(options)
  @compilation_units = []
  @pch_path = nil
  @current_file = nil
  @current_path = nil
end

Public Instance Methods

format_compile(file_name, file_path) click to toggle source
# File lib/xcpretty/reporters/json_compilation_database.rb, line 27
def format_compile(file_name, file_path)
  @current_file = file_name
  @current_path = file_path
end
format_compile_command(compiler_command, file_path) click to toggle source
# File lib/xcpretty/reporters/json_compilation_database.rb, line 32
def format_compile_command(compiler_command, file_path)
  directory = file_path.gsub("#{@current_path}", '').gsub(/\/$/, '')
  directory = '/' if directory.empty?

  cmd = compiler_command
  cmd = cmd.gsub(/(\-include)\s.*\.pch/, "\\1 #{@pch_path}") if @pch_path

  @compilation_units << {command: cmd,
                         file: @current_path,
                         directory: directory}
end
format_process_pch_command(file_path) click to toggle source
# File lib/xcpretty/reporters/json_compilation_database.rb, line 23
def format_process_pch_command(file_path)
  @pch_path = file_path
end
load_dependencies() click to toggle source
# File lib/xcpretty/reporters/json_compilation_database.rb, line 6
def load_dependencies
  unless @@loaded ||= false
    require 'fileutils'
    require 'pathname'
    require 'json'
    @@loaded = true
  end
end
write_report() click to toggle source
# File lib/xcpretty/reporters/json_compilation_database.rb, line 44
def write_report
  File.open(@filepath, 'w') do |f|
    f.write(@compilation_units.to_json)
  end
end