Sha256: df489964a3d4f4abeafe5e9776e44a00f4c258a4e9ac1edb0319f61380de38c0

Contents?: true

Size: 911 Bytes

Versions: 1

Compression:

Stored size: 911 Bytes

Contents

require "xccov-parse/version"
require "xccov-parse/parse"
require "open3"

class Xccov
  # @example
  #
  #     xccov = Xccov.new
  #     xccov.help
  #     json = xccov.view '--only-targets', '--json', '/path/to/Build/Logs/Test/*.xccovreport'
  #     parsed = Xccov::Parse.new(json: json)
  #     parsed.targets_line_coverage["test.examples.app"] #=> 0.35
  #
  def initialize
    @xccov = "#{get_xcrun} xccov"
  end

  private

  def run(*args)
    cmd = args.join ' '
    sto, ste, status = Open3.capture3(cmd)
    if status.success?
      sto
    else
      puts ste
      raise(sto)
    end
  end

  def method_missing(method, *args, &_block)
    if respond_to_missing?
      run(@xccov, method, args)
    else
      super
    end
  end

  def respond_to_missing?
    true
  end

  def get_xcrun
    cmd = `which xcrun`.strip
    return cmd unless cmd.empty?
    raise "You should install xcrun"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
xccov-parse-0.2.0 lib/xccov-parse.rb