Class: Xcov::Core::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/xcov-core.rb

Class Method Summary collapse

Class Method Details

.execute_command(command, description) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/xcov-core.rb', line 26

def self.execute_command(command, description)
  FastlaneCore::CommandExecutor.execute(
    command: command,
    print_all: true,
    print_command: true,
    prefix: description,
    loading: "Loading...",
    error: proc do |error_output|
      begin
        Xcov::ErrorHandler.handle_error(error_output)
      rescue => ex
        Xcov::SlackPoster.new.run({
          build_errors: 1
        })
        raise ex
      end
    end
  )
end

.parse(file, output_directory) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/xcov-core.rb', line 15

def self.parse(file, output_directory)
  tmp_dir = File.join(output_directory, 'tmp')
  FileUtils.mkdir_p(tmp_dir) unless File.directory?(tmp_dir)
  report_output = Tempfile.new("report.json", tmp_dir)
  command = "#{ENV['XCOV_CORE_LIBRARY_PATH'].shellescape} -s #{file.shellescape} -o #{report_output.path.shellescape} --include-lines-info"
  description = [{ prefix: "Parsing .xccoverage file: " }]
  execute_command(command, description)
  output_file = File.read(report_output.path)
  JSON.parse(output_file)
end