Sha256: 2bc441ea119c4b9c83d5760f78d852406145c7e85f26583c86d1f7b51b18e770

Contents?: true

Size: 1.49 KB

Versions: 2

Compression:

Stored size: 1.49 KB

Contents

module Scan
  class ReportCollector
    SUPPORTED = %w(html junit json-compilation-database)

    def parse_raw_file(path)
      raise "Couldn't find file at path '#{path}'".red unless File.exist?(path)

      commands = generate_commands(path)
      commands.each do |output_path, command|
        system(command)
        Helper.log.info("Successfully generated report at '#{output_path}'".green)

        if !Scan.config[:skip_html_open] and output_path.end_with?(".html")
          # Open the HTML file
          `open --hide '#{output_path}'`
        end
      end
    end

    # Returns a hash containg the resulting path as key and the command as value
    def generate_commands(path, types: nil, output_file_name: nil)
      types ||= Scan.config[: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)
          Helper.log.error "Couldn't find reporter '#{type}', available #{SUPPORTED.join(', ')}"
          next
        end

        file_name = "report.#{type}"
        output_path = output_file_name || File.join(Scan.config[:output_directory], file_name)
        parts = ["cat '#{path}' | "]
        parts << "xcpretty"
        parts << "--report #{type}"
        parts << "--output '#{output_path}'"
        parts << "&> /dev/null "

        commands[output_path] = parts.join(" ")
      end

      return commands
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
scan-0.1.1 lib/scan/report_collector.rb
scan-0.1.0 lib/scan/report_collector.rb