Class: Scan::XCPrettyReporterOptionsGenerator

Inherits:
Object
  • Object
show all
Defined in:
scan/lib/scan/xcpretty_reporter_options_generator.rb

Constant Summary collapse

SUPPORTED_REPORT_TYPES =
%w(html junit json-compilation-database)

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(open_report, output_types, output_files, output_directory, use_clang_report_name, xcpretty_args) ⇒ XCPrettyReporterOptionsGenerator

Intialize with values from Scan.config matching these param names


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'scan/lib/scan/xcpretty_reporter_options_generator.rb', line 17

def initialize(open_report, output_types, output_files, output_directory, use_clang_report_name, xcpretty_args)
  @open_report = open_report
  @output_types = output_types
  @output_files = output_files
  @output_directory = output_directory
  @use_clang_report_name = use_clang_report_name
  @xcpretty_args = xcpretty_args

  # might already be an array when passed via fastlane
  @output_types = @output_types.split(',') if @output_types.kind_of?(String)

  if @output_files.nil?
    @output_files = @output_types.map { |type| "report.#{type}" }
  elsif @output_files.kind_of?(String)
    # might already be an array when passed via fastlane
    @output_files = @output_files.split(',')
  end

  unless @output_types.length == @output_files.length
    UI.important("WARNING: output_types and output_files do not have the same number of items. Default values will be substituted as needed.")
  end

  (@output_types - SUPPORTED_REPORT_TYPES).each do |type|
    UI.error("Couldn't find reporter '#{type}', available #{SUPPORTED_REPORT_TYPES.join(', ')}")
  end
end

Class Method Details

.generate_from_scan_configObject


7
8
9
10
11
12
13
14
# File 'scan/lib/scan/xcpretty_reporter_options_generator.rb', line 7

def self.generate_from_scan_config
  self.new(Scan.config[:open_report],
           Scan.config[:output_types],
           Scan.config[:output_files] || Scan.config[:custom_report_file_name],
           Scan.config[:output_directory],
           Scan.config[:use_clang_report_name],
           Scan.config[:xcpretty_args])
end

Instance Method Details

#generate_reporter_optionsObject


44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'scan/lib/scan/xcpretty_reporter_options_generator.rb', line 44

def generate_reporter_options
  reporter = []

  valid_types = @output_types & SUPPORTED_REPORT_TYPES
  valid_types.each do |raw_type|
    type = raw_type.strip
    output_path = File.join(File.expand_path(@output_directory), determine_output_file_name(type))
    reporter << "--report #{type}"
    reporter << "--output '#{output_path}'"

    if type == "html" && @open_report
      Scan.cache[:open_html_report_path] = output_path
    end
  end

  # adds another junit reporter in case the user does not specify one
  # this will be used to generate a results table and then discarded
  require 'tempfile'
  @temp_junit_report = Tempfile.new("junit_report")
  Scan.cache[:temp_junit_report] = @temp_junit_report.path
  reporter << "--report junit"
  reporter << "--output '#{Scan.cache[:temp_junit_report]}'"
  return reporter
end

#generate_xcpretty_args_optionsObject


69
70
71
# File 'scan/lib/scan/xcpretty_reporter_options_generator.rb', line 69

def generate_xcpretty_args_options
  return @xcpretty_args
end