Class: Xcov::Manager

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

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Manager

Returns a new instance of Manager.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/xcov/manager.rb', line 13

def initialize(options)
  # Set command options
  Xcov.config = options

  # Set project options
  FastlaneCore::Project.detect_projects(options)
  Xcov.project = FastlaneCore::Project.new(options)

  # Set ignored files handler
  Xcov.ignore_handler = IgnoreHandler.new

  # Print summary
  FastlaneCore::PrintTable.print_values(config: options, hide_keys: [:slack_url, :coveralls_repo_token], title: "Summary for xcov #{Xcov::VERSION}")
end

Instance Method Details

#parse_xccoverageObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/xcov/manager.rb', line 38

def parse_xccoverage
  # Find .xccoverage file
  # If no xccov direct path, use the old derived data path method
  if xccov_file_direct_path.nil?
    extension = Xcov.config[:legacy_support] ? "xccoverage" : "xccovreport"
    test_logs_path = derived_data_path + "Logs/Test/"
    xccoverage_files = Dir["#{test_logs_path}*.#{extension}", "#{test_logs_path}*.xcresult/*/action.#{extension}"].sort_by { |filename| File.mtime(filename) }.reverse

    unless test_logs_path.directory? && !xccoverage_files.empty?
      ErrorHandler.handle_error("XccoverageFileNotFound")
    end
  else
    xccoverage_files = ["#{xccov_file_direct_path}"]
  end

  # Convert .xccoverage file to json
  ide_foundation_path = Xcov.config[:legacy_support] ? nil : Xcov.config[:ideFoundationPath]
  json_report = Xcov::Core::Parser.parse(xccoverage_files.first, Xcov.config[:output_directory], ide_foundation_path)
  ErrorHandler.handle_error("UnableToParseXccoverageFile") if json_report.nil?

  json_report
end

#runObject



28
29
30
31
32
33
34
35
36
# File 'lib/xcov/manager.rb', line 28

def run
  # Run xcov
  json_report = parse_xccoverage
  report = generate_xcov_report(json_report)
  validate_report(report)
  submit_to_coveralls(report)
  tmp_dir = File.join(Xcov.config[:output_directory], 'tmp')
  FileUtils.rm_rf(tmp_dir) if File.directory?(tmp_dir)
end