class TestCenter::Helper::ReportNameHelper

Public Class Methods

new(output_types = nil, output_files = nil, custom_report_file_name = nil) click to toggle source
# File lib/fastlane/plugin/retry_tests/helper/reportname_helper.rb, line 6
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

increment() click to toggle source
# File lib/fastlane/plugin/retry_tests/helper/reportname_helper.rb, line 65
def increment
  @report_count += 1
end
junit_filextension() click to toggle source
# File lib/fastlane/plugin/retry_tests/helper/reportname_helper.rb, line 61
def junit_filextension
  File.extname(junit_reportname)
end
junit_last_reportname() click to toggle source
# File lib/fastlane/plugin/retry_tests/helper/reportname_helper.rb, line 51
def junit_last_reportname
  junit_index = @output_types.split(',').find_index('junit')
  numbered_filename(@output_files.to_s.split(',')[junit_index])
end
junit_reportname() click to toggle source
# File lib/fastlane/plugin/retry_tests/helper/reportname_helper.rb, line 56
def junit_reportname
  junit_index = @output_types.split(',').find_index('junit')
  @output_files.to_s.split(',')[junit_index]
end
numbered_filename(filename) click to toggle source
# File lib/fastlane/plugin/retry_tests/helper/reportname_helper.rb, line 30
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/retry_tests/helper/reportname_helper.rb, line 39
def scan_options
  files = @output_files.split(',').each(&:chomp)
  files.map! do |filename|
    filename.chomp
    numbered_filename(filename)
  end
  {
    output_types: @output_types,
    output_files: files.join(',')
  }
end