Sha256: 06bcbd6e4676e9634800f0ee8954246e86c4beedd2241df699dba57c264b2abb

Contents?: true

Size: 974 Bytes

Versions: 10

Compression:

Stored size: 974 Bytes

Contents

require_relative 'module'

module Trainer
  class JunitGenerator
    attr_accessor :results

    def initialize(results)
      self.results = results
    end

    def generate
      # JUnit file documentation: http://llg.cubic.org/docs/junit/
      # And http://nelsonwells.net/2012/09/how-jenkins-ci-parses-and-displays-junit-output/
      # And http://windyroad.com.au/dl/Open%20Source/JUnit.xsd

      lib_path = Trainer::ROOT
      xml_path = File.join(lib_path, "lib/assets/junit.xml.erb")
      xml = ERB.new(File.read(xml_path), trim_mode: '<>').result(binding) # http://www.rrn.dk/rubys-erb-templating-system

      xml = xml.gsub('system_', 'system-').delete("\e") # Jenkins cannot parse 'ESC' symbol

      # We have to manually clear empty lines
      # They may contain white spaces
      clean_xml = []
      xml.each_line do |row|
        clean_xml << row.delete("\n") if row.strip.to_s.length > 0
      end
      return clean_xml.join("\n")
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
fastlane-2.225.0 trainer/lib/trainer/junit_generator.rb
fastlane-2.224.0 trainer/lib/trainer/junit_generator.rb
fastlane-2.223.1 trainer/lib/trainer/junit_generator.rb
fastlane-2.223.0 trainer/lib/trainer/junit_generator.rb
fastlane-2.222.0 trainer/lib/trainer/junit_generator.rb
fastlane-2.221.1 trainer/lib/trainer/junit_generator.rb
fastlane-2.221.0 trainer/lib/trainer/junit_generator.rb
fastlane-2.220.0 trainer/lib/trainer/junit_generator.rb
fastlane-2.219.0 trainer/lib/trainer/junit_generator.rb
fastlane-2.218.0 trainer/lib/trainer/junit_generator.rb