Class: TestCenter::Helper::ReportNameHelper
- Inherits:
-
Object
- Object
- TestCenter::Helper::ReportNameHelper
- Defined in:
- lib/fastlane/plugin/test_center/helper/reportname_helper.rb
Instance Attribute Summary collapse
-
#report_count ⇒ Object
readonly
Returns the value of attribute report_count.
Instance Method Summary collapse
- #html_fileglob ⇒ Object
- #html_filextension ⇒ Object
- #html_last_reportname ⇒ Object
- #html_numbered_fileglob ⇒ Object
- #html_reportname ⇒ Object
- #includes_html? ⇒ Boolean
- #increment ⇒ Object
-
#initialize(output_types = nil, output_files = nil, custom_report_file_name = nil) ⇒ ReportNameHelper
constructor
A new instance of ReportNameHelper.
- #junit_fileglob ⇒ Object
- #junit_filextension ⇒ Object
- #junit_last_reportname ⇒ Object
- #junit_numbered_fileglob ⇒ Object
- #junit_reportname ⇒ Object
- #numbered_filename(filename) ⇒ Object
- #scan_options ⇒ Object
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.('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_count ⇒ Object (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_fileglob ⇒ Object
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_filextension ⇒ Object
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_reportname ⇒ Object
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_fileglob ⇒ Object
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_reportname ⇒ Object
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
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 |
#increment ⇒ Object
101 102 103 |
# File 'lib/fastlane/plugin/test_center/helper/reportname_helper.rb', line 101 def increment @report_count += 1 end |
#junit_fileglob ⇒ Object
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_filextension ⇒ Object
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_reportname ⇒ Object
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_fileglob ⇒ Object
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_reportname ⇒ Object
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_options ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/fastlane/plugin/test_center/helper/reportname_helper.rb', line 41 def 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 |