class TestCenter::Helper::ReportNameHelper

Attributes

report_count[R]

Public Class Methods

ensure_output_includes_xcresult(output_types, output_files) click to toggle source
# File lib/fastlane/plugin/test_center/helper/reportname_helper.rb, line 149
def self.ensure_output_includes_xcresult(output_types, output_files)
  return [output_types, output_files] if includes_xcresult?(output_types) || output_types.nil?

  output_types = output_types.split(',').push('xcresult').join(',')
  if output_files
    output_files = output_files.split(',').push('report.xcresult').join(',')
  end

  [output_types, output_files]
end
includes_xcresult?(output_types) click to toggle source
# File lib/fastlane/plugin/test_center/helper/reportname_helper.rb, line 160
def self.includes_xcresult?(output_types)
 return false unless ::FastlaneCore::Helper.xcode_at_least?('11.0.0')
 output_types && output_types.split(',').find_index('xcresult') != nil
end
new(output_types = nil, output_files = nil, custom_report_file_name = nil) click to toggle source
# File lib/fastlane/plugin/test_center/helper/reportname_helper.rb, line 8
def initialize(output_types = nil, output_files = nil, custom_report_file_name = nil)
  @output_types = output_types || 'junit'
  @output_files = output_files || custom_report_file_name
  @report_count = 0

  if @output_types && @output_files.nil?
    @output_files = @output_types.split(',').map { |type| "report.#{type}" }.join(',')
  end
  unless @output_types.include?('junit')
    FastlaneCore::UI.important('Scan output types missing \'junit\', adding it')
    @output_types = @output_types.split(',').push('junit').join(',')
    if @output_types.split(',').size == @output_files.split(',').size + 1
      @output_files = @output_files.split(',').push('report.xml').join(',')
      FastlaneCore::UI.message('As output files has one less than the new number of output types, assumming the filename for the junit was missing and added it')
    end
  end

  types = @output_types.split(',').each(&:chomp)
  files = @output_files.split(',').each(&:chomp)
  unless files.size == types.size
    raise ArgumentError, "Error: count of :output_types, #{types}, does not match the output filename(s) #{files}"
  end
end

Public Instance Methods

html_fileglob() click to toggle source
# File lib/fastlane/plugin/test_center/helper/reportname_helper.rb, line 112
def html_fileglob
  "#{File.basename(html_reportname, '.*')}*#{html_filextension}"
end
html_filextension() click to toggle source
# File lib/fastlane/plugin/test_center/helper/reportname_helper.rb, line 108
def html_filextension
  File.extname(html_reportname)
end
html_last_reportname() click to toggle source
# File lib/fastlane/plugin/test_center/helper/reportname_helper.rb, line 95
def html_last_reportname
  html_index = @output_types.split(',').find_index('html')
  numbered_filename(@output_files.to_s.split(',')[html_index])
end
html_numbered_fileglob() click to toggle source
# File lib/fastlane/plugin/test_center/helper/reportname_helper.rb, line 116
def html_numbered_fileglob
  "#{File.basename(html_reportname, '.*')}-[1-9]*#{html_filextension}"
end
html_reportname(suffix = '') click to toggle source
# File lib/fastlane/plugin/test_center/helper/reportname_helper.rb, line 100
def html_reportname(suffix = '')
  html_index = @output_types.split(',').find_index('html')
  report_name = @output_files.to_s.split(',')[html_index]
  return report_name if suffix.empty?

  "#{File.basename(report_name, '.*')}-#{suffix}#{html_filextension}"
end
includes_html?() click to toggle source
# File lib/fastlane/plugin/test_center/helper/reportname_helper.rb, line 91
def includes_html?
  @output_types.split(',').find_index('html') != nil
end
includes_json?() click to toggle source
# File lib/fastlane/plugin/test_center/helper/reportname_helper.rb, line 120
def includes_json?
  @output_types.split(',').find_index('json') != nil
end
includes_xcresult?() click to toggle source
# File lib/fastlane/plugin/test_center/helper/reportname_helper.rb, line 165
def includes_xcresult?
  self.class.includes_xcresult?(@output_types)
end
increment() click to toggle source
# File lib/fastlane/plugin/test_center/helper/reportname_helper.rb, line 194
def increment
  @report_count += 1
end
json_fileglob() click to toggle source
# File lib/fastlane/plugin/test_center/helper/reportname_helper.rb, line 141
def json_fileglob
  "#{File.basename(json_reportname, '.*')}*#{json_filextension}"
end
json_filextension() click to toggle source
# File lib/fastlane/plugin/test_center/helper/reportname_helper.rb, line 137
def json_filextension
  File.extname(json_reportname)
end
json_last_reportname() click to toggle source
# File lib/fastlane/plugin/test_center/helper/reportname_helper.rb, line 124
def json_last_reportname
  json_index = @output_types.split(',').find_index('json')
  numbered_filename(@output_files.to_s.split(',')[json_index])
end
json_numbered_fileglob() click to toggle source
# File lib/fastlane/plugin/test_center/helper/reportname_helper.rb, line 145
def json_numbered_fileglob
  "#{File.basename(json_reportname, '.*')}-[1-9]*#{json_filextension}"
end
json_reportname(suffix = '') click to toggle source
# File lib/fastlane/plugin/test_center/helper/reportname_helper.rb, line 129
def json_reportname(suffix = '')
  json_index = @output_types.split(',').find_index('json')
  report_name = @output_files.to_s.split(',')[json_index]
  return report_name if suffix.empty?

  "#{File.basename(report_name, '.*')}-#{suffix}#{json_filextension}"
end
junit_fileglob() click to toggle source
# File lib/fastlane/plugin/test_center/helper/reportname_helper.rb, line 83
def junit_fileglob
  "#{File.basename(junit_reportname, '.*')}*#{junit_filextension}"
end
junit_filextension() click to toggle source
# File lib/fastlane/plugin/test_center/helper/reportname_helper.rb, line 79
def junit_filextension
  File.extname(junit_reportname)
end
junit_last_reportname() click to toggle source
# File lib/fastlane/plugin/test_center/helper/reportname_helper.rb, line 66
def junit_last_reportname
  junit_index = @output_types.split(',').find_index('junit')
  numbered_filename(@output_files.to_s.split(',')[junit_index])
end
junit_numbered_fileglob() click to toggle source
# File lib/fastlane/plugin/test_center/helper/reportname_helper.rb, line 87
def junit_numbered_fileglob
  "#{File.basename(junit_reportname, '.*')}-[1-9]*#{junit_filextension}"
end
junit_reportname(suffix = '') click to toggle source
# File lib/fastlane/plugin/test_center/helper/reportname_helper.rb, line 71
def junit_reportname(suffix = '')
  junit_index = @output_types.split(',').find_index('junit')
  report_name = @output_files.to_s.split(',')[junit_index]
  return report_name if suffix.empty?

  "#{File.basename(report_name, '.*')}-#{suffix}#{junit_filextension}"
end
numbered_filename(filename) click to toggle source
# File lib/fastlane/plugin/test_center/helper/reportname_helper.rb, line 32
def numbered_filename(filename)
  if @report_count > 0
    basename = File.basename(filename, '.*')
    extension = File.extname(filename)
    filename = "#{basename}-#{@report_count + 1}#{extension}"
  end
  filename
end
scan_options() click to toggle source
# File lib/fastlane/plugin/test_center/helper/reportname_helper.rb, line 41
def scan_options
  options = {}

  types = @output_types.split(',').each(&:chomp)
  files = @output_files.split(',').each(&:chomp)
  if (json_index = types.find_index('json'))
    options[:formatter] = 'xcpretty-json-formatter'
    files.delete_at(json_index)
    types.delete_at(json_index)
  end
  if (xcresult_index = types.find_index('xcresult'))
    files.delete_at(xcresult_index)
    types.delete_at(xcresult_index)
  end
  files.map! do |filename|
    filename.chomp
    numbered_filename(filename)
  end

  options.merge(
    output_types: types.join(','),
    output_files: files.join(',')
  )
end
xcresult_bundlename(suffix = '') click to toggle source
# File lib/fastlane/plugin/test_center/helper/reportname_helper.rb, line 174
def xcresult_bundlename(suffix = '')
  xcresult_index = @output_types.split(',').find_index('xcresult')
  report_name = @output_files.to_s.split(',')[xcresult_index]
  return report_name if suffix.empty?

  "#{File.basename(report_name, '.*')}-#{suffix}#{xcresult_filextension}"
end
xcresult_fileglob() click to toggle source
# File lib/fastlane/plugin/test_center/helper/reportname_helper.rb, line 186
def xcresult_fileglob
  "#{File.basename(xcresult_bundlename, '.*')}*#{xcresult_filextension}"
end
xcresult_filextension() click to toggle source
# File lib/fastlane/plugin/test_center/helper/reportname_helper.rb, line 182
def xcresult_filextension
  File.extname(xcresult_bundlename)
end
xcresult_last_bundlename() click to toggle source
# File lib/fastlane/plugin/test_center/helper/reportname_helper.rb, line 169
def xcresult_last_bundlename
  xcresult_index = @output_types.split(',').find_index('xcresult')
  numbered_filename(@output_files.to_s.split(',')[xcresult_index])
end
xcresult_numbered_fileglob() click to toggle source
# File lib/fastlane/plugin/test_center/helper/reportname_helper.rb, line 190
def xcresult_numbered_fileglob
  "#{File.basename(xcresult_bundlename, '.*')}-[1-9]*#{xcresult_filextension}"
end