Class: Scan::ReportCollector
- Inherits:
-
Object
- Object
- Scan::ReportCollector
- Defined in:
- lib/scan/report_collector.rb
Constant Summary collapse
- SUPPORTED =
%w(html junit json-compilation-database)
Instance Method Summary collapse
- #determine_output_file_name(type) ⇒ Object
-
#generate_commands(path, types: nil, output_file_name: nil) ⇒ Object
Returns a hash containing the resulting path as key and the command as value.
-
#initialize(open_report, output_types, output_directory, use_clang_report_name, custom_report_file_name = nil) ⇒ ReportCollector
constructor
Intialize with values from Scan.config matching these param names.
- #parse_raw_file(path) ⇒ Object
Constructor Details
#initialize(open_report, output_types, output_directory, use_clang_report_name, custom_report_file_name = nil) ⇒ ReportCollector
Intialize with values from Scan.config matching these param names
6 7 8 9 10 11 12 |
# File 'lib/scan/report_collector.rb', line 6 def initialize(open_report, output_types, output_directory, use_clang_report_name, custom_report_file_name = nil) @open_report = open_report @output_types = output_types @output_directory = output_directory @use_clang_report_name = use_clang_report_name @custom_report_file_name = custom_report_file_name end |
Instance Method Details
#determine_output_file_name(type) ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'lib/scan/report_collector.rb', line 60 def determine_output_file_name(type) if @use_clang_report_name && type == "json-compilation-database" "compile_commands.json" elsif !@custom_report_file_name.nil? @custom_report_file_name else "report.#{type}" end end |
#generate_commands(path, types: nil, output_file_name: nil) ⇒ Object
Returns a hash containing the resulting path as key and the command as value
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/scan/report_collector.rb', line 33 def generate_commands(path, types: nil, output_file_name: nil) types ||= @output_types types = types.split(",") if types.kind_of?(String) # might already be an array when passed via fastlane commands = {} types.each do |raw| type = raw.strip unless SUPPORTED.include?(type) UI.error("Couldn't find reporter '#{type}', available #{SUPPORTED.join(', ')}") next end output_path = output_file_name || File.join(File.(@output_directory), determine_output_file_name(type)) parts = ["cat '#{path}' | "] parts << "xcpretty" parts << "--report #{type}" parts << "--output '#{output_path}'" parts << "&> /dev/null " commands[output_path] = parts.join(" ") end return commands end |
#parse_raw_file(path) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/scan/report_collector.rb', line 14 def parse_raw_file(path) UI.user_error!("Couldn't find file at path '#{path}'") unless File.exist?(path) commands = generate_commands(path) commands.each do |output_path, command| if system(command) UI.success("Successfully generated report at '#{output_path}'") else UI.user_error!("Failed to generate report at '#{output_path}'") end if @open_report and output_path.end_with?(".html") # Open the HTML file `open --hide '#{output_path}'` end end end |