class Juniter::File

Attributes

parsed_xml[R]
test_suites[R]

Public Class Methods

from_file(filename) click to toggle source
# File lib/juniter/file.rb, line 12
def from_file(filename)
  ::File.open(filename, "r") do |f|
    read f
  end
end
new(xml) click to toggle source
# File lib/juniter/file.rb, line 25
def initialize(xml)
  @parsed_xml = xml
  root = xml.respond_to?(:root) ? xml.root : xml
  raise ArgumentError, "Invalid JUnit file. Expected <testsuites> or <testsuite> as the root node but got <#{root.value}>" unless %w{testsuites testsuite}.include?(root.value)
  @test_suites = TestSuites.from_xml(root) if root.value == "testsuites"
  @test_suites ||= TestSuites.new.tap do |test_suites|
    test_suites.test_suites = [ TestSuite.from_xml(root) ]
  end
end
parse(xml_string) click to toggle source
# File lib/juniter/file.rb, line 18
def parse(xml_string)
  new(Ox.parse(xml_string))
end
read(io) click to toggle source
# File lib/juniter/file.rb, line 8
def read(io)
  parse io.read
end

Public Instance Methods

to_xml() click to toggle source
# File lib/juniter/file.rb, line 35
def to_xml
  Ox.dump(test_suites.to_xml)
end