Sha256: f2caec193c5739b72c54fc27b7d65e27d0a17c8fe7dce52e9021660a7f37ca24

Contents?: true

Size: 1.28 KB

Versions: 10

Compression:

Stored size: 1.28 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']} -s #{file} -o #{report_output.path}"
        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

10 entries across 10 versions & 1 rubygems

Version Path
xcov-0.10 lib/xcov-core.rb
xcov-0.9 lib/xcov-core.rb
xcov-0.8 lib/xcov-core.rb
xcov-0.7 lib/xcov-core.rb
xcov-0.6 lib/xcov-core.rb
xcov-0.5 lib/xcov-core.rb
xcov-0.4 lib/xcov-core.rb
xcov-0.3 lib/xcov-core.rb
xcov-0.2 lib/xcov-core.rb
xcov-0.1 lib/xcov-core.rb