Class: Yolo::Tasks::Ios::Coverage

Inherits:
BaseTask
  • Object
show all
Defined in:
lib/yolo/tasks/ios/coverage.rb

Overview

Executes all code coverage related tasks

Author:

  • Alex Fish

Instance Method Summary collapse

Methods inherited from BaseTask

#name

Constructor Details

#initializeCoverage

Initializes the class with default settings



14
15
16
17
# File 'lib/yolo/tasks/ios/coverage.rb', line 14

def initialize
  @xcode = Yolo::Tools::Ios::Xcode.new
  super
end

Instance Method Details

#build_pathString

Uses Xcode to find the full path to the build objects

Returns:

  • (String)

    the path to the generated .app file



23
24
25
26
27
28
29
30
# File 'lib/yolo/tasks/ios/coverage.rb', line 23

def build_path
  files = []
  Find.find(@xcode.build_path) do |path|
    files << path if path =~ /.*#{name}-.*\/Build\/Intermediates\/#{name}.build\/.*-iphonesimulator\/#{name}.build\/Objects-normal/
  end
  latest = files.sort_by { |filename| File.mtime(filename)}.last # get the latest
  latest.split("/")[0..-2].join("/") if latest # remove the file and get the dir
end

#defineObject

Defines rake tasks available to the Coverage class



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/yolo/tasks/ios/coverage.rb', line 35

def define
  super
  namespace :yolo do
    namespace :coverage do
      desc "Calculates the specified scheme(s) test coverage."
      task :calculate do
        Yolo::Tools::Ios::Coverage.calculate(build_path.gsub(" ", "\\ "), Dir.pwd)
      end
    end
  end
end