Sha256: f900ce1ced3532977977336d00df0b82570553992157be267300fc4abadd6606

Contents?: true

Size: 1.22 KB

Versions: 4

Compression:

Stored size: 1.22 KB

Contents

require 'xcov-core/version'
require 'xcov'
require 'json'
require 'tempfile'
require 'fastlane_core'

module Xcov
  module Core

    ENV['XCOV_CORE_LIBRARY_PATH'] = File.expand_path("../xcov-core/bin", __FILE__) + "/xcov-core"

    class Parser

      def self.parse(file)
        report_output = Tempfile.new("report.json")
        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

      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

    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
xcov-1.2.0 lib/xcov-core.rb
xcov-1.1.2 lib/xcov-core.rb
xcov-1.1.1 lib/xcov-core.rb
xcov-1.1.0 lib/xcov-core.rb