Class: TestCenter::Helper::ReportNameHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/plugin/test_center/helper/reportname_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output_types = nil, output_files = nil, custom_report_file_name = nil) ⇒ ReportNameHelper

Returns a new instance of ReportNameHelper.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# 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

Instance Attribute Details

#report_countObject (readonly)

Returns the value of attribute report_count.



6
7
8
# File 'lib/fastlane/plugin/test_center/helper/reportname_helper.rb', line 6

def report_count
  @report_count
end

Instance Method Details

#html_fileglobObject



93
94
95
# File 'lib/fastlane/plugin/test_center/helper/reportname_helper.rb', line 93

def html_fileglob
  "#{File.basename(html_reportname, '.*')}*#{html_filextension}"
end

#html_filextensionObject



89
90
91
# File 'lib/fastlane/plugin/test_center/helper/reportname_helper.rb', line 89

def html_filextension
  File.extname(html_reportname)
end

#html_last_reportnameObject



79
80
81
82
# File 'lib/fastlane/plugin/test_center/helper/reportname_helper.rb', line 79

def html_last_reportname
  html_index = @output_types.split(',').find_index('html')
  numbered_filename(@output_files.to_s.split(',')[html_index])
end

#html_numbered_fileglobObject



97
98
99
# File 'lib/fastlane/plugin/test_center/helper/reportname_helper.rb', line 97

def html_numbered_fileglob
  "#{File.basename(html_reportname, '.*')}-[1-9]*#{html_filextension}"
end

#html_reportnameObject



84
85
86
87
# File 'lib/fastlane/plugin/test_center/helper/reportname_helper.rb', line 84

def html_reportname
  html_index = @output_types.split(',').find_index('html')
  @output_files.to_s.split(',')[html_index]
end

#includes_html?Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/fastlane/plugin/test_center/helper/reportname_helper.rb', line 75

def includes_html?
  @output_types.split(',').find_index('html') != nil
end

#incrementObject



101
102
103
# File 'lib/fastlane/plugin/test_center/helper/reportname_helper.rb', line 101

def increment
  @report_count += 1
end

#junit_fileglobObject



67
68
69
# File 'lib/fastlane/plugin/test_center/helper/reportname_helper.rb', line 67

def junit_fileglob
  "#{File.basename(junit_reportname, '.*')}*#{junit_filextension}"
end

#junit_filextensionObject



63
64
65
# File 'lib/fastlane/plugin/test_center/helper/reportname_helper.rb', line 63

def junit_filextension
  File.extname(junit_reportname)
end

#junit_last_reportnameObject



53
54
55
56
# File 'lib/fastlane/plugin/test_center/helper/reportname_helper.rb', line 53

def junit_last_reportname
  junit_index = @output_types.split(',').find_index('junit')
  numbered_filename(@output_files.to_s.split(',')[junit_index])
end

#junit_numbered_fileglobObject



71
72
73
# File 'lib/fastlane/plugin/test_center/helper/reportname_helper.rb', line 71

def junit_numbered_fileglob
  "#{File.basename(junit_reportname, '.*')}-[1-9]*#{junit_filextension}"
end

#junit_reportnameObject



58
59
60
61
# File 'lib/fastlane/plugin/test_center/helper/reportname_helper.rb', line 58

def junit_reportname
  junit_index = @output_types.split(',').find_index('junit')
  @output_files.to_s.split(',')[junit_index]
end

#numbered_filename(filename) ⇒ Object



32
33
34
35
36
37
38
39
# 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_optionsObject



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/fastlane/plugin/test_center/helper/reportname_helper.rb', line 41

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